Skip to content

Commit 6eab737

Browse files
committed
Make MonetConnection.getDatabaseMicroVersion() public, so it can be called from programs such as JDBC_API_Tester.
In JDBC_API_Tester extended method versionIsAtLeast() to include the microVersion.
1 parent b05398e commit 6eab737

2 files changed

Lines changed: 23 additions & 12 deletions

File tree

src/main/java/org/monetdb/jdbc/MonetConnection.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1933,7 +1933,7 @@ String getDatabaseProductVersion() throws SQLException {
19331933
/**
19341934
* Get the major product version of the connected MonetDB Database Server.
19351935
* The number is extracted from the env_monet_version the first time and cached for next calls.
1936-
* It is called from: MonetDatabaseMetaData and MonetConnection
1936+
* It is called from: MonetConnection, MonetDatabaseMetaData and MonetStatement
19371937
*
19381938
* @return the MonetDB Database Server major version number.
19391939
* @throws SQLException if fetching MonetDB server version string failed
@@ -1959,7 +1959,7 @@ int getDatabaseMajorVersion() throws SQLException {
19591959
/**
19601960
* Get the minor product version of the connected MonetDB Database Server.
19611961
* The number is extracted from the env_monet_version the first time and cached for next calls.
1962-
* It is called from: MonetDatabaseMetaData and MonetConnection
1962+
* It is called from: MonetConnection, MonetDatabaseMetaData and MonetStatement
19631963
*
19641964
* @return the MonetDB Database Server minor version number.
19651965
* @throws SQLException if fetching MonetDB server version string failed
@@ -1989,12 +1989,12 @@ int getDatabaseMinorVersion() throws SQLException {
19891989
/**
19901990
* Get the micro product version of the connected MonetDB Database Server.
19911991
* The number is extracted from the env_monet_version the first time and cached for next calls.
1992-
* It is called from: MonetDatabaseMetaData and MonetConnection
1992+
* It is called from: MonetConnection and JDBC_API_tester, hence it is made public.
19931993
*
19941994
* @return the MonetDB Database Server minor version number.
19951995
* @throws SQLException if fetching MonetDB server version string failed
19961996
*/
1997-
int getDatabaseMicroVersion() throws SQLException {
1997+
public int getDatabaseMicroVersion() throws SQLException {
19981998
if (databaseMicroVersion == 0) {
19991999
if (env_monet_version == null)
20002000
getEnvValues();

tests/JDBC_API_Tester.java

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public final class JDBC_API_Tester {
4242
private Connection con; // main connection shared by all tests
4343
final private int dbmsMajorVersion;
4444
final private int dbmsMinorVersion;
45+
final private int dbmsMicroVersion;
4546
final private boolean isPostDec2023; // flags to support version specific output
4647
final private boolean isPostMar2025;
4748
final private boolean isPostDec2025; // Dec2025-SP1 or later
@@ -61,13 +62,13 @@ public final class JDBC_API_Tester {
6162
DatabaseMetaData dbmd = con_.getMetaData();
6263
dbmsMajorVersion = dbmd.getDatabaseMajorVersion();
6364
dbmsMinorVersion = dbmd.getDatabaseMinorVersion();
65+
dbmsMicroVersion = (con_ instanceof MonetConnection) ? ((MonetConnection) con_).getDatabaseMicroVersion() : 0;
6466
// from version 11.50 on, the MonetDB server returns different metadata for
6567
// integer digits (1 less) and for clob and char columns (now return varchar).
66-
isPostDec2023 = versionIsAtLeast(11, 50);
67-
isPostMar2025 = versionIsAtLeast(11, 54);
68-
// the "micro" version is not easily accessible
69-
// post-Dec2025 means Dec2025-SP1 or later
70-
isPostDec2025 = versionIsAtLeast(11, 56) || (dbmsMajorVersion == 11 && dbmsMinorVersion == 55 && Integer.parseInt(dbmd.getDatabaseProductVersion().substring(6)) >= 2);
68+
isPostDec2023 = versionIsAtLeast(11, 50, 0);
69+
isPostMar2025 = versionIsAtLeast(11, 54, 0);
70+
// post-Dec2025 means Dec2025-SP1 (11.55.2) or later. It has new system table: tmp.dependencies
71+
isPostDec2025 = versionIsAtLeast(11, 55, 2);
7172
}
7273

7374
/**
@@ -165,16 +166,26 @@ public static void main(String[] args) throws Exception {
165166
ConnectionTests.runTests(con_URL);
166167

167168
// invoke running OnClientTester only on Oct2020 (11.39) or older servers
168-
if (!jt.versionIsAtLeast(11,40)) {
169+
if (!jt.versionIsAtLeast(11,40,0)) {
169170
OnClientTester oct = new OnClientTester(con_URL, 0);
170171
int failures = oct.runTests();
171172
if (failures > 0)
172173
System.exit(-1);
173174
}
174175
}
175176

176-
private boolean versionIsAtLeast(int major, int minor) {
177-
return ((dbmsMajorVersion == major && dbmsMinorVersion >= minor) || dbmsMajorVersion > major);
177+
private boolean versionIsAtLeast(int requiredMajor, int requiredMinor, int requiredMicro) {
178+
if (dbmsMajorVersion > requiredMajor)
179+
return true;
180+
if (dbmsMajorVersion < requiredMajor)
181+
return false;
182+
183+
if (dbmsMinorVersion > requiredMinor)
184+
return true;
185+
if (dbmsMinorVersion < requiredMinor)
186+
return false;
187+
188+
return dbmsMicroVersion >= requiredMicro;
178189
}
179190

180191
private void Test_Cautocommit(String arg0) {

0 commit comments

Comments
 (0)