diff options
author | Lionel Elie Mamane <lionel@mamane.lu> | 2011-11-29 17:49:36 +0100 |
---|---|---|
committer | Lionel Elie Mamane <lionel@mamane.lu> | 2011-11-30 16:00:00 +0100 |
commit | 9a466d9718cceeb4ace9e3352a173c7b62387eee (patch) | |
tree | 83d1c58daca186935714690af5d1f7be85b53fae /connectivity | |
parent | ec894c5fb90bdee1c56d113d14b0bf524df9f5a9 (diff) |
ODBC: use right integer length to get Statement Options
Else (on 64bits platform) the driver smashes our stack: SQL_ULEN is 64 bits
Widen result type of getQueryTimeOut, getMaxFieldSize and getMaxRows so that it will always fit
Diffstat (limited to 'connectivity')
-rw-r--r-- | connectivity/source/drivers/odbcbase/OStatement.cxx | 19 | ||||
-rw-r--r-- | connectivity/source/inc/odbc/OStatement.hxx | 8 |
2 files changed, 14 insertions, 13 deletions
diff --git a/connectivity/source/drivers/odbcbase/OStatement.cxx b/connectivity/source/drivers/odbcbase/OStatement.cxx index 0c0a10a0d3df..1e8558cc21b6 100644 --- a/connectivity/source/drivers/odbcbase/OStatement.cxx +++ b/connectivity/source/drivers/odbcbase/OStatement.cxx @@ -446,11 +446,11 @@ Reference< XResultSet > OStatement_Base::getResultSet (sal_Bool checkCount) thro // Invoke SQLGetStmtOption with the given option. //-------------------------------------------------------------------- -sal_Int32 OStatement_Base::getStmtOption (short fOption) const +template < typename T, SQLINTEGER BufferLength > T OStatement_Base::getStmtOption (short fOption) const { - sal_Int32 result = 0; + T result = 0; OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!"); - N3SQLGetStmtAttr(m_aStatementHandle, fOption,&result,SQL_IS_INTEGER,NULL); + N3SQLGetStmtAttr(m_aStatementHandle, fOption, &result, BufferLength, NULL); return result; } // ------------------------------------------------------------------------- @@ -669,14 +669,15 @@ void SAL_CALL OStatement_Base::clearWarnings( ) throw(SQLException, RuntimeExce } // ------------------------------------------------------------------------- //------------------------------------------------------------------------------ -sal_Int32 OStatement_Base::getQueryTimeOut() const +sal_Int64 OStatement_Base::getQueryTimeOut() const { - return getStmtOption(SQL_ATTR_QUERY_TIMEOUT); + return getStmtOption<SQLULEN, SQL_IS_UINTEGER>(SQL_ATTR_QUERY_TIMEOUT); } //------------------------------------------------------------------------------ -sal_Int32 OStatement_Base::getMaxRows() const +sal_Int64 OStatement_Base::getMaxRows() const { - return getStmtOption(SQL_ATTR_MAX_ROWS); + // How do I say I want a SQLULEN?? + return getStmtOption<SQLULEN, SQL_IS_UINTEGER>(SQL_ATTR_MAX_ROWS); } //------------------------------------------------------------------------------ sal_Int32 OStatement_Base::getResultSetConcurrency() const @@ -745,9 +746,9 @@ sal_Int32 OStatement_Base::getFetchSize() const return nValue; } //------------------------------------------------------------------------------ -sal_Int32 OStatement_Base::getMaxFieldSize() const +sal_Int64 OStatement_Base::getMaxFieldSize() const { - return getStmtOption(SQL_ATTR_MAX_LENGTH); + return getStmtOption<SQLULEN, SQL_IS_UINTEGER>(SQL_ATTR_MAX_LENGTH); } //------------------------------------------------------------------------------ ::rtl::OUString OStatement_Base::getCursorName() const diff --git a/connectivity/source/inc/odbc/OStatement.hxx b/connectivity/source/inc/odbc/OStatement.hxx index 3532156e7d94..2ad1a42240d2 100644 --- a/connectivity/source/inc/odbc/OStatement.hxx +++ b/connectivity/source/inc/odbc/OStatement.hxx @@ -87,9 +87,9 @@ namespace connectivity protected: - sal_Int32 getQueryTimeOut() const; - sal_Int32 getMaxFieldSize() const; - sal_Int32 getMaxRows() const; + sal_Int64 getQueryTimeOut() const; + sal_Int64 getMaxFieldSize() const; + sal_Int64 getMaxRows() const; sal_Int32 getResultSetConcurrency() const; sal_Int32 getResultSetType() const; sal_Int32 getFetchDirection() const; @@ -97,7 +97,7 @@ namespace connectivity ::rtl::OUString getCursorName() const; sal_Bool isUsingBookmarks() const; sal_Bool getEscapeProcessing() const; - sal_Int32 getStmtOption (short fOption) const; + template < typename T, SQLINTEGER BufferLength > T getStmtOption (short fOption) const; void setQueryTimeOut(sal_Int32 _par0) ; void setMaxFieldSize(sal_Int32 _par0) ; |