diff options
author | Lukas Zeller <luz@plan44.ch> | 2010-12-15 15:44:25 +0100 |
---|---|---|
committer | Lukas Zeller <luz@synthesis.ch> | 2011-01-20 17:19:06 +0100 |
commit | fecc5f16d9943cf8310084dddcb87378a4abecc7 (patch) | |
tree | dadc6900690da2cf412cd0fbadd34dc58f958707 | |
parent | 525ab40fdc66a97e1da49d7756849da2b78b0db6 (diff) |
ODBC: adjusted for 64bit, especially using SQLLEN which is not same as SQLINTEGER in 64bit
-rw-r--r-- | src/DB_interfaces/odbc_db/odbcapiagent.cpp | 49 | ||||
-rwxr-xr-x | src/DB_interfaces/odbc_db/odbcapiagent.h | 6 | ||||
-rw-r--r-- | src/global_options.h | 4 |
3 files changed, 34 insertions, 25 deletions
diff --git a/src/DB_interfaces/odbc_db/odbcapiagent.cpp b/src/DB_interfaces/odbc_db/odbcapiagent.cpp index 310cd5a..21529c7 100644 --- a/src/DB_interfaces/odbc_db/odbcapiagent.cpp +++ b/src/DB_interfaces/odbc_db/odbcapiagent.cpp @@ -989,6 +989,10 @@ HSTMT TODBCApiAgent::getScriptStatement(void) #if !defined(NO_AV_GUARDING) // && !__option(microsoft_exceptions) +#ifndef _WIN32 + #error "AV Guarding is only for Win32" +#endif + // SEH-aware versions of ODBC calls (to avoid that crashing drivers blame our server) // ================================================================================== @@ -1211,7 +1215,7 @@ SQLRETURN SafeSQLGetData( SQLSMALLINT TargetType, SQLPOINTER TargetValuePtr, SQLINTEGER BufferLength, - SQLINTEGER * StrLen_or_IndPtr) + SQLLEN * StrLen_or_IndPtr) { __try { return SQLGetData(StatementHandle,ColumnNumber,TargetType,TargetValuePtr,BufferLength,StrLen_or_IndPtr); @@ -2820,15 +2824,6 @@ void TODBCApiAgent::bindSQLParameters( // if this is an out param, create a buffer of BufferLength if (pos->parammode!=param_buffer) { if (pos->outparam || copyvalue) { - // determine needed size of buffer - /* %%% no longer needed as we calculate buffer size above now - if (!pos->outparam || pos->BufferLength<pos->StrLen_or_Ind+1) { - // adjust col size - colSiz=pos->StrLen_or_Ind; - // adapt buffer size to actual length of input param - pos->BufferLength=colSiz+1; // set buffer size to what we need for input parameter - } - */ // create buffer void *bP = sysync_malloc(pos->BufferLength); pos->mybuffer=true; // this is now a buffer allocated by myself @@ -2846,19 +2841,33 @@ void TODBCApiAgent::bindSQLParameters( } // now actually bind to parameter POBJDEBUGPRINTFX(aSessionP,DBG_DBAPI+DBG_EXOTIC,( - "SQLBind: paramNo=%hd, in=%d, out=%d, parammode=%hd, valuetype=%hd, paramtype=%hd, lenorind=%ld, valptr=%lX, bufsiz=%ld, maxcol=%ld, colsiz=%ld", - paramNo, + "SQLBind: sizeof(SQLLEN)=%d, sizeof(SQLINTEGER)=%d, paramNo=%hd, in=%d, out=%d, parammode=%hd, valuetype=%hd, paramtype=%hd, lenorind=%d, valptr=%X, bufsiz=%d, maxcol=%d, colsiz=%d", + sizeof(SQLLEN), sizeof(SQLINTEGER), // to debug, as there can be problematic 32bit/64bit mismatches between these + (uInt16)paramNo, (int)pos->inparam, (int)pos->outparam, - (uInt16) (pos->outparam ? (pos->inparam ? SQL_PARAM_INPUT_OUTPUT : SQL_PARAM_OUTPUT ) : SQL_PARAM_INPUT), // type of param - valueType, - paramType, - pos->StrLen_or_Ind, + (uInt16)(pos->outparam ? (pos->inparam ? SQL_PARAM_INPUT_OUTPUT : SQL_PARAM_OUTPUT ) : SQL_PARAM_INPUT), // type of param + (uInt16)valueType, + (uInt16)paramType, + (int)pos->StrLen_or_Ind, pos->ParameterValuePtr, - pos->BufferLength, - pos->maxSize, - colSiz + (int)pos->BufferLength, + (int)pos->maxSize, + (int)colSiz )); + /* + SQLRETURN SQL_API SQLBindParameter( + SQLHSTMT hstmt, + SQLUSMALLINT ipar, + SQLSMALLINT fParamType, + SQLSMALLINT fCType, + SQLSMALLINT fSqlType, + SQLULEN cbColDef, + SQLSMALLINT ibScale, + SQLPOINTER rgbValue, + SQLLEN cbValueMax, + SQLLEN *pcbValue); + */ SQLRETURN res=SQLBindParameter( aStatement, paramNo, // parameter number @@ -2869,7 +2878,7 @@ void TODBCApiAgent::bindSQLParameters( 0, // decimal digits pos->ParameterValuePtr, // parameter value pos->BufferLength, // value buffer size (for output params) - (SQLLEN*)&(pos->StrLen_or_Ind) // length or indicator + &(pos->StrLen_or_Ind) // length or indicator ); checkStatementError(res,aStatement); // next param diff --git a/src/DB_interfaces/odbc_db/odbcapiagent.h b/src/DB_interfaces/odbc_db/odbcapiagent.h index 1794394..aa44aa3 100755 --- a/src/DB_interfaces/odbc_db/odbcapiagent.h +++ b/src/DB_interfaces/odbc_db/odbcapiagent.h @@ -95,8 +95,8 @@ typedef struct { bool mybuffer; #ifdef ODBCAPI_SUPPORT SQLPOINTER ParameterValuePtr; - SQLINTEGER BufferLength; - SQLINTEGER StrLen_or_Ind; + SQLLEN BufferLength; + SQLLEN StrLen_or_Ind; #elif defined(SQLITE_SUPPORT) appPointer ParameterValuePtr; memSize BufferLength; @@ -227,7 +227,7 @@ SQLRETURN SafeSQLGetData( SQLSMALLINT TargetType, SQLPOINTER TargetValuePtr, SQLINTEGER BufferLength, - SQLINTEGER * StrLen_or_IndPtr); + SQLLEN * StrLen_or_IndPtr); SQLRETURN SafeSQLCloseCursor( SQLHSTMT StatementHandle); diff --git a/src/global_options.h b/src/global_options.h index 85c56c1..4c45247 100644 --- a/src/global_options.h +++ b/src/global_options.h @@ -53,8 +53,8 @@ #endif // Real Release date (shown in some texts) #if !defined(REAL_RELEASE_YEAR) - #define REAL_RELEASE_YEAR 2010 - #define REAL_RELEASE_YEAR_TXT "2010" + #define REAL_RELEASE_YEAR 2011 + #define REAL_RELEASE_YEAR_TXT "2011" #endif |