Skip to content

Commit fef5d26

Browse files
committed
Optimise implementation of internal methods privilege_codesTableExists() and commentsTableExists().
When the version of the connected server is Jul2021 (11.41.5) or newer, we no longer sent a query to the server to check if table exists on the server.
1 parent 97842ab commit fef5d26

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

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

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1737,7 +1737,7 @@ void setQueryTimeout(final int seconds) throws SQLException {
17371737

17381738
// as of release Jun2020 (11.37.7) the function sys.settimeout(secs bigint)
17391739
// is deprecated and replaced by new sys.setquerytimeout(secs int)
1740-
if (checkMinimumDBVersion(11, 37))
1740+
if (checkMinimumDBVersion(11, 37, 7))
17411741
callstmt = "CALL sys.\"setquerytimeout\"(" + seconds + ")";
17421742
else
17431743
callstmt = "CALL sys.\"settimeout\"(" + seconds + ")";
@@ -2042,7 +2042,7 @@ boolean checkMinimumDBVersion(int major, int minor) {
20422042
* @return true when the server supports ODBC/JDBC escape sequence syntax else false.
20432043
*/
20442044
boolean supportsEscapeSequenceSyntax() {
2045-
return checkMinimumDBVersion(11, 47);
2045+
return checkMinimumDBVersion(11, 47, 0);
20462046
}
20472047

20482048
/**
@@ -2081,6 +2081,15 @@ boolean supportsLargePrepares() {
20812081
* @return whether the system table sys.privilege_codes exist in the connected server.
20822082
*/
20832083
boolean privilege_codesTableExists() {
2084+
if (hasPrivilege_codesTable)
2085+
return true;
2086+
2087+
// optimisation: servers from Jul2021 (11.41.5) onwards will have the system table. No need to query the server.
2088+
if (checkMinimumDBVersion(11, 41, 5)) {
2089+
hasPrivilege_codesTable = true;
2090+
return hasPrivilege_codesTable;
2091+
}
2092+
20842093
if (!queriedPrivilege_codesTable) {
20852094
querySysTable();
20862095
queriedPrivilege_codesTable = true; // set flag, so the querying is done only at first invocation.
@@ -2100,6 +2109,15 @@ boolean privilege_codesTableExists() {
21002109
* @return whether the system table sys.comments exist in the connected server.
21012110
*/
21022111
boolean commentsTableExists() {
2112+
if (hasCommentsTable)
2113+
return true;
2114+
2115+
// optimisation: servers from Jul2021 (11.41.5) onwards will have the system table. No need to query the server.
2116+
if (checkMinimumDBVersion(11, 41, 5)) {
2117+
hasCommentsTable = true;
2118+
return hasCommentsTable;
2119+
}
2120+
21032121
if (!queriedCommentsTable) {
21042122
querySysTable();
21052123
queriedCommentsTable = true; // set flag, so the querying is done only at first invocation.

0 commit comments

Comments
 (0)