Skip to content

Commit fe3765b

Browse files
committed
#868 backport to Jaybird 5: #864 Increase default and maximum SQL info sizes
1 parent 199527f commit fe3765b

File tree

5 files changed

+33
-5
lines changed

5 files changed

+33
-5
lines changed

src/docs/asciidoc/release_notes.adoc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,18 @@ The following has been changed or fixed since Jaybird 5.0.7:
3737
* Improvement: added `authPlugins` property on `FBManager` (https://github.com/FirebirdSQL/jaybird/issues/865[#865])
3838
+
3939
As part of this change, the interface `FBManagerMBean` now extends `AttachmentProperties`, so that all attachment properties are accessible.
40+
* 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/868[#868])
41+
+
42+
--
43+
* For pure Java connections:
44+
** protocol 12 (Firebird 2.5): 65535 (default and maximum),
45+
** protocol 13 (Firebird 3.0) and higher: 512 KiB default, 16 MiB maximum. +
46+
* For native connections:
47+
** Firebird 2.5 and higher: 65535 (default and maximum)
48+
--
49+
+
50+
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 information.
51+
It may also prevent (or reduce occurrences of) truncation of "`explained plans`" for statements with complex or extensive plans.
4052
4153
[#jaybird-5-0-7-changelog]
4254
=== Jaybird 5.0.7

src/jna-client/org/firebirdsql/gds/ng/jna/JnaStatement.java

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

439439
@Override
440440
public int getDefaultSqlInfoSize() {
441-
// TODO Test for an optimal buffer size
442441
return getMaxSqlInfoSize();
443442
}
444443

445444
@Override
446445
public int getMaxSqlInfoSize() {
447-
// TODO Is this the actual max, or is it 65535?
448-
return 32767;
446+
// Theoretically, also Firebird 2.1, but not supported since before Jaybird 5
447+
return getDatabase().getServerVersion().isEqualOrAbove(2, 5) ? 65535 : 32767;
449448
}
450449

451450
@Override

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

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

615615
@Override
616616
public int getDefaultSqlInfoSize() {
617-
// TODO Test for an optimal buffer size
618617
return getMaxSqlInfoSize();
619618
}
620619

621620
@Override
622621
public int getMaxSqlInfoSize() {
623-
// TODO Is this the actual max for the v10 protocol, or is it 65535?
624622
return 32767;
625623
}
626624
}

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
@@ -101,4 +101,17 @@ protected void writeSqlData(XdrOutputStream xdrOut, BlrCalculator blrCalculator,
101101
}
102102
}
103103
}
104+
105+
@Override
106+
public int getDefaultSqlInfoSize() {
107+
return 512 * 1024;
108+
}
109+
110+
@Override
111+
public int getMaxSqlInfoSize() {
112+
// It can be higher: 0xFFFE_FFFF serverside, and Integer.MAX_VALUE - 8 due to Java array size limitations
113+
// 16 MiB is probably already excessive
114+
return 16 * 1024 * 1024;
115+
}
116+
104117
}

0 commit comments

Comments
 (0)