Skip to content

Commit 4cee032

Browse files
committed
#869 backport to Jaybird 5: #864 Increase default and maximum SQL info sizes
1 parent c1ed6aa commit 4cee032

File tree

5 files changed

+35
-5
lines changed

5 files changed

+35
-5
lines changed

jaybird-native/src/main/java/org/firebirdsql/gds/ng/jna/JnaStatement.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -453,14 +453,13 @@ public byte[] getSqlInfo(byte[] requestItems, int bufferLength) throws SQLExcept
453453

454454
@Override
455455
public int getDefaultSqlInfoSize() {
456-
// TODO Test for an optimal buffer size
457456
return getMaxSqlInfoSize();
458457
}
459458

460459
@Override
461460
public int getMaxSqlInfoSize() {
462-
// TODO Is this the actual max, or is it 65535?
463-
return 32767;
461+
// Theoretically, also Firebird 2.1, but not supported since before Jaybird 5
462+
return getDatabase().getServerVersion().isEqualOrAbove(2, 5) ? 65535 : 32767;
464463
}
465464

466465
@Override

src/docs/asciidoc/release_notes.adoc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,20 @@ The following was fixed or changed since Jaybird 6.0.1:
4040
* Improvement: added `authPlugins` property on `FBManager` (https://github.com/FirebirdSQL/jaybird/issues/866[#866])
4141
+
4242
As part of this change, the interface `FBManagerMBean` now extends `AttachmentProperties`, so that all attachment properties are accessible.
43+
* Improvement: increased default and maximum SQL info sizes used for retrieving statement information like columns, parameters and plan information (https://github.com/FirebirdSQL/jaybird/issues/869[#869])
44+
+
45+
The values were changed from the original default and maximum of 32,767 to:
46+
+
47+
--
48+
* For pure Java connections:
49+
** protocol 12 (Firebird 2.5): 65,535 (default and maximum),
50+
** protocol 13 (Firebird 3.0) and higher: 512 KiB default, 16 MiB maximum. +
51+
* For native connections:
52+
** Firebird 2.5 and higher: 65,535 (default and maximum)
53+
--
54+
+
55+
This change improves the performance of preparing statements with a lot of columns and parameters by reducing the number of round-trips needed to retrieve the column and parameter information.
56+
It may also prevent truncation of "`explained plans`" for statements with very complex or extensive plans.
4357

4458
=== Jaybird 6.0.1
4559

src/main/org/firebirdsql/gds/ng/wire/version10/V10Statement.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -649,13 +649,11 @@ protected void processAllocateResponse(GenericResponse response) throws SQLExcep
649649

650650
@Override
651651
public int getDefaultSqlInfoSize() {
652-
// TODO Test for an optimal buffer size
653652
return getMaxSqlInfoSize();
654653
}
655654

656655
@Override
657656
public int getMaxSqlInfoSize() {
658-
// TODO Is this the actual max for the v10 protocol, or is it 65535?
659657
return 32767;
660658
}
661659
}

src/main/org/firebirdsql/gds/ng/wire/version12/V12Statement.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,10 @@ public V12Statement(FbWireDatabase database) {
3636
super(database);
3737
}
3838

39+
@Override
40+
public int getMaxSqlInfoSize() {
41+
// Theoretically, also protocol 11 (Firebird 2.1), but not supported since before Jaybird 5
42+
return 65535;
43+
}
44+
3945
}

src/main/org/firebirdsql/gds/ng/wire/version13/V13Statement.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,17 @@ protected void writeSqlData(XdrOutputStream xdrOut, BlrCalculator blrCalculator,
9999
}
100100
}
101101
}
102+
103+
@Override
104+
public int getDefaultSqlInfoSize() {
105+
return 512 * 1024;
106+
}
107+
108+
@Override
109+
public int getMaxSqlInfoSize() {
110+
// It can be higher: 0xFFFE_FFFF serverside, and Integer.MAX_VALUE - 8 due to Java array size limitations
111+
// 16 MiB is probably already excessive
112+
return 16 * 1024 * 1024;
113+
}
114+
102115
}

0 commit comments

Comments
 (0)