Changeset: 11c4e061a45b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/11c4e061a45b
Modified Files:
        clients/odbc/driver/ODBCDbc.h
        clients/odbc/driver/SQLConnect.c
        clients/odbc/driver/SQLDisconnect.c
        clients/odbc/driver/SQLDriverConnect.c
Branch: odbc-tls
Log Message:

Properly maintain the dsn field


diffs (72 lines):

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
@@ -170,7 +170,7 @@ SQLRETURN MNDBSetConnectAttr(ODBCDbc *db
  */
 extern char *ODBCTranslateSQL(ODBCDbc *dbc, const SQLCHAR *query, size_t 
length, SQLULEN noscan);
 
-extern SQLRETURN MNDBConnectSettings(ODBCDbc *dbc, msettings *settings);
+extern SQLRETURN MNDBConnectSettings(ODBCDbc *dbc, const char *dsn, msettings 
*settings);
 extern SQLRETURN MNDBDriverConnect(ODBCDbc *dbc, SQLHWND WindowHandle, const 
SQLCHAR *InConnectionString, SQLSMALLINT StringLength1, SQLCHAR 
*OutConnectionString, SQLSMALLINT BufferLength, SQLSMALLINT *StringLength2Ptr, 
SQLUSMALLINT DriverCompletion, int tryOnly);
 
 extern bool makeNulTerminated(const SQLCHAR **argument, ssize_t argument_len, 
void **scratch);
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
@@ -469,7 +469,7 @@ MNDBConnect(ODBCDbc *dbc,
 
        SQLRETURN ret;
 
-       ret = MNDBConnectSettings(dbc, settings);
+       ret = MNDBConnectSettings(dbc, dsn, settings);
        if (SQL_SUCCEEDED(ret)) {
                settings = NULL; // must not be free'd now
        }
@@ -498,7 +498,7 @@ end:
 }
 
 SQLRETURN
-MNDBConnectSettings(ODBCDbc *dbc, msettings *settings)
+MNDBConnectSettings(ODBCDbc *dbc, const char *dsn, msettings *settings)
 {
        Mapi mid = mapi_settings(settings);
        if (mid) {
@@ -513,6 +513,9 @@ MNDBConnectSettings(ODBCDbc *dbc, msetti
                return SQL_ERROR;
        }
 
+       free(dbc->dsn);
+       dbc->dsn = dsn ? strdup(dsn) : NULL;
+
        dbc->Connected = true;
        dbc->mapToLongVarchar = msetting_long(settings, MP_MAPTOLONGVARCHAR);
 
diff --git a/clients/odbc/driver/SQLDisconnect.c 
b/clients/odbc/driver/SQLDisconnect.c
--- a/clients/odbc/driver/SQLDisconnect.c
+++ b/clients/odbc/driver/SQLDisconnect.c
@@ -69,10 +69,9 @@ SQLDisconnect(SQLHDBC ConnectionHandle)
        dbc->Mdebug = 0;
        dbc->has_comment = false;
        dbc->raw_strings = false;
-       if (dbc->dsn) {
-               free(dbc->dsn);
-               dbc->dsn = NULL;
-       }
+       free(dbc->dsn);
+       dbc->dsn = NULL;
+
        if (dbc->uid) {
                free(dbc->uid);
                dbc->uid = NULL;
diff --git a/clients/odbc/driver/SQLDriverConnect.c 
b/clients/odbc/driver/SQLDriverConnect.c
--- a/clients/odbc/driver/SQLDriverConnect.c
+++ b/clients/odbc/driver/SQLDriverConnect.c
@@ -369,7 +369,7 @@ MNDBDriverConnect(ODBCDbc *dbc,
        if (*scratch_no_alloc)
                setODBCdebug(scratch_no_alloc, false);
 
-       rc = MNDBConnectSettings(dbc, settings);
+       rc = MNDBConnectSettings(dbc, dsn, settings);
        if (!SQL_SUCCEEDED(rc))
                goto end; // not to 'failure', all errors have already been 
logged
 
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to