comphelper/inc/comphelper/types.hxx | 1 comphelper/source/misc/types.cxx | 8 + connectivity/source/drivers/odbcbase/OPreparedStatement.cxx | 77 ------------ connectivity/source/drivers/odbcbase/OStatement.cxx | 18 +- connectivity/source/drivers/odbcbase/OTools.cxx | 11 + connectivity/source/inc/odbc/OPreparedStatement.hxx | 4 connectivity/source/inc/odbc/OStatement.hxx | 6 connectivity/source/inc/odbc/OTools.hxx | 20 +-- 8 files changed, 41 insertions(+), 104 deletions(-)
New commits: commit c8d91a8f2f6780cd187c65660ebf18e5eea568bc Author: Kate Goss <katherine.g...@gmail.com> Date: Mon Feb 13 21:53:08 2012 +0000 Remove unused code from connectivity::odbc::OPreparedStatement Remove methods getDataBuf(int), getParamLength(int), getPrecision(int). diff --git a/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx b/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx index 63401f5..d1288f9 100644 --- a/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx +++ b/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx @@ -674,27 +674,6 @@ sal_Int8* OPreparedStatement::allocBindBuf( sal_Int32 index,sal_Int32 bufLen) // ------------------------------------------------------------------------- //-------------------------------------------------------------------- -// getDataBuf -// Gets the data buffer for the given parameter index -//-------------------------------------------------------------------- - -sal_Int8* OPreparedStatement::getDataBuf (sal_Int32 index) -{ - sal_Int8* b = NULL; - - // Sanity check the parameter number - - if ((index >= 1) && - (index <= numParams)) - { - b = boundParams[index - 1].getBindDataBuffer (); - } - - return b; -} -// ------------------------------------------------------------------------- - -//-------------------------------------------------------------------- // getLengthBuf // Gets the length buffer for the given parameter index //-------------------------------------------------------------------- @@ -716,34 +695,6 @@ sal_Int8* OPreparedStatement::getLengthBuf (sal_Int32 index) // ------------------------------------------------------------------------- //-------------------------------------------------------------------- -// getParamLength -// Returns the length of the given parameter number. When each -// parameter was bound, a 4-sal_Int8 buffer was given to hold the -// length (stored in native format). Get the buffer, convert the -// buffer from native format, and return it. If the length is -1, -// the column is considered to be NULL. -//-------------------------------------------------------------------- - -sal_Int32 OPreparedStatement::getParamLength ( sal_Int32 index) -{ - sal_Int32 paramLen = SQL_NULL_DATA; - - // Sanity check the parameter number - - if ((index >= 1) && - (index <= numParams)) { - - // Now get the length of the parameter from the - // bound param array. -1 is returned if it is NULL. - long n = 0; - memcpy (&n, boundParams[index -1].getBindLengthBuffer (), sizeof (n)); - paramLen = n; - } - return paramLen; -} -// ------------------------------------------------------------------------- - -//-------------------------------------------------------------------- // putParamData // Puts parameter data from a previously bound input stream. The // input stream was bound using SQL_LEN_DATA_AT_EXEC. @@ -810,34 +761,6 @@ void OPreparedStatement::putParamData (sal_Int32 index) throw(SQLException) } } // ------------------------------------------------------------------------- -//-------------------------------------------------------------------- -// getPrecision -// Given a SQL type, return the maximum precision for the column. -// Returns -1 if not known -//-------------------------------------------------------------------- - -sal_Int32 OPreparedStatement::getPrecision ( sal_Int32 sqlType) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OStatement_BASE::rBHelper.bDisposed); - - sal_Int32 prec = -1; - const TTypeInfoVector& rTypeInfo = m_pConnection->getTypeInfo(); - if ( !rTypeInfo.empty() ) - { - m_pConnection->buildTypeInfo(); - } - - if ( !rTypeInfo.empty() ) - { - OTypeInfo aInfo; - aInfo.nType = (sal_Int16)sqlType; - TTypeInfoVector::const_iterator aIter = ::std::find(rTypeInfo.begin(),rTypeInfo.end(),aInfo); - if(aIter != rTypeInfo.end()) - prec = (*aIter).nPrecision; - } - return prec; -} //-------------------------------------------------------------------- // setStream diff --git a/connectivity/source/inc/odbc/OPreparedStatement.hxx b/connectivity/source/inc/odbc/OPreparedStatement.hxx index 8c41355..076c9e0 100644 --- a/connectivity/source/inc/odbc/OPreparedStatement.hxx +++ b/connectivity/source/inc/odbc/OPreparedStatement.hxx @@ -88,15 +88,11 @@ namespace connectivity void putParamData (sal_Int32 index) throw(::com::sun::star::sdbc::SQLException); void setStream (sal_Int32 ParameterIndex,const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream>& x, SQLLEN length,sal_Int32 SQLtype) throw(::com::sun::star::sdbc::SQLException); - sal_Int32 getParamLength ( sal_Int32 index); sal_Int8* getLengthBuf (sal_Int32 index); - sal_Int8* getDataBuf (sal_Int32 index); sal_Int8* allocBindBuf ( sal_Int32 index, sal_Int32 bufLen); void initBoundParam () throw(::com::sun::star::sdbc::SQLException); void setParameter(sal_Int32 parameterIndex,sal_Int32 _nType,sal_Int32 _nSize,void* _pData); - sal_Int32 getPrecision ( sal_Int32 sqlType); - sal_Bool isPrepared() const { return m_bPrepared;} void prepareStatement(); void checkParameterIndex(sal_Int32 _parameterIndex); commit cdb2d21c550d18c5565a4ade7aeca4594a836f94 Author: Lionel Elie Mamane <lio...@mamane.lu> Date: Tue Feb 14 19:41:08 2012 +0100 ODBC: align *all* the handling of SQLULEN properties with maximal ODBC size diff --git a/connectivity/source/drivers/odbcbase/OStatement.cxx b/connectivity/source/drivers/odbcbase/OStatement.cxx index 6355217..5c64c26 100644 --- a/connectivity/source/drivers/odbcbase/OStatement.cxx +++ b/connectivity/source/drivers/odbcbase/OStatement.cxx @@ -756,13 +756,13 @@ sal_Int64 OStatement_Base::getMaxFieldSize() const return ::rtl::OUString::createFromAscii((const char*)pName); } //------------------------------------------------------------------------------ -void OStatement_Base::setQueryTimeOut(sal_Int32 seconds) +void OStatement_Base::setQueryTimeOut(sal_Int64 seconds) { OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!"); setStmtOption<SQLULEN, SQL_IS_UINTEGER>(SQL_ATTR_QUERY_TIMEOUT,seconds); } //------------------------------------------------------------------------------ -void OStatement_Base::setMaxRows(sal_Int32 _par0) +void OStatement_Base::setMaxRows(sal_Int64 _par0) { OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!"); setStmtOption<SQLULEN, SQL_IS_UINTEGER>(SQL_ATTR_MAX_ROWS, _par0); @@ -872,7 +872,7 @@ void OStatement_Base::setFetchSize(sal_Int32 _par0) } } //------------------------------------------------------------------------------ -void OStatement_Base::setMaxFieldSize(sal_Int32 _par0) +void OStatement_Base::setMaxFieldSize(sal_Int64 _par0) { OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!"); setStmtOption<SQLULEN, SQL_IS_UINTEGER>(SQL_ATTR_MAX_LENGTH, _par0); @@ -913,9 +913,9 @@ void OStatement_Base::setUsingBookmarks(sal_Bool _bUseBookmark) DECL_BOOL_PROP0(ESCAPEPROCESSING); DECL_PROP0(FETCHDIRECTION,sal_Int32); DECL_PROP0(FETCHSIZE, sal_Int32); - DECL_PROP0(MAXFIELDSIZE,sal_Int32); - DECL_PROP0(MAXROWS, sal_Int32); - DECL_PROP0(QUERYTIMEOUT,sal_Int32); + DECL_PROP0(MAXFIELDSIZE,sal_Int64); + DECL_PROP0(MAXROWS, sal_Int64); + DECL_PROP0(QUERYTIMEOUT,sal_Int64); DECL_PROP0(RESULTSETCONCURRENCY,sal_Int32); DECL_PROP0(RESULTSETTYPE,sal_Int32); DECL_BOOL_PROP0(USEBOOKMARKS); @@ -997,13 +997,13 @@ void OStatement_Base::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const A switch(nHandle) { case PROPERTY_ID_QUERYTIMEOUT: - setQueryTimeOut(comphelper::getINT32(rValue)); + setQueryTimeOut(comphelper::getINT64(rValue)); break; case PROPERTY_ID_MAXFIELDSIZE: - setMaxFieldSize(comphelper::getINT32(rValue)); + setMaxFieldSize(comphelper::getINT64(rValue)); break; case PROPERTY_ID_MAXROWS: - setMaxRows(comphelper::getINT32(rValue)); + setMaxRows(comphelper::getINT64(rValue)); break; case PROPERTY_ID_CURSORNAME: setCursorName(comphelper::getString(rValue)); diff --git a/connectivity/source/inc/odbc/OStatement.hxx b/connectivity/source/inc/odbc/OStatement.hxx index e0d4663..4768f70 100644 --- a/connectivity/source/inc/odbc/OStatement.hxx +++ b/connectivity/source/inc/odbc/OStatement.hxx @@ -99,9 +99,9 @@ namespace connectivity sal_Bool getEscapeProcessing() const; template < typename T, SQLINTEGER BufferLength > T getStmtOption (SQLINTEGER fOption, T dflt = 0) const; - void setQueryTimeOut(sal_Int32 _par0) ; - void setMaxFieldSize(sal_Int32 _par0) ; - void setMaxRows(sal_Int32 _par0) ; + void setQueryTimeOut(sal_Int64 _par0) ; + void setMaxFieldSize(sal_Int64 _par0) ; + void setMaxRows(sal_Int64 _par0) ; void setFetchDirection(sal_Int32 _par0) ; void setFetchSize(sal_Int32 _par0) ; void setCursorName(const ::rtl::OUString &_par0); commit 034b130b90af330caab0b9fe7f19db45b5232eea Author: Lionel Elie Mamane <lio...@mamane.lu> Date: Tue Feb 14 19:39:01 2012 +0100 comphelper: add getINT64 diff --git a/comphelper/inc/comphelper/types.hxx b/comphelper/inc/comphelper/types.hxx index dfa1565..a23116f 100644 --- a/comphelper/inc/comphelper/types.hxx +++ b/comphelper/inc/comphelper/types.hxx @@ -156,6 +156,7 @@ namespace comphelper // no, we don't use templates here. This would lead to a lot of implicit uses of the conversion methods, // which would be difficult to trace ... + COMPHELPER_DLLPUBLIC sal_Int64 getINT64(const staruno::Any& _rAny); COMPHELPER_DLLPUBLIC sal_Int32 getINT32(const staruno::Any& _rAny); COMPHELPER_DLLPUBLIC sal_Int16 getINT16(const staruno::Any& _rAny); COMPHELPER_DLLPUBLIC double getDouble(const staruno::Any& _rAny); diff --git a/comphelper/source/misc/types.cxx b/comphelper/source/misc/types.cxx index f3df258..c9eb6bb 100644 --- a/comphelper/source/misc/types.cxx +++ b/comphelper/source/misc/types.cxx @@ -80,6 +80,14 @@ sal_Bool operator ==(const Time& _rLeft, const Time& _rRight) } //------------------------------------------------------------------------------ +sal_Int64 getINT64(const Any& _rAny) +{ + sal_Int64 nReturn = 0; + OSL_VERIFY( _rAny >>= nReturn ); + return nReturn; +} + +//------------------------------------------------------------------------------ sal_Int32 getINT32(const Any& _rAny) { sal_Int32 nReturn = 0; commit c1ef5ba65c1b3d9c9bb8c45f68e494493e628837 Author: Lionel Elie Mamane <lio...@mamane.lu> Date: Tue Feb 14 18:34:52 2012 +0100 improve OTools::binParameter/bindData interaction Don't duplicate the decision point for "data at execution or copied data" diff --git a/connectivity/source/drivers/odbcbase/OTools.cxx b/connectivity/source/drivers/odbcbase/OTools.cxx index 9e8714c..df74076 100644 --- a/connectivity/source/drivers/odbcbase/OTools.cxx +++ b/connectivity/source/drivers/odbcbase/OTools.cxx @@ -181,14 +181,15 @@ void OTools::bindParameter( OConnection* _pConnection, SQLLEN* pLen = (SQLLEN*)pLenBuffer; SQLULEN nColumnSize=0; SQLSMALLINT nDecimalDigits=0; + bool atExec; OTools::getBindTypes(_bUseWChar,_bUseOldTimeDate,_nODBCtype,fCType,fSqlType); - OTools::bindData(_nODBCtype,_bUseWChar,pDataBuffer,pLen,_pValue,_nTextEncoding,nColumnSize); + OTools::bindData(_nODBCtype,_bUseWChar,pDataBuffer,pLen,_pValue,_nTextEncoding,nColumnSize, atExec); if ((nColumnSize == 0) && (fSqlType == SQL_CHAR || fSqlType == SQL_VARCHAR || fSqlType == SQL_LONGVARCHAR)) nColumnSize = 1; - if(fSqlType == SQL_LONGVARCHAR || fSqlType == SQL_LONGVARBINARY) + if (atExec) memcpy(pDataBuffer,&nPos,sizeof(nPos)); nRetcode = (*(T3SQLBindParameter)_pConnection->getOdbcFunction(ODBC3SQLBindParameter))(_hStmt, @@ -211,10 +212,12 @@ void OTools::bindData( SQLSMALLINT _nOdbcType, SQLLEN*& pLen, const void* _pValue, rtl_TextEncoding _nTextEncoding, - SQLULEN& _nColumnSize) + SQLULEN& _nColumnSize, + bool &atExec) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "ocke.jans...@sun.com", "OTools::bindData" ); _nColumnSize = 0; + atExec = false; switch (_nOdbcType) { @@ -307,6 +310,7 @@ void OTools::bindData( SQLSMALLINT _nOdbcType, nLen = ((const ::com::sun::star::uno::Sequence< sal_Int8 > *)_pValue)->getLength(); *pLen = (SQLLEN)SQL_LEN_DATA_AT_EXEC(nLen); } + atExec = true; break; case SQL_LONGVARCHAR: { @@ -319,6 +323,7 @@ void OTools::bindData( SQLSMALLINT _nOdbcType, nLen = aString.getLength(); } *pLen = (SQLLEN)SQL_LEN_DATA_AT_EXEC(nLen); + atExec = true; } break; case SQL_DATE: *(DATE_STRUCT*)_pData = *(DATE_STRUCT*)_pValue; diff --git a/connectivity/source/inc/odbc/OTools.hxx b/connectivity/source/inc/odbc/OTools.hxx index 7f48373..ad1fb12 100644 --- a/connectivity/source/inc/odbc/OTools.hxx +++ b/connectivity/source/inc/odbc/OTools.hxx @@ -216,13 +216,16 @@ namespace connectivity SQLLEN _nSize) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); /** - bindData copies the from pValue to pData - @param _nOdbcType the ODBC sql type - @param _bUseWChar true when Unicode should be used - @param _pData contains a copy of the data to be set - @param _pValue contains the data to be copied - @param _nTextEncoding the text encoding - @param _nColumnSize the columnsize which is a out param + bindData copies data from pValue to pData + @param _nOdbcType [in] the ODBC sql type + @param _bUseWChar [in] true when Unicode should be used + @param _pData [in/out] data copy destination + @param pLen [out] buffer length of data written to _pData + @param _pValue [in] contains the data to be copied + @param _nTextEncoding [in] the text encoding + @param _nColumnSize [out] columnSize of data written to _pData + @param atExec [out] data was not copied, but setup for data-at-execution; + caller is responsible for writing a token in _pData */ static void bindData( SQLSMALLINT _nOdbcType, sal_Bool _bUseWChar, @@ -230,7 +233,8 @@ namespace connectivity SQLLEN*& pLen, const void* _pValue, rtl_TextEncoding _nTextEncoding, - SQLULEN& _nColumnSize); + SQLULEN& _nColumnSize, + bool &atExec); static void bindParameter( OConnection* _pConnection, SQLHANDLE _hStmt, _______________________________________________ Libreoffice-commits mailing list Libreoffice-commits@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits