@@ -1786,15 +1786,16 @@ String getJDBCURL() {
17861786 return target .buildUrl ();
17871787 }
17881788
1789- // Internal caches for 4 static mserver5 environment values
1789+ // Internal caches for 5 static mserver5 environment values
17901790 private String env_current_user ;
17911791 private String env_monet_version ;
1792+ private String env_monet_release ;
17921793 private String env_raw_strings ; // Note: this is only supported from Jun2020 (11.37) servers
17931794 private int maxConnections ;
17941795
17951796 /**
1796- * Utility method to fetch 4 mserver5 environment values combined in one query for efficiency.
1797- * We fetch the env values of: current_user, monet_version, max_clients and raw_strings.
1797+ * Utility method to fetch 5 mserver5 environment values combined in one query for efficiency.
1798+ * We fetch the env() values of: current_user, monet_version, monet_release , max_clients and raw_strings.
17981799 * We cache them such that we do not need to query the server again and again.
17991800 * Note: raw_strings is available in sys.env() result set since release Jun2020 (11.37)
18001801 *
@@ -1808,7 +1809,7 @@ private synchronized void getEnvValues() throws SQLException {
18081809 if (st != null ) {
18091810 rs = st .executeQuery (
18101811 "SELECT \" name\" , \" value\" FROM \" sys\" .\" env\" ()" +
1811- " WHERE \" name\" IN ('monet_version', 'max_clients', 'raw_strings')" +
1812+ " WHERE \" name\" IN ('monet_version', 'monet_release', ' max_clients', 'raw_strings')" +
18121813 " UNION SELECT 'current_user' as \" name\" , current_user as \" value\" " );
18131814 if (rs != null ) {
18141815 while (rs .next ()) {
@@ -1820,6 +1821,9 @@ private synchronized void getEnvValues() throws SQLException {
18201821 if ("monet_version" .equals (prop )) {
18211822 env_monet_version = value ;
18221823 } else
1824+ if ("monet_release" .equals (prop )) {
1825+ env_monet_release = value ;
1826+ } else
18231827 if ("raw_strings" .equals (prop )) {
18241828 env_raw_strings = value ;
18251829 } else
@@ -1839,7 +1843,7 @@ private synchronized void getEnvValues() throws SQLException {
18391843 } finally {
18401844 closeResultsetStatement (rs , st );
18411845 }
1842- // for debug: System.out.println("Read: env_current_user: " + env_current_user + " env_monet_version: " + env_monet_version + " env_max_clients: " + maxConnections + " env_raw_strings: " + env_raw_strings);
1846+ // for debug: System.out.println("Read: env_current_user: " + env_current_user + " env_monet_version: " + env_monet_version + " env_monet_release: " + env_monet_release + " env_max_clients: " + maxConnections + " env_raw_strings: " + env_raw_strings);
18431847 }
18441848
18451849 /**
@@ -1893,6 +1897,22 @@ boolean inRawStringsMode() throws SQLException {
18931897 return "true" .equals (env_raw_strings );
18941898 }
18951899
1900+ /**
1901+ * Get the product release of the connected MonetDB server.
1902+ * It is called from JdbcClient, hence it is made public.
1903+ *
1904+ * @return the MonetDB server release string.
1905+ * @throws SQLException if fetching MonetDB server release string failed
1906+ */
1907+ public String getServerProductRelease () throws SQLException {
1908+ if (env_monet_release == null )
1909+ getEnvValues ();
1910+ if (env_monet_version != null )
1911+ return env_monet_release ;
1912+ // always return a valid String to prevent NPE
1913+ return "" ;
1914+ }
1915+
18961916 /**
18971917 * Get the product version of the connected MonetDB Database Server.
18981918 * It is called from: MonetDatabaseMetaData
@@ -1903,9 +1923,9 @@ boolean inRawStringsMode() throws SQLException {
19031923 String getDatabaseProductVersion () throws SQLException {
19041924 if (env_monet_version == null )
19051925 getEnvValues ();
1906- // always return a valid String to prevent NPE in getTables() and getTableTypes()
19071926 if (env_monet_version != null )
19081927 return env_monet_version ;
1928+ // always return a valid String to prevent NPE in getTables() and getTableTypes()
19091929 return "" ;
19101930 }
19111931
0 commit comments