Changeset: 2d5cd6e6efea for monetdb-java
URL: https://dev.monetdb.org/hg/monetdb-java/rev/2d5cd6e6efea
Modified Files:
        src/main/java/org/monetdb/jdbc/MonetConnection.java
        tests/JDBC_API_Tester.java
Branch: default
Log Message:

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.


diffs (96 lines):

diff --git a/src/main/java/org/monetdb/jdbc/MonetConnection.java 
b/src/main/java/org/monetdb/jdbc/MonetConnection.java
--- a/src/main/java/org/monetdb/jdbc/MonetConnection.java
+++ b/src/main/java/org/monetdb/jdbc/MonetConnection.java
@@ -1933,7 +1933,7 @@ public class MonetConnection
        /**
         * Get the major product version of the connected MonetDB Database 
Server.
         * The number is extracted from the env_monet_version the first time 
and cached for next calls.
-        * It is called from: MonetDatabaseMetaData and MonetConnection
+        * It is called from: MonetConnection, MonetDatabaseMetaData and 
MonetStatement
         *
         * @return the MonetDB Database Server major version number.
         * @throws SQLException if fetching MonetDB server version string failed
@@ -1959,7 +1959,7 @@ public class MonetConnection
        /**
         * Get the minor product version of the connected MonetDB Database 
Server.
         * The number is extracted from the env_monet_version the first time 
and cached for next calls.
-        * It is called from: MonetDatabaseMetaData and MonetConnection
+        * It is called from: MonetConnection, MonetDatabaseMetaData and 
MonetStatement
         *
         * @return the MonetDB Database Server minor version number.
         * @throws SQLException if fetching MonetDB server version string failed
@@ -1989,12 +1989,12 @@ public class MonetConnection
        /**
         * Get the micro product version of the connected MonetDB Database 
Server.
         * The number is extracted from the env_monet_version the first time 
and cached for next calls.
-        * It is called from: MonetDatabaseMetaData and MonetConnection
+        * It is called from: MonetConnection and JDBC_API_tester, hence it is 
made public.
         *
         * @return the MonetDB Database Server minor version number.
         * @throws SQLException if fetching MonetDB server version string failed
         */
-       int getDatabaseMicroVersion() throws SQLException {
+       public int getDatabaseMicroVersion() throws SQLException {
                if (databaseMicroVersion == 0) {
                        if (env_monet_version == null)
                                getEnvValues();
diff --git a/tests/JDBC_API_Tester.java b/tests/JDBC_API_Tester.java
--- a/tests/JDBC_API_Tester.java
+++ b/tests/JDBC_API_Tester.java
@@ -42,6 +42,7 @@ public final class JDBC_API_Tester {
        private Connection con;         // main connection shared by all tests
        final private int dbmsMajorVersion;
        final private int dbmsMinorVersion;
+       final private int dbmsMicroVersion;
        final private boolean isPostDec2023;    // flags to support version 
specific output
        final private boolean isPostMar2025;
        final private boolean isPostDec2025;    // Dec2025-SP1 or later
@@ -61,13 +62,13 @@ public final class JDBC_API_Tester {
                DatabaseMetaData dbmd = con_.getMetaData();
                dbmsMajorVersion = dbmd.getDatabaseMajorVersion();
                dbmsMinorVersion = dbmd.getDatabaseMinorVersion();
+               dbmsMicroVersion = (con_ instanceof MonetConnection) ? 
((MonetConnection) con_).getDatabaseMicroVersion() : 0;
                // from version 11.50 on, the MonetDB server returns different 
metadata for
                // integer digits (1 less) and for clob and char columns (now 
return varchar).
-               isPostDec2023 = versionIsAtLeast(11, 50);
-               isPostMar2025 = versionIsAtLeast(11, 54);
-               // the "micro" version is not easily accessible
-               // post-Dec2025 means Dec2025-SP1 or later
-               isPostDec2025 = versionIsAtLeast(11, 56) || (dbmsMajorVersion 
== 11 && dbmsMinorVersion == 55 && 
Integer.parseInt(dbmd.getDatabaseProductVersion().substring(6)) >= 2);
+               isPostDec2023 = versionIsAtLeast(11, 50, 0);
+               isPostMar2025 = versionIsAtLeast(11, 54, 0);
+               // post-Dec2025 means Dec2025-SP1 (11.55.2) or later. It has 
new system table: tmp.dependencies
+               isPostDec2025 = versionIsAtLeast(11, 55, 2);
        }
 
        /**
@@ -165,7 +166,7 @@ public final class JDBC_API_Tester {
                ConnectionTests.runTests(con_URL);
 
                // invoke running OnClientTester only on Oct2020 (11.39) or 
older servers
-               if (!jt.versionIsAtLeast(11,40)) {
+               if (!jt.versionIsAtLeast(11,40,0)) {
                        OnClientTester oct = new OnClientTester(con_URL, 0);
                        int failures = oct.runTests();
                        if (failures > 0)
@@ -173,8 +174,18 @@ public final class JDBC_API_Tester {
                }
        }
 
-       private boolean versionIsAtLeast(int major, int minor) {
-               return ((dbmsMajorVersion == major && dbmsMinorVersion >= 
minor) || dbmsMajorVersion > major);
+       private boolean versionIsAtLeast(int requiredMajor, int requiredMinor, 
int requiredMicro) {
+               if (dbmsMajorVersion > requiredMajor)
+                       return true;
+               if (dbmsMajorVersion < requiredMajor)
+                       return false;
+
+               if (dbmsMinorVersion > requiredMinor)
+                       return true;
+               if (dbmsMinorVersion < requiredMinor)
+                       return false;
+
+               return dbmsMicroVersion >= requiredMicro;
        }
 
        private void Test_Cautocommit(String arg0) {
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to