Commits

Anonymous committed 75de8e7

#i10000#: merge conflicts resolved (CWS sb102); resurrect performance improvements from m38

Comments (0)

Files changed (3)

connectivity/source/drivers/odbcbase/OResultSet.cxx

 #include "connectivity/dbtools.hxx"
 #include "connectivity/dbexception.hxx"
 #include "diagnose_ex.h"
+#include <rtl/logfile.hxx>
 
 using namespace ::comphelper;
 using namespace connectivity;
 using namespace com::sun::star::io;
 using namespace com::sun::star::util;
 
+#define ODBC_SQL_NOT_DEFINED    99UL
+
 //------------------------------------------------------------------------------
 //	IMPLEMENT_SERVICE_INFO(OResultSet,"com.sun.star.sdbcx.OResultSet","com.sun.star.sdbc.ResultSet");
 ::rtl::OUString SAL_CALL OResultSet::getImplementationName(  ) throw ( RuntimeException)
                         ,m_nTextEncoding(pStmt->getOwnConnection()->getTextEncoding())
 						,m_nRowPos(0)
                         ,m_nLastColumnPos(0)
+                        ,m_nUseBookmarks(ODBC_SQL_NOT_DEFINED)
                         ,m_nCurrentFetchState(0)
                         ,m_bWasNull(sal_True)
                         ,m_bEOF(sal_True)
 	m_xStatement	= NULL;
 	m_xMetaData		= NULL;
 }
-// -----------------------------------------------------------------------------
-sal_Int32 OResultSet::mapColumn (sal_Int32	column)
-{
-	sal_Int32	map = column;
-
-	if (!m_aColMapping.empty())
-	{
-		// Validate column number
-		OSL_ENSURE(column>0,"OResultSet::mapColumn column <= 0");
-		map = m_aColMapping[column];
-	}
-
-	return map;
-}
 // -------------------------------------------------------------------------
 SQLRETURN OResultSet::unbind(sal_Bool _bUnbindHandle)
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::unbind" );
 	SQLRETURN nRet = 0;
 	if ( _bUnbindHandle )
 		nRet = N3SQLFreeStmt(m_aStatementHandle,SQL_UNBIND);
 // -------------------------------------------------------------------------
 TVoidPtr OResultSet::allocBindColumn(sal_Int32 _nType,sal_Int32 _nColumnIndex)
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::allocBindColumn" );
 	TVoidPtr aPair;
 	switch (_nType)
 	{
 // -------------------------------------------------------------------------
 void OResultSet::allocBuffer()
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::allocBuffer" );
 	Reference< XResultSetMetaData > xMeta = getMetaData();
 	sal_Int32 nLen = xMeta->getColumnCount();
 
 // -------------------------------------------------------------------------
 void OResultSet::releaseBuffer()
 {	
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::releaseBuffer" );
 	unbind(sal_False);
 	m_aLengthVector.clear();
 }
 
 sal_Int32 SAL_CALL OResultSet::findColumn( const ::rtl::OUString& columnName ) throw(SQLException, RuntimeException)
 {
-
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::findColumn" );
 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
 
 	return i;
 }
 // -------------------------------------------------------------------------
-Reference< XInputStream > SAL_CALL OResultSet::getBinaryStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+Reference< XInputStream > SAL_CALL OResultSet::getBinaryStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
 {
 	::osl::MutexGuard aGuard( m_aMutex );
 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
 
-	columnIndex = mapColumn(columnIndex);
 	// TODO use getBytes instead of
 	return NULL;
 }
 // -------------------------------------------------------------------------
-Reference< XInputStream > SAL_CALL OResultSet::getCharacterStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+Reference< XInputStream > SAL_CALL OResultSet::getCharacterStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
 {
 	::osl::MutexGuard aGuard( m_aMutex );
 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
 
-	columnIndex = mapColumn(columnIndex);
 	// TODO use getBytes instead of
 	return NULL;
 }
 // -----------------------------------------------------------------------------
 const ORowSetValue& OResultSet::getValue(sal_Int32 _nColumnIndex,SQLSMALLINT _nType,void* _pValue,SQLINTEGER _rSize)
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::getValue" );
 	::osl::MutexGuard aGuard( m_aMutex );
 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
-
-	_nColumnIndex = mapColumn(_nColumnIndex);
-
 	if(m_bFetchData)
 	{
 		if(_nColumnIndex > m_nLastColumnPos)
 
 Sequence< sal_Int8 > SAL_CALL OResultSet::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::getBytes" );
 
 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 	::osl::MutexGuard aGuard( m_aMutex );
 
 
-	columnIndex = mapColumn(columnIndex);
 	if(m_bFetchData)
 	{
 		if(columnIndex > m_nLastColumnPos)
 		return nRet;
 	}
 
-    SWORD nType = OResultSetMetaData::getColumnODBCType(m_pStatement->getOwnConnection(),m_aStatementHandle,*this,columnIndex);
-	switch(nType)
+    ::std::map<sal_Int32,SWORD>::iterator aFind = m_aODBCColumnTypes.find(columnIndex);
+    if ( aFind == m_aODBCColumnTypes.end() )
+        aFind = m_aODBCColumnTypes.insert(::std::map<sal_Int32,SWORD>::value_type(columnIndex,OResultSetMetaData::getColumnODBCType(m_pStatement->getOwnConnection(),m_aStatementHandle,*this,columnIndex))).first;
+
+	switch(aFind->second)
 	{
 		case SQL_WVARCHAR:
         case SQL_WCHAR:
         case SQL_CHAR:
         case SQL_LONGVARCHAR:
 		{
-			::rtl::OUString aRet = OTools::getStringValue(m_pStatement->getOwnConnection(),m_aStatementHandle,columnIndex,nType,m_bWasNull,**this,m_nTextEncoding);
+			::rtl::OUString aRet = OTools::getStringValue(m_pStatement->getOwnConnection(),m_aStatementHandle,columnIndex,aFind->second,m_bWasNull,**this,m_nTextEncoding);
 			return Sequence<sal_Int8>(reinterpret_cast<const sal_Int8*>(aRet.getStr()),sizeof(sal_Unicode)*aRet.getLength());
 		}
         default:
 
 Date SAL_CALL OResultSet::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::getDate" );
 	DATE_STRUCT aDate;
 	aDate.day	= 0;
 	aDate.month = 0;
 
 Reference< XResultSetMetaData > SAL_CALL OResultSet::getMetaData(  ) throw(SQLException, RuntimeException)
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::getMetaData" );
 	::osl::MutexGuard aGuard( m_aMutex );
 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
 
 Any SAL_CALL OResultSet::getObject( sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException)
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::getObject" );
 	::osl::MutexGuard aGuard( m_aMutex );
 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
-	columnIndex = mapColumn(columnIndex);
 	fillRow(columnIndex);
 	return m_aRow[columnIndex].makeAny();
 }
 
 ::rtl::OUString SAL_CALL OResultSet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::getString" );
 	::osl::MutexGuard aGuard( m_aMutex );
-	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
-
-
-	columnIndex = mapColumn(columnIndex);
+	
 	::rtl::OUString nRet;
-	if(m_bFetchData)
+	if ( m_bFetchData )
 		nRet = getValue(columnIndex,0,NULL,0);
 	else
     {
-		nRet = OTools::getStringValue(m_pStatement->getOwnConnection(),m_aStatementHandle,columnIndex,OResultSetMetaData::getColumnODBCType(m_pStatement->getOwnConnection(),m_aStatementHandle,*this,columnIndex),m_bWasNull,**this,m_nTextEncoding);
+        checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+        ::std::map<sal_Int32,SWORD>::iterator aFind = m_aODBCColumnTypes.find(columnIndex);
+        if ( aFind == m_aODBCColumnTypes.end() )
+            aFind = m_aODBCColumnTypes.insert(::std::map<sal_Int32,SWORD>::value_type(columnIndex,OResultSetMetaData::getColumnODBCType(m_pStatement->getOwnConnection(),m_aStatementHandle,*this,columnIndex))).first;
+		nRet = OTools::getStringValue(m_pStatement->getOwnConnection(),m_aStatementHandle,columnIndex,aFind->second,m_bWasNull,**this,m_nTextEncoding);
     }
 	return nRet;
 }
 
 Time SAL_CALL OResultSet::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::getTime" );
 	TIME_STRUCT aTime={0,0,0};
 	const ORowSetValue& aValue = getValue(columnIndex,
 		m_pStatement->getOwnConnection()->useOldDateFormat() ? SQL_C_TIME : SQL_C_TYPE_TIME,
 
 DateTime SAL_CALL OResultSet::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::getTimestamp" );
 	TIMESTAMP_STRUCT aTime={0,0,0,0,0,0,0};
 	const ORowSetValue& aValue = getValue(columnIndex,
 		m_pStatement->getOwnConnection()->useOldDateFormat() ? SQL_C_TIMESTAMP : SQL_C_TYPE_TIMESTAMP,
 // -------------------------------------------------------------------------
 void SAL_CALL OResultSet::beforeFirst(  ) throw(SQLException, RuntimeException)
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::beforeFirst" );
 	::osl::MutexGuard aGuard( m_aMutex );
 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
 // -------------------------------------------------------------------------
 void SAL_CALL OResultSet::afterLast(  ) throw(SQLException, RuntimeException)
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::afterLast" );
 	::osl::MutexGuard aGuard( m_aMutex );
 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
 
 sal_Bool SAL_CALL OResultSet::first(  ) throw(SQLException, RuntimeException)
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::first" );
 	return moveImpl(IResultSetHelper::FIRST,0,sal_True);
 }
 // -------------------------------------------------------------------------
 
 sal_Bool SAL_CALL OResultSet::last(  ) throw(SQLException, RuntimeException)
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::last" );
 	return moveImpl(IResultSetHelper::LAST,0,sal_True);
 }
 // -------------------------------------------------------------------------
 sal_Bool SAL_CALL OResultSet::absolute( sal_Int32 row ) throw(SQLException, RuntimeException)
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::absolute" );
 	return moveImpl(IResultSetHelper::ABSOLUTE,row,sal_True);
 }
 // -------------------------------------------------------------------------
 sal_Bool SAL_CALL OResultSet::relative( sal_Int32 row ) throw(SQLException, RuntimeException)
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::relative" );
 	return moveImpl(IResultSetHelper::RELATIVE,row,sal_True);
 }
 // -------------------------------------------------------------------------
 sal_Bool SAL_CALL OResultSet::previous(  ) throw(SQLException, RuntimeException)
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::previous" );
 	return moveImpl(IResultSetHelper::PRIOR,0,sal_True);
 }
 // -------------------------------------------------------------------------
 
 sal_Bool SAL_CALL OResultSet::rowDeleted() throw(SQLException, RuntimeException)
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::rowDeleted" );
 	::osl::MutexGuard aGuard( m_aMutex );
 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
 // -------------------------------------------------------------------------
 sal_Bool SAL_CALL OResultSet::rowInserted(  ) throw(SQLException, RuntimeException)
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::rowInserted" );
 	::osl::MutexGuard aGuard( m_aMutex );
 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
 // -------------------------------------------------------------------------
 sal_Bool SAL_CALL OResultSet::rowUpdated(  ) throw(SQLException, RuntimeException)
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::rowUpdated" );
 	::osl::MutexGuard aGuard( m_aMutex );
 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
 
 sal_Bool SAL_CALL OResultSet::next(  ) throw(SQLException, RuntimeException)
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::next" );
 	return moveImpl(IResultSetHelper::NEXT,1,sal_True);
 }
 // -------------------------------------------------------------------------
 
 sal_Bool SAL_CALL OResultSet::wasNull(  ) throw(SQLException, RuntimeException)
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::wasNull" );
 	::osl::MutexGuard aGuard( m_aMutex );
 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
 // -------------------------------------------------------------------------
 void SAL_CALL OResultSet::insertRow(  ) throw(SQLException, RuntimeException)
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::insertRow" );
 	::osl::MutexGuard aGuard( m_aMutex );
 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
 // -------------------------------------------------------------------------
 void SAL_CALL OResultSet::updateRow(  ) throw(SQLException, RuntimeException)
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::updateRow" );
 	::osl::MutexGuard aGuard( m_aMutex );
 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
 // -------------------------------------------------------------------------
 void SAL_CALL OResultSet::deleteRow(  ) throw(SQLException, RuntimeException)
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::deleteRow" );
 	SQLRETURN nRet = SQL_SUCCESS;
 	sal_Int32 nPos = getDriverPos();
 	nRet = N3SQLSetPos(m_aStatementHandle,1,SQL_DELETE,SQL_LOCK_NO_CHANGE);
 
 void SAL_CALL OResultSet::moveToInsertRow(  ) throw(SQLException, RuntimeException)
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::moveToInsertRow" );
 	::osl::MutexGuard aGuard( m_aMutex );
 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
 // -------------------------------------------------------------------------
 void OResultSet::updateValue(sal_Int32 columnIndex,SQLSMALLINT _nType,void* _pValue) throw(SQLException, RuntimeException)
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::updateValue" );
 	::osl::MutexGuard aGuard( m_aMutex );
 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
-	columnIndex = mapColumn(columnIndex);
 	m_aBindVector.push_back(allocBindColumn(OTools::MapOdbcType2Jdbc(_nType),columnIndex));
 	void* pData = reinterpret_cast<void*>(m_aBindVector.rbegin()->first);
 	OSL_ENSURE(pData != NULL,"Data for update is NULL!");
 	::osl::MutexGuard aGuard( m_aMutex );
 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
-
-	columnIndex = mapColumn(columnIndex);
 	m_aBindVector.push_back(allocBindColumn(DataType::CHAR,columnIndex));
 	void* pData = reinterpret_cast<void*>(m_aBindVector.rbegin()->first);
 	OTools::bindValue(m_pStatement->getOwnConnection(),m_aStatementHandle,columnIndex,SQL_CHAR,0,(sal_Int8*)NULL,pData,&m_aLengthVector[columnIndex],**this,m_nTextEncoding,m_pStatement->getOwnConnection()->useOldDateFormat());
 // -------------------------------------------------------------------------
 void SAL_CALL OResultSet::refreshRow(  ) throw(SQLException, RuntimeException)
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::refreshRow" );
 	::osl::MutexGuard aGuard( m_aMutex );
 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
 // XRowLocate
 Any SAL_CALL OResultSet::getBookmark(  ) throw( SQLException,  RuntimeException)
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::getBookmark" );
 	 ::osl::MutexGuard aGuard( m_aMutex );
 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
 
 	if ( aFind == m_aPosToBookmarks.end() )
 	{
-		sal_uInt32 nValue = SQL_UB_OFF;
-		SQLRETURN nRet = N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_USE_BOOKMARKS,&nValue,SQL_IS_UINTEGER,NULL);
-        OSL_UNUSED( nRet );
-		if(nValue == SQL_UB_OFF)
+        if ( m_nUseBookmarks == ODBC_SQL_NOT_DEFINED )
+        {
+            RTL_LOGFILE_CONTEXT_TRACE( aLogger, "SQLGetStmtAttr" );
+            m_nUseBookmarks = SQL_UB_OFF;
+		    SQLRETURN nRet = N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_USE_BOOKMARKS,&m_nUseBookmarks,SQL_IS_UINTEGER,NULL);
+            OSL_UNUSED( nRet );
+        }
+		if(m_nUseBookmarks == SQL_UB_OFF)
 			throw SQLException();
 
 		m_aBookmark = OTools::getBytesValue(m_pStatement->getOwnConnection(),m_aStatementHandle,0,SQL_C_VARBOOKMARK,m_bWasNull,**this);
 // -------------------------------------------------------------------------
 sal_Bool SAL_CALL OResultSet::moveToBookmark( const  Any& bookmark ) throw( SQLException,  RuntimeException)
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::moveToBookmark" );
 	::osl::MutexGuard aGuard( m_aMutex );
 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
 // -------------------------------------------------------------------------
 sal_Bool SAL_CALL OResultSet::moveRelativeToBookmark( const  Any& bookmark, sal_Int32 rows ) throw( SQLException,  RuntimeException)
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::moveRelativeToBookmark" );
 	::osl::MutexGuard aGuard( m_aMutex );
 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
 // -------------------------------------------------------------------------
 sal_Int32 SAL_CALL OResultSet::compareBookmarks( const Any& lhs, const  Any& rhs ) throw( SQLException,  RuntimeException)
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::compareBookmarks" );
 	::osl::MutexGuard aGuard( m_aMutex );
 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
 	{
 		return sal_False;
 	}
-	sal_uInt32 nUseBookmark = SQL_UB_OFF;
-	N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_USE_BOOKMARKS,&nUseBookmark,SQL_IS_UINTEGER,NULL);
+    
+    if ( m_nUseBookmarks == ODBC_SQL_NOT_DEFINED )
+    {
+        m_nUseBookmarks = SQL_UB_OFF;
+	    SQLRETURN nRet = N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_USE_BOOKMARKS,&m_nUseBookmarks,SQL_IS_UINTEGER,NULL);
+        OSL_UNUSED( nRet );
+    }
 
-	return (nUseBookmark != SQL_UB_OFF) && (nAttr & SQL_CA1_BOOKMARK) == SQL_CA1_BOOKMARK;
+	return (m_nUseBookmarks != SQL_UB_OFF) && (nAttr & SQL_CA1_BOOKMARK) == SQL_CA1_BOOKMARK;
 }
 //------------------------------------------------------------------------------
 void OResultSet::setFetchDirection(sal_Int32 _par0)
 // -------------------------------------------------------------------------
 void OResultSet::fillRow(sal_Int32 _nToColumn)
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::fillRow" );
 	if((sal_Int32)m_aRow.size() <= _nToColumn)
 	{
 		m_aRow.resize(_nToColumn+1);
 		{
 			case DataType::CHAR:
 			case DataType::VARCHAR:
-				*pColumn = getString(nColumn);
-				break;
-			case DataType::DECIMAL:
+            case DataType::DECIMAL:
 			case DataType::NUMERIC:
-				*pColumn = getString(nColumn);
+            case DataType::LONGVARCHAR:
+                {
+                    ::std::map<sal_Int32,SWORD>::iterator aFind = m_aODBCColumnTypes.find(nColumn);
+                    if ( aFind == m_aODBCColumnTypes.end() )
+                        aFind = m_aODBCColumnTypes.insert(::std::map<sal_Int32,SWORD>::value_type(nColumn,OResultSetMetaData::getColumnODBCType(m_pStatement->getOwnConnection(),m_aStatementHandle,*this,nColumn))).first;
+		            *pColumn = OTools::getStringValue(m_pStatement->getOwnConnection(),m_aStatementHandle,nColumn,aFind->second,m_bWasNull,**this,m_nTextEncoding);
+                }
 				break;
 			case DataType::BIGINT:
 				*pColumn = getLong(nColumn);
 			case DataType::DOUBLE:
 				*pColumn = getDouble(nColumn);
 				break;
-			case DataType::LONGVARCHAR:
-				*pColumn = getString(nColumn);
-				break;
 			case DataType::LONGVARBINARY:
 				*pColumn = getBytes(nColumn);
 				break;
 				break;
 		}
 
-		if(wasNull())
+		if ( m_bWasNull )
 			pColumn->setNull();
 		if(nType != pColumn->getTypeKind())
 		{
 // -----------------------------------------------------------------------------
 sal_Bool OResultSet::move(IResultSetHelper::Movement _eCursorPosition, sal_Int32 _nOffset, sal_Bool /*_bRetrieveData*/)
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::move" );
 	SQLSMALLINT nFetchOrientation = SQL_FETCH_NEXT;
 	switch(_eCursorPosition)
 	{
 	OSL_TRACE( __FILE__": OSkipDeletedSet::OResultSet::move(%d,%d), FetchState = %d",nFetchOrientation,_nOffset,m_nCurrentFetchState);
 	OTools::ThrowException(m_pStatement->getOwnConnection(),m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
 
-	if ( m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO )
+    const bool bSuccess = m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO;
+	if ( bSuccess )
 	{
 		switch(_eCursorPosition)
 		{
 			case IResultSetHelper::BOOKMARK: // special case here because we are only called with position numbers
 				m_nRowPos = _nOffset;
 				break;
-		}
-		sal_uInt32 nValue = SQL_UB_OFF;
-		SQLRETURN nRet = N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_USE_BOOKMARKS,&nValue,SQL_IS_UINTEGER,NULL);
-        OSL_UNUSED( nRet );
-		if ( nValue != SQL_UB_OFF )
+		} // switch(_eCursorPosition)
+        if ( m_nUseBookmarks == ODBC_SQL_NOT_DEFINED )
+        {
+            RTL_LOGFILE_CONTEXT_TRACE( aLogger, "SQLGetStmtAttr" );
+            m_nUseBookmarks = SQL_UB_OFF;
+		    SQLRETURN nRet = N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_USE_BOOKMARKS,&m_nUseBookmarks,SQL_IS_UINTEGER,NULL);
+            OSL_UNUSED( nRet );
+        }
+		if ( m_nUseBookmarks != SQL_UB_OFF )
 		{
+            RTL_LOGFILE_CONTEXT_TRACE( aLogger, "OTools::getBytesValue" );
 			m_aBookmark = OTools::getBytesValue(m_pStatement->getOwnConnection(),m_aStatementHandle,0,SQL_C_VARBOOKMARK,m_bWasNull,**this);
 			m_aPosToBookmarks[m_aBookmark] = m_nRowPos;
 			OSL_ENSURE(m_aBookmark.getLength(),"Invalid bookmark from length 0!");
 	else if(IResultSetHelper::NEXT == _eCursorPosition && m_nCurrentFetchState == SQL_NO_DATA && nOldFetchStatus != SQL_NO_DATA)
 		++m_nRowPos;
 
-	return m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO;
+	return bSuccess;
 }
 // -----------------------------------------------------------------------------
 sal_Int32 OResultSet::getDriverPos() const
 // -----------------------------------------------------------------------------
 void OResultSet::fillNeededData(SQLRETURN _nRet)
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::fillNeededData" );
 	SQLRETURN nRet = _nRet;
 	if( nRet == SQL_NEED_DATA)
 	{

connectivity/source/drivers/odbcbase/OResultSetMetaData.cxx

 #include "precompiled_connectivity.hxx"
 #include "odbc/OResultSetMetaData.hxx"
 #include "odbc/OTools.hxx"
+#include <rtl/logfile.hxx>
 
 using namespace connectivity::odbc;
 using namespace com::sun::star::uno;
 {
 	if(m_nColCount != -1)
 		return m_nColCount;
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSetMetaData::getColumnCount" );
 	sal_Int16 nNumResultCols=0;
 	OTools::ThrowException(m_pConnection,N3SQLNumResultCols(m_aStatementHandle,&nNumResultCols),m_aStatementHandle,SQL_HANDLE_STMT,*this);
 	return m_nColCount = nNumResultCols;
 // -------------------------------------------------------------------------
 ::rtl::OUString SAL_CALL OResultSetMetaData::getColumnTypeName( sal_Int32 column ) throw(SQLException, RuntimeException)
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSetMetaData::getColumnTypeName" );
 	return getCharColAttrib(column,SQL_DESC_TYPE_NAME);
 }
 // -------------------------------------------------------------------------
 ::rtl::OUString SAL_CALL OResultSetMetaData::getColumnLabel( sal_Int32 column ) throw(SQLException, RuntimeException)
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSetMetaData::getColumnLabel" );
 	return getCharColAttrib(column,SQL_DESC_LABEL);
 }
 // -------------------------------------------------------------------------
 ::rtl::OUString SAL_CALL OResultSetMetaData::getColumnServiceName( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException)
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSetMetaData::getColumnServiceName" );
 	return ::rtl::OUString();
 }
 // -------------------------------------------------------------------------
 
 sal_Bool SAL_CALL OResultSetMetaData::isSigned( sal_Int32 column ) throw(SQLException, RuntimeException)
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSetMetaData::isSigned" );
 	return getNumColAttrib(column,SQL_DESC_UNSIGNED) == SQL_FALSE;
 }
 // -------------------------------------------------------------------------
 sal_Int32 SAL_CALL OResultSetMetaData::getPrecision( sal_Int32 column ) throw(SQLException, RuntimeException)
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSetMetaData::getPrecision" );
 	sal_Int32 nType = 0;
 	try
 	{
 // -----------------------------------------------------------------------------
 sal_Int32 SAL_CALL OResultSetMetaData::getScale( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSetMetaData::getScale" );
 	sal_Int32 nType = 0;
 	try
 	{
 
 sal_Int32 SAL_CALL OResultSetMetaData::isNullable( sal_Int32 column ) throw(SQLException, RuntimeException)
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSetMetaData::isNullable" );
 	return getNumColAttrib(column,SQL_DESC_NULLABLE);
 }
 // -------------------------------------------------------------------------
 
 sal_Bool SAL_CALL OResultSetMetaData::isSearchable( sal_Int32 column ) throw(SQLException, RuntimeException)
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSetMetaData::isSearchable" );
 	return getNumColAttrib(column,SQL_DESC_SEARCHABLE) != SQL_PRED_NONE;
 }
 // -------------------------------------------------------------------------
 
 sal_Bool SAL_CALL OResultSetMetaData::isReadOnly( sal_Int32 column ) throw(SQLException, RuntimeException)
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSetMetaData::isReadOnly" );
 	return getNumColAttrib(column,SQL_DESC_UPDATABLE) == SQL_ATTR_READONLY;
 }
 // -------------------------------------------------------------------------
 
 sal_Bool SAL_CALL OResultSetMetaData::isDefinitelyWritable( sal_Int32 column ) throw(SQLException, RuntimeException)
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSetMetaData::isDefinitelyWritable" );
 	return getNumColAttrib(column,SQL_DESC_UPDATABLE) == SQL_ATTR_WRITE;
 ;
 }
 // -------------------------------------------------------------------------
 sal_Bool SAL_CALL OResultSetMetaData::isWritable( sal_Int32 column ) throw(SQLException, RuntimeException)
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSetMetaData::isWritable" );
 	return getNumColAttrib(column,SQL_DESC_UPDATABLE) == SQL_ATTR_WRITE;
 }
 // -------------------------------------------------------------------------

connectivity/source/drivers/odbcbase/OTools.cxx

 #include <osl/diagnose.h>
 #include "odbc/OConnection.hxx"
 #include "diagnose_ex.h"
+#include <rtl/logfile.hxx>
 
 #include <string.h>
 #include <string>
 						void* _pValue,
 						SQLINTEGER _rSize) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OTools::getValue" );
 	SQLINTEGER pcbValue = SQL_NULL_DATA;
 	OTools::ThrowException(_pConnection,
 							(*(T3SQLGetData)_pConnection->getOdbcFunction(ODBC3SQLGetData))(_aStatementHandle,
 							rtl_TextEncoding _nTextEncoding)
 							 throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OTools::bindParameter" );
 	SQLRETURN nRetcode;
 	SWORD   fSqlType;
 	SWORD   fCType;
 						rtl_TextEncoding _nTextEncoding,
 						SQLUINTEGER& _nColumnSize)
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OTools::bindData" );
 	_nColumnSize = 0;
 
 	switch (_nOdbcType)
 						rtl_TextEncoding _nTextEncoding,
 						sal_Bool _bUseOldTimeDate) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OTools::bindValue" );
 	SQLRETURN nRetcode;
 	SQLSMALLINT   fSqlType;
 	SQLSMALLINT   fCType;
 
 	// Zusaetliche Informationen zum letzten ODBC-Funktionsaufruf vorhanden.
 	// SQLError liefert diese Informationen.
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OTools::ThrowException" );
 
 	SDB_ODBC_CHAR szSqlState[5];
 	SDWORD pfNativeError;
 										 sal_Bool &_bWasNull,
 										 const Reference< XInterface >& _xInterface) throw(SQLException, RuntimeException)
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OTools::getBytesValue" );
 	char aCharArray[2048];
 	// Erstmal versuchen, die Daten mit dem kleinen Puffer
 	// abzuholen:
 									   const Reference< XInterface >& _xInterface,
 									   rtl_TextEncoding _nTextEncoding) throw(SQLException, RuntimeException)
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OTools::getStringValue" );
 	::rtl::OUString aData;
 	switch(_fSqlType)
 	{
 //--------------------------------------------------------------------
 sal_Int32 OTools::jdbcTypeToOdbc(sal_Int32 jdbcType)
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OTools::jdbcTypeToOdbc" );
 	// For the most part, JDBC types match ODBC types.  We'll
 	// just convert the ones that we know are different
 
 						  SQLSMALLINT& fSqlType
 						  )
 {
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OTools::getBindTypes" );
 	switch(_nOdbcType)
 	{
 		case SQL_CHAR:				if(_bUseWChar)