Changeset: b9cdb1420209 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b9cdb1420209
Modified Files:
        clients/odbc/driver/ODBCDbc.c
        clients/odbc/driver/ODBCDbc.h
        clients/odbc/driver/SQLConnect.c
        clients/odbc/driver/SQLGetInfo.c
Branch: Aug2011
Log Message:

Ask server for its version number and use that information.
We now return the correct version information in the SQLGetInfo call
to get the SQL_DBMS_VER property, and we only attempt to get
headersize information from a new enough server.  (The latter would
hang when a new client asks this of an old server.)


diffs (83 lines):

diff --git a/clients/odbc/driver/ODBCDbc.c b/clients/odbc/driver/ODBCDbc.c
--- a/clients/odbc/driver/ODBCDbc.c
+++ b/clients/odbc/driver/ODBCDbc.c
@@ -80,6 +80,9 @@ newODBCDbc(ODBCEnv *env)
        dbc->Connected = 0;
        dbc->sql_attr_autocommit = SQL_AUTOCOMMIT_ON;   /* default is 
autocommit */
        dbc->mid = NULL;
+       dbc->major = 0;
+       dbc->minor = 0;
+       dbc->patch = 0;
        dbc->cachelimit = 0;
        dbc->Mdebug = 0;
 
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
@@ -70,6 +70,7 @@ typedef struct tODBCDRIVERDBC {
        /* MonetDB connection handle & status information */
        Mapi mid;               /* connection with server */
        int cachelimit;         /* cache limit we requested */
+       short major, minor, patch; /* version of server */
        int Mdebug;
 
        /* Dbc children: list of ODBC Statement handles created within
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
@@ -86,6 +86,21 @@ set_timezone(Mapi mid)
 #endif
 }
 
+static void
+get_serverversion(ODBCDbc *dbc)
+{
+       MapiHdl hdl;
+       char *v;
+
+       if ((hdl = mapi_query(dbc->mid, "select value from env() where name = 
'monet_version'")) == NULL)
+               return;
+       while (mapi_fetch_row(hdl)) {
+               v = mapi_fetch_field(hdl, 0);
+               sscanf(v, "%hd.%hd.%hd", &dbc->major, &dbc->minor, &dbc->patch);
+       }
+       mapi_close_handle(hdl);
+}
+
 SQLRETURN
 SQLConnect_(ODBCDbc *dbc,
            SQLCHAR *ServerName,
@@ -234,7 +249,10 @@ SQLConnect_(ODBCDbc *dbc,
                dbc->dbname = schema ? strdup(schema) : NULL;
                mapi_setAutocommit(mid, dbc->sql_attr_autocommit == 
SQL_AUTOCOMMIT_ON);
                set_timezone(mid);
-               mapi_set_size_header(mid, 1);
+               get_serverversion(dbc);
+               if (dbc->major > 11 ||
+                   (dbc->major == 11 && dbc->minor >= 5))
+                       mapi_set_size_header(mid, 1);
        }
 
        return rc;
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
@@ -427,15 +427,11 @@ SQLGetInfo_(ODBCDbc *dbc,
        case SQL_DBMS_NAME:
                sValue = PACKAGE_NAME;
                break;
-       case SQL_DBMS_VER: {
-               int maj = 0, min = 0, pat = 0;
-               /* should be the server's version, not the client's */
-               sscanf(PACKAGE_VERSION, "%d.%d.%d", &maj, &min, &pat);
-               snprintf(buf, sizeof(buf), "%02d.%02d.%04d %s", maj, min, pat,
-                        MONETDB_RELEASE);
+       case SQL_DBMS_VER:
+               snprintf(buf, sizeof(buf), "%02d.%02d.%04d",
+                        dbc->major, dbc->minor, dbc->patch);
                sValue = buf;
                break;
-       }
        case SQL_PROCEDURES:
                sValue = "N";
                break;
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to