Kaydet (Commit) 9a466d97 authored tarafından Lionel Elie Mamane's avatar Lionel Elie Mamane

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
üst ec894c5f
...@@ -446,11 +446,11 @@ Reference< XResultSet > OStatement_Base::getResultSet (sal_Bool checkCount) thro ...@@ -446,11 +446,11 @@ Reference< XResultSet > OStatement_Base::getResultSet (sal_Bool checkCount) thro
// Invoke SQLGetStmtOption with the given option. // 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!"); 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; return result;
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
...@@ -669,14 +669,15 @@ void SAL_CALL OStatement_Base::clearWarnings( ) throw(SQLException, RuntimeExce ...@@ -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 sal_Int32 OStatement_Base::getResultSetConcurrency() const
...@@ -745,9 +746,9 @@ sal_Int32 OStatement_Base::getFetchSize() const ...@@ -745,9 +746,9 @@ sal_Int32 OStatement_Base::getFetchSize() const
return nValue; 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 ::rtl::OUString OStatement_Base::getCursorName() const
......
...@@ -87,9 +87,9 @@ namespace connectivity ...@@ -87,9 +87,9 @@ namespace connectivity
protected: protected:
sal_Int32 getQueryTimeOut() const; sal_Int64 getQueryTimeOut() const;
sal_Int32 getMaxFieldSize() const; sal_Int64 getMaxFieldSize() const;
sal_Int32 getMaxRows() const; sal_Int64 getMaxRows() const;
sal_Int32 getResultSetConcurrency() const; sal_Int32 getResultSetConcurrency() const;
sal_Int32 getResultSetType() const; sal_Int32 getResultSetType() const;
sal_Int32 getFetchDirection() const; sal_Int32 getFetchDirection() const;
...@@ -97,7 +97,7 @@ namespace connectivity ...@@ -97,7 +97,7 @@ namespace connectivity
::rtl::OUString getCursorName() const; ::rtl::OUString getCursorName() const;
sal_Bool isUsingBookmarks() const; sal_Bool isUsingBookmarks() const;
sal_Bool getEscapeProcessing() 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 setQueryTimeOut(sal_Int32 _par0) ;
void setMaxFieldSize(sal_Int32 _par0) ; void setMaxFieldSize(sal_Int32 _par0) ;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment