Changeset: 1e9de30b8b99 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/1e9de30b8b99
Modified Files:
        clients/odbc/driver/SQLConnect.c
Branch: Mar2025
Log Message:

Optimise ODBC Connection time. Run query to find out if table sys.comments 
exist only for old (before 2019) servers.


diffs (53 lines):

diff --git a/clients/odbc/driver/SQLConnect.c b/clients/odbc/driver/SQLConnect.c
--- a/clients/odbc/driver/SQLConnect.c
+++ b/clients/odbc/driver/SQLConnect.c
@@ -73,16 +73,22 @@ get_serverinfo(ODBCDbc *dbc)
        }
        if (mapi_error(dbc->mid))
                goto end;
-       mapi_close_handle(hdl);
-       if ((hdl = mapi_query(dbc->mid, "select id from sys._tables where name 
= 'comments' and schema_id = (select id from sys.schemas where name = 'sys')")) 
== NULL)
-               goto end;
-       if (mapi_error(dbc->mid))
-               goto end;
-       n = NULL;
-       while (mapi_fetch_row(hdl)) {
-               n = mapi_fetch_field(hdl, 0);
+
+       /* table sys.comments should exist since Mar2018 (11.29) */
+       if (dbc->major == 11 && dbc->minor > 29) {
+               dbc->has_comment = true;
+       } else {
+               mapi_close_handle(hdl);
+               if ((hdl = mapi_query(dbc->mid, "select id from sys._tables 
where name = 'comments' and schema_id = (select id from sys.schemas where name 
= 'sys')")) == NULL)
+                       goto end;
+               if (mapi_error(dbc->mid))
+                       goto end;
+               n = NULL;
+               if (mapi_fetch_row(hdl)) {
+                       n = mapi_fetch_field(hdl, 0);
+               }
+               dbc->has_comment = n != NULL;
        }
-       dbc->has_comment = n != NULL;
 
        rc = SQL_SUCCESS;
 end:
@@ -136,7 +142,6 @@ makeNulTerminated(const SQLCHAR **argume
 char*
 buildConnectionString(const char *dsn, const msettings *settings)
 {
-
        size_t pos = 0;
        size_t cap = 1024;
        char *buf = malloc(cap);  // reallocprintf will deal with allocation 
failures
@@ -494,9 +499,6 @@ MNDBConnectSettings(ODBCDbc *dbc, const 
        return SQL_SUCCESS;
 }
 
-
-
-
 SQLRETURN SQL_API
 SQLConnect(SQLHDBC ConnectionHandle,
           SQLCHAR *ServerName,
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to