Changeset: 9c079fe040da for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/9c079fe040da
Modified Files:
        clients/odbc/ChangeLog
        clients/odbc/driver/ODBCDbc.h
        clients/odbc/driver/SQLConnect.c
        clients/odbc/driver/SQLGetInfo.c
Branch: default
Log Message:

Fixed implementation of SQLGetInfo(hdbc, SQL_MAX_DRIVER_CONNECTIONS, ...). It 
used to always return a value of 64. Now it returns the MonetDB server value.


diffs (81 lines):

diff --git a/clients/odbc/ChangeLog b/clients/odbc/ChangeLog
--- a/clients/odbc/ChangeLog
+++ b/clients/odbc/ChangeLog
@@ -1,6 +1,11 @@
 # ChangeLog file for odbc
 # This file is updated with Maddlog
 
+* Thu Jun  2 2022 Martin van Dinther <martin.van.dint...@monetdbsolutions.com>
+- Fixed implementation of SQLGetInfo(hdbc, SQL_MAX_DRIVER_CONNECTIONS,
+  ...). It used to always return a value of 64. Now it returns the
+  MonetDB server value.
+
 * Thu May 19 2022 Martin van Dinther <martin.van.dint...@monetdbsolutions.com>
 - Corrected SQLSpecialColumns(..., SQL_BEST_ROWID, ...). Previously it only
   returned rows when the table had a primary key. Now it also returns
diff --git a/clients/odbc/driver/ODBCDbc.h b/clients/odbc/driver/ODBCDbc.h
--- a/clients/odbc/driver/ODBCDbc.h
+++ b/clients/odbc/driver/ODBCDbc.h
@@ -65,6 +65,7 @@ typedef struct tODBCDRIVERDBC {
        int cachelimit;         /* cache limit we requested */
        SQLULEN qtimeout;       /* current query timeout */
        short major, minor, patch; /* version of server */
+       SQLUSMALLINT maxclients;   /* mserver5 max_clients value */
        int Mdebug;
 
        /* Dbc children: list of ODBC Statement handles created within
@@ -75,7 +76,6 @@ typedef struct tODBCDRIVERDBC {
 } ODBCDbc;
 
 
-
 /*
  * Creates a new allocated ODBCDbc object and initializes it.
  *
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
@@ -72,7 +72,7 @@ get_serverinfo(ODBCDbc *dbc)
        MapiHdl hdl;
        char *n, *v;
 
-       if ((hdl = mapi_query(dbc->mid, "select name, value from sys.env() 
where name in ('monet_version', 'gdk_dbname')")) == NULL)
+       if ((hdl = mapi_query(dbc->mid, "select name, value from sys.env() 
where name in ('monet_version', 'gdk_dbname', 'max_clients')")) == NULL)
                return;
        while (mapi_fetch_row(hdl)) {
                n = mapi_fetch_field(hdl, 0);
@@ -80,6 +80,9 @@ get_serverinfo(ODBCDbc *dbc)
                if (strcmp(n, "monet_version") == 0) {
                        sscanf(v, "%hd.%hd.%hd",
                               &dbc->major, &dbc->minor, &dbc->patch);
+               } else
+               if (strcmp(n, "max_clients") == 0) {
+                       sscanf(v, "%hu", &dbc->maxclients);
                } else {
                        assert(strcmp(n, "gdk_dbname") == 0);
                        assert(dbc->dbname == NULL ||
diff --git a/clients/odbc/driver/SQLGetInfo.c b/clients/odbc/driver/SQLGetInfo.c
--- a/clients/odbc/driver/SQLGetInfo.c
+++ b/clients/odbc/driver/SQLGetInfo.c
@@ -46,8 +46,9 @@ MNDBGetInfo(ODBCDbc *dbc,
        /* For some info types an active connection is needed */
        if (!dbc->Connected &&
            (InfoType == SQL_DATA_SOURCE_NAME ||
-            InfoType == SQL_SERVER_NAME ||
             InfoType == SQL_DATABASE_NAME ||
+            InfoType == SQL_DBMS_VER ||
+            InfoType == SQL_MAX_DRIVER_CONNECTIONS ||
             InfoType == SQL_USER_NAME ||
             InfoType == SQL_KEYWORDS)) {
                /* Connection does not exist */
@@ -694,9 +695,7 @@ MNDBGetInfo(ODBCDbc *dbc,
                len = sizeof(SQLUSMALLINT);
                break;
        case SQL_MAX_DRIVER_CONNECTIONS:
-               nValue = 64;    /* default value of mserver5 */
-               /* TODO query the server for the actual value via SQL:
-                  SELECT value FROM sys.env() WHERE name = 'max_clients'; */
+               nValue = dbc->maxclients;
                len = sizeof(SQLUSMALLINT);
                break;
        case SQL_MAX_IDENTIFIER_LEN:
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to