From 5ca9326508e5ee5941a1c730a8ede780d958b5e4 Mon Sep 17 00:00:00 2001 From: Dave Page Date: Thu, 24 Nov 2005 11:44:59 +0000 Subject: [PATCH] Make sure the StringLength is set correctly for SQLGetConnectAttr values that are actually in SQLGetConnectOption --- pgapi30.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/pgapi30.c b/pgapi30.c index 2665921..7c15fa3 100644 --- a/pgapi30.c +++ b/pgapi30.c @@ -363,7 +363,7 @@ PGAPI_GetConnectAttr(HDBC ConnectionHandle, { ConnectionClass *conn = (ConnectionClass *) ConnectionHandle; RETCODE ret = SQL_SUCCESS; - SQLINTEGER len = 4; + SQLINTEGER len = sizeof(SQLUINTEGER); mylog("PGAPI_GetConnectAttr %d\n", Attribute); switch (Attribute) @@ -386,6 +386,36 @@ PGAPI_GetConnectAttr(HDBC ConnectionHandle, break; default: ret = PGAPI_GetConnectOption(ConnectionHandle, (UWORD) Attribute, Value); + + /* We need to make sure the length is set correct for these... */ + switch (Attribute) + { + case SQL_ACCESS_MODE: + case SQL_AUTOCOMMIT: + case SQL_LOGIN_TIMEOUT: + case SQL_PACKET_SIZE: + case SQL_QUIET_MODE: + case SQL_TXN_ISOLATION: + len = sizeof(UDWORD); + break; + + case SQL_CURRENT_QUALIFIER: + case SQL_ODBC_CURSORS: + case SQL_OPT_TRACE: + case SQL_OPT_TRACEFILE: + case SQL_TRANSLATE_DLL: + case SQL_TRANSLATE_OPTION: + len = 0; + break; + +#ifdef SQL_ATTR_CONNECTION_DEAD + case SQL_ATTR_CONNECTION_DEAD: +#else + case 1209: +#endif /* SQL_ATTR_CONNECTION_DEAD */ + len = sizeof(SQLUINTEGER); + break; + } } if (StringLength) *StringLength = len; -- 2.39.5