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

Improve connection speed of ODBC driver.
Make use of handshake-time option settings, and don't set timezone since
that was already done during handshake.


diffs (63 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
@@ -39,34 +39,6 @@
 #endif
 
 static void
-set_timezone(Mapi mid)
-{
-       char buf[128];
-       time_t t, lt, gt;
-       struct tm *tmp;
-       long tzone;
-       MapiHdl hdl;
-
-       /* figure out our current timezone */
-       t = time(NULL);
-       tmp = gmtime(&t);
-       gt = mktime(tmp);
-       tmp = localtime(&t);
-       lt = mktime(tmp);
-       tzone = (long) (gt - lt);
-       if (tzone < 0)
-               snprintf(buf, sizeof(buf),
-                        "SET TIME ZONE INTERVAL '+%02ld:%02ld' HOUR TO MINUTE",
-                        -tzone / 3600, (-tzone % 3600) / 60);
-       else
-               snprintf(buf, sizeof(buf),
-                        "SET TIME ZONE INTERVAL '-%02ld:%02ld' HOUR TO MINUTE",
-                        tzone / 3600, (tzone % 3600) / 60);
-       if ((hdl = mapi_query(mid, buf)) != NULL)
-               mapi_close_handle(hdl);
-}
-
-static void
 get_serverinfo(ODBCDbc *dbc)
 {
        MapiHdl hdl;
@@ -263,7 +235,12 @@ MNDBConnect(ODBCDbc *dbc,
 
        /* connect to a server on host via port */
        /* FIXME: use dbname from ODBC connect string/options here */
-       mid = mapi_connect(host, port, uid, pwd, "sql", dbname);
+       mid = mapi_mapi(host, port, uid, pwd, "sql", dbname);
+       if (mid) {
+               mapi_setAutocommit(mid, dbc->sql_attr_autocommit == 
SQL_AUTOCOMMIT_ON);
+               mapi_set_size_header(mid, true);
+               mapi_reconnect(mid);
+       }
        if (mid == NULL || mapi_error(mid)) {
                /* Client unable to establish connection */
                addDbcError(dbc, "08001", NULL, 0);
@@ -294,10 +271,7 @@ MNDBConnect(ODBCDbc *dbc,
                if (dbc->dbname != NULL)
                        free(dbc->dbname);
                dbc->dbname = (char *) dbname; /* discard const */
-               mapi_setAutocommit(mid, dbc->sql_attr_autocommit == 
SQL_AUTOCOMMIT_ON);
-               set_timezone(mid);
                get_serverinfo(dbc);
-               mapi_set_size_header(mid, true);
                /* set timeout after we're connected */
                mapi_timeout(mid, dbc->sql_attr_connection_timeout * 1000);
        }
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to