Changeset: 54f574debd57 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/54f574debd57
Modified Files:
        clients/odbc/driver/ODBCDbc.h
        clients/odbc/driver/SQLConnect.c
        clients/odbc/driver/SQLExecDirect.c
        clients/odbc/driver/SQLExecute.c
        clients/odbc/driver/SQLFetch.c
        clients/odbc/driver/SQLGetConnectAttr.c
        clients/odbc/driver/SQLMoreResults.c
        clients/odbc/driver/SQLSetConnectAttr.c
Branch: odbc-tls
Log Message:

Get rid of sql_attr_connection_timeout


diffs (155 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
@@ -61,7 +61,6 @@ typedef struct tODBCDRIVERDBC {
        int mapToLongVarchar;   /* when > 0 we map WVARCHAR to WLONGVARCHAR, 
default 0 */
        SQLUINTEGER sql_attr_autocommit;
        SQLUINTEGER sql_attr_metadata_id;
-       SQLUINTEGER sql_attr_connection_timeout;
 
        /* MonetDB connection handle & status information */
        Mapi mid;               /* connection with server */
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
@@ -550,9 +550,6 @@ MNDBConnectSettings(ODBCDbc *dbc, const 
        if (!SQL_SUCCEEDED(rc))
                return rc;
 
-       /* set timeout after we're connected */
-       mapi_timeout(dbc->mid, dbc->sql_attr_connection_timeout * 1000);
-
        return SQL_SUCCESS;
 }
 
diff --git a/clients/odbc/driver/SQLExecDirect.c 
b/clients/odbc/driver/SQLExecDirect.c
--- a/clients/odbc/driver/SQLExecDirect.c
+++ b/clients/odbc/driver/SQLExecDirect.c
@@ -40,6 +40,7 @@ ODBCExecDirect(ODBCStmt *stmt, const SQL
        const char *err;
        MapiMsg ret;
        MapiHdl hdl;
+       long timeout;
 
        hdl = stmt->hdl;
 
@@ -93,7 +94,8 @@ ODBCExecDirect(ODBCStmt *stmt, const SQL
                break;
        case MTIMEOUT:
                /* Timeout expired / Communication link failure */
-               addStmtError(stmt, stmt->Dbc->sql_attr_connection_timeout ? 
"HYT00" : "08S01", mapi_error_str(stmt->Dbc->mid), 0);
+               timeout = msetting_long(stmt->Dbc->settings, MP_REPLY_TIMEOUT);
+               addStmtError(stmt, timeout > 0 ? "HYT00" : "08S01", 
mapi_error_str(stmt->Dbc->mid), 0);
                return SQL_ERROR;
        default:
                err = mapi_result_error(hdl);
diff --git a/clients/odbc/driver/SQLExecute.c b/clients/odbc/driver/SQLExecute.c
--- a/clients/odbc/driver/SQLExecute.c
+++ b/clients/odbc/driver/SQLExecute.c
@@ -434,6 +434,7 @@ MNDBExecute(ODBCStmt *stmt)
        int i;
        ODBCDesc *desc;
        SQLLEN offset;
+       long timeout;
 
        /* check statement cursor state, query should be prepared */
        if (stmt->State == INITED ||
@@ -529,7 +530,8 @@ MNDBExecute(ODBCStmt *stmt)
                break;
        case MTIMEOUT:
                /* Timeout expired / Communication link failure */
-               addStmtError(stmt, stmt->Dbc->sql_attr_connection_timeout ? 
"HYT00" : "08S01", mapi_error_str(stmt->Dbc->mid), 0);
+               timeout = msetting_long(stmt->Dbc->settings, MP_REPLY_TIMEOUT);
+               addStmtError(stmt, timeout > 0 ? "HYT00" : "08S01", 
mapi_error_str(stmt->Dbc->mid), 0);
                return SQL_ERROR;
        default:
                errstr = mapi_result_error(hdl);
diff --git a/clients/odbc/driver/SQLFetch.c b/clients/odbc/driver/SQLFetch.c
--- a/clients/odbc/driver/SQLFetch.c
+++ b/clients/odbc/driver/SQLFetch.c
@@ -41,6 +41,7 @@ MNDBFetch(ODBCStmt *stmt, SQLUSMALLINT *
        int i;
        SQLULEN row;
        SQLLEN offset;
+       long timeout;
 
        /* stmt->startRow is the (0 based) index of the first row we
         * stmt->need to fetch */
@@ -102,7 +103,8 @@ MNDBFetch(ODBCStmt *stmt, SQLUSMALLINT *
                                        WriteValue(RowStatusArray, 
SQL_ROW_ERROR);
                                /* Timeout expired / Communication
                                 * link failure */
-                               addStmtError(stmt, 
stmt->Dbc->sql_attr_connection_timeout ? "HYT00" : "08S01", 
mapi_error_str(stmt->Dbc->mid), 0);
+                               timeout = msetting_long(stmt->Dbc->settings, 
MP_REPLY_TIMEOUT);
+                               addStmtError(stmt, timeout > 0 ? "HYT00" : 
"08S01", mapi_error_str(stmt->Dbc->mid), 0);
                                return SQL_ERROR;
                        default:
                                if (RowStatusArray)
diff --git a/clients/odbc/driver/SQLGetConnectAttr.c 
b/clients/odbc/driver/SQLGetConnectAttr.c
--- a/clients/odbc/driver/SQLGetConnectAttr.c
+++ b/clients/odbc/driver/SQLGetConnectAttr.c
@@ -41,6 +41,7 @@ MNDBGetConnectAttr(ODBCDbc *dbc,
                   SQLINTEGER BufferLength,
                   SQLINTEGER *StringLengthPtr)
 {
+       long timeout;
        /* check input parameters */
        if (ValuePtr == NULL) {
                /* Invalid use of null pointer */
@@ -69,7 +70,10 @@ MNDBGetConnectAttr(ODBCDbc *dbc,
                WriteData(ValuePtr, dbc->mid && mapi_is_connected(dbc->mid) ? 
SQL_CD_FALSE : SQL_CD_TRUE, SQLUINTEGER);
                break;
        case SQL_ATTR_CONNECTION_TIMEOUT:       /* SQLUINTEGER */
-               WriteData(ValuePtr, dbc->sql_attr_connection_timeout, 
SQLUINTEGER);
+               timeout = msetting_long(dbc->settings, MP_REPLY_TIMEOUT);
+               if (timeout < 0)
+                       timeout = 0;
+               WriteData(ValuePtr, (SQLUINTEGER)timeout, SQLUINTEGER);
                break;
        case SQL_ATTR_LOGIN_TIMEOUT:            /* SQLUINTEGER */
                /* SQL_LOGIN_TIMEOUT */
diff --git a/clients/odbc/driver/SQLMoreResults.c 
b/clients/odbc/driver/SQLMoreResults.c
--- a/clients/odbc/driver/SQLMoreResults.c
+++ b/clients/odbc/driver/SQLMoreResults.c
@@ -37,6 +37,7 @@ SQLRETURN SQL_API
 SQLMoreResults(SQLHSTMT StatementHandle)
 {
        ODBCStmt *stmt = (ODBCStmt *) StatementHandle;
+       long timeout;
 
 #ifdef ODBCDEBUG
        ODBCLOG("SQLMoreResults %p\n", StatementHandle);
@@ -60,7 +61,8 @@ SQLMoreResults(SQLHSTMT StatementHandle)
                return SQL_ERROR;
        case MTIMEOUT:
                /* Timeout expired / Communication link failure */
-               addStmtError(stmt, stmt->Dbc->sql_attr_connection_timeout ? 
"HYT00" : "08S01", mapi_error_str(stmt->Dbc->mid), 0);
+               timeout = msetting_long(stmt->Dbc->settings, MP_REPLY_TIMEOUT);
+               addStmtError(stmt, timeout > 0 ? "HYT00" : "08S01", 
mapi_error_str(stmt->Dbc->mid), 0);
                return SQL_ERROR;
        default:
                return ODBCInitResult(stmt);
diff --git a/clients/odbc/driver/SQLSetConnectAttr.c 
b/clients/odbc/driver/SQLSetConnectAttr.c
--- a/clients/odbc/driver/SQLSetConnectAttr.c
+++ b/clients/odbc/driver/SQLSetConnectAttr.c
@@ -41,6 +41,7 @@ MNDBSetConnectAttr(ODBCDbc *dbc,
                   SQLINTEGER StringLength)
 {
        (void) StringLength;    /* Stefan: unused!? */
+       long timeout;
 
        switch (Attribute) {
        case SQL_ATTR_AUTOCOMMIT:               /* SQLUINTEGER */
@@ -66,9 +67,10 @@ MNDBSetConnectAttr(ODBCDbc *dbc,
                addDbcError(dbc, "IM001", NULL, 0);
                return SQL_ERROR;
        case SQL_ATTR_CONNECTION_TIMEOUT:       /* SQLUINTEGER */
-               dbc->sql_attr_connection_timeout = (SQLUINTEGER) (uintptr_t) 
ValuePtr;
+               timeout = 1000 * (long)(uintptr_t) ValuePtr;
+               msetting_set_long(dbc->settings, MP_CONNECT_TIMEOUT, timeout);
                if (dbc->mid)
-                       mapi_timeout(dbc->mid, dbc->sql_attr_connection_timeout 
* 1000);
+                       mapi_timeout(dbc->mid, timeout);
                break;
        case SQL_ATTR_LOGIN_TIMEOUT:            /* SQLUINTEGER */
                /* currently only value 0 (no timeout) is accepted
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to