diff options
Diffstat (limited to 'dbaccess/source/core/api')
-rw-r--r-- | dbaccess/source/core/api/BookmarkSet.cxx | 6 | ||||
-rw-r--r-- | dbaccess/source/core/api/CacheSet.cxx | 105 | ||||
-rw-r--r-- | dbaccess/source/core/api/CacheSet.hxx | 9 | ||||
-rw-r--r-- | dbaccess/source/core/api/KeySet.cxx | 260 | ||||
-rw-r--r-- | dbaccess/source/core/api/KeySet.hxx | 4 | ||||
-rw-r--r-- | dbaccess/source/core/api/RowSet.cxx | 17 | ||||
-rw-r--r-- | dbaccess/source/core/api/RowSet.hxx | 1 | ||||
-rw-r--r-- | dbaccess/source/core/api/RowSetBase.cxx | 6 | ||||
-rw-r--r-- | dbaccess/source/core/api/RowSetCache.cxx | 242 | ||||
-rw-r--r-- | dbaccess/source/core/api/RowSetCache.hxx | 4 | ||||
-rw-r--r-- | dbaccess/source/core/api/SingleSelectQueryComposer.cxx | 131 | ||||
-rw-r--r-- | dbaccess/source/core/api/resultset.cxx | 2422 | ||||
-rw-r--r-- | dbaccess/source/core/api/statement.cxx | 51 |
13 files changed, 1702 insertions, 1556 deletions
diff --git a/dbaccess/source/core/api/BookmarkSet.cxx b/dbaccess/source/core/api/BookmarkSet.cxx index b96c1eaf7..74b925f47 100644 --- a/dbaccess/source/core/api/BookmarkSet.cxx +++ b/dbaccess/source/core/api/BookmarkSet.cxx @@ -129,7 +129,8 @@ void SAL_CALL OBookmarkSet::insertRow( const ORowSetRow& _rInsertRow,const conne { xUpd->moveToInsertRow(); sal_Int32 i = 1; - for(connectivity::ORowVector< ORowSetValue > ::Vector::iterator aIter = _rInsertRow->get().begin()+1;aIter != _rInsertRow->get().end();++aIter,++i) + connectivity::ORowVector< ORowSetValue > ::Vector::iterator aEnd = _rInsertRow->get().end(); + for(connectivity::ORowVector< ORowSetValue > ::Vector::iterator aIter = _rInsertRow->get().begin()+1;aIter != aEnd;++aIter,++i) { aIter->setSigned(m_aSignedFlags[i-1]); updateColumn(i,xUpdRow,*aIter); @@ -151,7 +152,8 @@ void SAL_CALL OBookmarkSet::updateRow(const ORowSetRow& _rInsertRow ,const ORowS sal_Int32 i = 1; connectivity::ORowVector< ORowSetValue > ::Vector::const_iterator aOrgIter = _rOrginalRow->get().begin()+1; - for(connectivity::ORowVector< ORowSetValue > ::Vector::iterator aIter = _rInsertRow->get().begin()+1;aIter != _rInsertRow->get().end();++aIter,++i,++aOrgIter) + connectivity::ORowVector< ORowSetValue > ::Vector::iterator aEnd = _rInsertRow->get().end(); + for(connectivity::ORowVector< ORowSetValue > ::Vector::iterator aIter = _rInsertRow->get().begin()+1;aIter != aEnd;++aIter,++i,++aOrgIter) { aIter->setSigned(aOrgIter->isSigned()); updateColumn(i,xUpdRow,*aIter); diff --git a/dbaccess/source/core/api/CacheSet.cxx b/dbaccess/source/core/api/CacheSet.cxx index 1c5e07a7c..796cf39f4 100644 --- a/dbaccess/source/core/api/CacheSet.cxx +++ b/dbaccess/source/core/api/CacheSet.cxx @@ -88,6 +88,7 @@ #ifndef _TOOLS_DEBUG_HXX #include <tools/debug.hxx> #endif +#include <rtl/ustrbuf.hxx> #include <rtl/logfile.hxx> using namespace comphelper; @@ -205,36 +206,37 @@ void OCacheSet::fillTableName(const Reference<XPropertySet>& _xTable) throw(SQL void SAL_CALL OCacheSet::insertRow( const ORowSetRow& _rInsertRow,const connectivity::OSQLTable& _xTable ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::insertRow" ); - ::rtl::OUString aSql(::rtl::OUString::createFromAscii("INSERT INTO ")); + ::rtl::OUStringBuffer aSql(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("INSERT INTO "))); Reference<XPropertySet> xSet(_xTable,UNO_QUERY); fillTableName(xSet); - aSql += m_aComposedTableName; - aSql += ::rtl::OUString::createFromAscii(" ( "); + aSql.append(m_aComposedTableName); + aSql.append(::rtl::OUString::createFromAscii(" ( ")); // set values and column names - ::rtl::OUString aValues = ::rtl::OUString::createFromAscii(" VALUES ( "); - static ::rtl::OUString aPara = ::rtl::OUString::createFromAscii("?,"); + ::rtl::OUStringBuffer aValues = ::rtl::OUString::createFromAscii(" VALUES ( "); + static ::rtl::OUString aPara(RTL_CONSTASCII_USTRINGPARAM("?,")); ::rtl::OUString aQuote = getIdentifierQuoteString(); - static ::rtl::OUString aComma = ::rtl::OUString::createFromAscii(","); + static ::rtl::OUString aComma(RTL_CONSTASCII_USTRINGPARAM(",")); sal_Int32 i = 1; ORowVector< ORowSetValue >::Vector::const_iterator aIter = _rInsertRow->get().begin()+1; - for(; aIter != _rInsertRow->get().end();++aIter) + connectivity::ORowVector< ORowSetValue > ::Vector::iterator aEnd = _rInsertRow->get().end(); + for(; aIter != aEnd;++aIter) { - aSql += ::dbtools::quoteName( aQuote,m_xSetMetaData->getColumnName(i++)); - aSql += aComma; - aValues += aPara; + aSql.append(::dbtools::quoteName( aQuote,m_xSetMetaData->getColumnName(i++))); + aSql.append(aComma); + aValues.append(aPara); } - aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString::createFromAscii(")")); - aValues = aValues.replaceAt(aValues.getLength()-1,1,::rtl::OUString::createFromAscii(")")); + aSql.setCharAt(aSql.getLength()-1,')'); + aValues.setCharAt(aValues.getLength()-1,')'); - aSql += aValues; + aSql.append(aValues.makeStringAndClear()); // now create end execute the prepared statement { - Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(aSql)); + Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(aSql.makeStringAndClear())); Reference< XParameters > xParameter(xPrep,UNO_QUERY); i = 1; - for(aIter = _rInsertRow->get().begin()+1; aIter != _rInsertRow->get().end();++aIter,++i) + for(aIter = _rInsertRow->get().begin()+1; aIter != aEnd;++aIter,++i) { if(aIter->isNull()) xParameter->setNull(i,aIter->getTypeKind()); @@ -265,8 +267,8 @@ void SAL_CALL OCacheSet::insertRow( const ORowSetRow& _rInsertRow,const connecti // ------------------------------------------------------------------------- void OCacheSet::fillParameters( const ORowSetRow& _rRow ,const connectivity::OSQLTable& _xTable - ,::rtl::OUString& _sCondition - ,::rtl::OUString& _sParameter + ,::rtl::OUStringBuffer& _sCondition + ,::rtl::OUStringBuffer& _sParameter ,::std::list< sal_Int32>& _rOrgValues) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::fillParameters" ); @@ -330,6 +332,9 @@ void OCacheSet::fillParameters( const ORowSetRow& _rRow sal_Int32 nCheckCount = 1; // index for the orginal values sal_Int32 i = 1; + + ::rtl::OUString sIsNull(RTL_CONSTASCII_USTRINGPARAM(" IS NULL")); + ::rtl::OUString sParam(RTL_CONSTASCII_USTRINGPARAM(" = ?")); ORowVector< ORowSetValue >::Vector::const_iterator aIter = _rRow->get().begin()+1; ORowVector< ORowSetValue >::Vector::const_iterator aEnd = _rRow->get().end()+1; for(; aIter != aEnd;++aIter,++nCheckCount,++i) @@ -337,34 +342,35 @@ void OCacheSet::fillParameters( const ORowSetRow& _rRow aColumnName = m_xSetMetaData->getColumnName(i); if(xKeyColumns.is() && xKeyColumns->hasByName(aColumnName)) { - _sCondition += ::dbtools::quoteName( aQuote,aColumnName); + _sCondition.append(::dbtools::quoteName( aQuote,aColumnName)); if(aIter->isNull()) - _sCondition += ::rtl::OUString::createFromAscii(" IS NULL"); + _sCondition.append(sIsNull); else - _sCondition += ::rtl::OUString::createFromAscii(" = ?"); - _sCondition += aAnd; + _sCondition.append(sParam); + _sCondition.append(aAnd); _rOrgValues.push_back(nCheckCount); - } + } // if(xKeyColumns.is() && xKeyColumns->hasByName(aColumnName)) + ::std::vector< Reference<XNameAccess> >::const_iterator aIndexEnd = aAllIndexColumns.end(); for( ::std::vector< Reference<XNameAccess> >::const_iterator aIndexIter = aAllIndexColumns.begin(); - aIndexIter != aAllIndexColumns.end();++aIndexIter) + aIndexIter != aIndexEnd;++aIndexIter) { if((*aIndexIter)->hasByName(aColumnName)) { - _sCondition += ::dbtools::quoteName( aQuote,aColumnName); + _sCondition.append(::dbtools::quoteName( aQuote,aColumnName)); if(aIter->isNull()) - _sCondition += ::rtl::OUString::createFromAscii(" IS NULL"); + _sCondition.append(sIsNull); else - _sCondition += ::rtl::OUString::createFromAscii(" = ?"); - _sCondition += aAnd; + _sCondition.append(sParam); + _sCondition.append(aAnd); _rOrgValues.push_back(nCheckCount); break; } } if(aIter->isModified()) { - _sParameter += ::dbtools::quoteName( aQuote,aColumnName); - _sParameter += aPara; + _sParameter.append(::dbtools::quoteName( aQuote,aColumnName)); + _sParameter.append(aPara); } } } @@ -375,39 +381,41 @@ void SAL_CALL OCacheSet::updateRow(const ORowSetRow& _rInsertRow ,const ORowSetR Reference<XPropertySet> xSet(_xTable,UNO_QUERY); fillTableName(xSet); - ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("UPDATE "); - aSql += m_aComposedTableName; - aSql += ::rtl::OUString::createFromAscii(" SET "); + ::rtl::OUStringBuffer aSql = ::rtl::OUString::createFromAscii("UPDATE "); + aSql.append(m_aComposedTableName); + aSql.append(::rtl::OUString::createFromAscii(" SET ")); // list all cloumns that should be set - ::rtl::OUString aCondition; + ::rtl::OUStringBuffer aCondition; ::std::list< sal_Int32> aOrgValues; fillParameters(_rInsertRow,_xTable,aCondition,aSql,aOrgValues); - aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString::createFromAscii(" ")); + aSql.setCharAt(aSql.getLength()-1,' '); if ( aCondition.getLength() ) { - aCondition = aCondition.replaceAt(aCondition.getLength()-5,5,::rtl::OUString::createFromAscii(" ")); + aCondition.setLength(aCondition.getLength()-5); - aSql += ::rtl::OUString::createFromAscii(" WHERE "); - aSql += aCondition; + aSql.append(::rtl::OUString::createFromAscii(" WHERE ")); + aSql.append(aCondition.makeStringAndClear()); } else ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_UPDATE_MISSING_CONDITION ), SQL_GENERAL_ERROR, *this ); // now create end execute the prepared statement - Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(aSql)); + Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(aSql.makeStringAndClear())); Reference< XParameters > xParameter(xPrep,UNO_QUERY); sal_Int32 i = 1; - for(ORowVector< ORowSetValue >::Vector::const_iterator aIter = _rInsertRow->get().begin()+1; aIter != _rInsertRow->get().end();++aIter) + connectivity::ORowVector< ORowSetValue > ::Vector::iterator aEnd = _rInsertRow->get().end(); + for(ORowVector< ORowSetValue >::Vector::const_iterator aIter = _rInsertRow->get().begin()+1; aIter != aEnd;++aIter) { if(aIter->isModified()) { setParameter(i,xParameter,*aIter,m_xSetMetaData->getColumnType(i),m_xSetMetaData->getScale(i)); ++i; } - } - for(::std::list< sal_Int32>::const_iterator aOrgValue = aOrgValues.begin(); aOrgValue != aOrgValues.end();++aOrgValue,++i) + } // for(ORowVector< ORowSetValue >::Vector::const_iterator aIter = _rInsertRow->get().begin()+1; aIter != aEnd;++aIter) + ::std::list< sal_Int32>::const_iterator aOrgValueEnd = aOrgValues.end(); + for(::std::list< sal_Int32>::const_iterator aOrgValue = aOrgValues.begin(); aOrgValue != aOrgValueEnd;++aOrgValue,++i) { setParameter(i,xParameter,(_rOrginalRow->get())[*aOrgValue],m_xSetMetaData->getColumnType(i),m_xSetMetaData->getScale(i)); } @@ -421,9 +429,9 @@ void SAL_CALL OCacheSet::deleteRow(const ORowSetRow& _rDeleteRow ,const connecti Reference<XPropertySet> xSet(_xTable,UNO_QUERY); fillTableName(xSet); - ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("DELETE FROM "); - aSql += m_aComposedTableName; - aSql += ::rtl::OUString::createFromAscii(" WHERE "); + ::rtl::OUStringBuffer aSql = ::rtl::OUString::createFromAscii("DELETE FROM "); + aSql.append(m_aComposedTableName); + aSql.append(::rtl::OUString::createFromAscii(" WHERE ")); // list all cloumns that should be set ::rtl::OUString aQuote = getIdentifierQuoteString(); @@ -480,17 +488,18 @@ void SAL_CALL OCacheSet::deleteRow(const ORowSetRow& _rDeleteRow ,const connecti } } - ::rtl::OUString aColumnName; + ::rtl::OUStringBuffer aColumnName; ::std::list< sal_Int32> aOrgValues; fillParameters(_rDeleteRow,_xTable,aSql,aColumnName,aOrgValues); - aSql = aSql.replaceAt(aSql.getLength()-5,5,::rtl::OUString::createFromAscii(" ")); + aSql.setLength(aSql.getLength()-5); // now create end execute the prepared statement - Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(aSql)); + Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(aSql.makeStringAndClear())); Reference< XParameters > xParameter(xPrep,UNO_QUERY); sal_Int32 i = 1; - for(::std::list< sal_Int32>::const_iterator j = aOrgValues.begin(); j != aOrgValues.end();++j,++i) + ::std::list< sal_Int32>::const_iterator aOrgValueEnd = aOrgValues.end(); + for(::std::list< sal_Int32>::const_iterator j = aOrgValues.begin(); j != aOrgValueEnd;++j,++i) { setParameter(i,xParameter,(_rDeleteRow->get())[*j],m_xSetMetaData->getColumnType(i),m_xSetMetaData->getScale(i)); } diff --git a/dbaccess/source/core/api/CacheSet.hxx b/dbaccess/source/core/api/CacheSet.hxx index a009fa6e3..8d765e6db 100644 --- a/dbaccess/source/core/api/CacheSet.hxx +++ b/dbaccess/source/core/api/CacheSet.hxx @@ -65,7 +65,10 @@ #endif #include <list> - +namespace rtl +{ + class OUStringBuffer; +} namespace com{ namespace sun { namespace star{namespace sdbc{ class XParameters; } } } } namespace dbaccess @@ -98,8 +101,8 @@ namespace dbaccess ); void fillParameters( const ORowSetRow& _rRow ,const connectivity::OSQLTable& _xTable - ,::rtl::OUString& _sCondition - ,::rtl::OUString& _sParameter + ,::rtl::OUStringBuffer& _sCondition + ,::rtl::OUStringBuffer& _sParameter ,::std::list< sal_Int32>& _rOrgValues); void fillTableName(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xTable) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); diff --git a/dbaccess/source/core/api/KeySet.cxx b/dbaccess/source/core/api/KeySet.cxx index 785cba4df..56c87c7b5 100644 --- a/dbaccess/source/core/api/KeySet.cxx +++ b/dbaccess/source/core/api/KeySet.cxx @@ -157,8 +157,10 @@ DBG_NAME(OKeySet) OKeySet::OKeySet(const connectivity::OSQLTable& _xTable, const Reference< XIndexAccess>& _xTableKeys, const ::rtl::OUString& _rUpdateTableName, // this can be the alias or the full qualified name - const Reference< XSingleSelectQueryAnalyzer >& _xComposer) - :m_pKeyColumnNames(NULL) + const Reference< XSingleSelectQueryAnalyzer >& _xComposer, + const ORowSetValueVector& _aParameterValueForCache) + :m_aParameterValueForCache(_aParameterValueForCache) + ,m_pKeyColumnNames(NULL) ,m_pColumnNames(NULL) ,m_pForeignColumnNames(NULL) ,m_xTable(_xTable) @@ -213,7 +215,8 @@ void OKeySet::construct(const Reference< XResultSet>& _xDriverSet) ::dbaccess::getColumnPositions(xSup->getColumns(),xSourceColumns,m_sUpdateTableName,(*m_pColumnNames)); SelectColumnsMetaData::const_iterator aPosIter = (*m_pKeyColumnNames).begin(); - for(;aPosIter != (*m_pKeyColumnNames).end();++aPosIter) + SelectColumnsMetaData::const_iterator aPosEnd = (*m_pKeyColumnNames).end(); + for(;aPosIter != aPosEnd;++aPosIter) { if(xSourceColumns->hasByName(aPosIter->first)) { @@ -234,7 +237,7 @@ void OKeySet::construct(const Reference< XResultSet>& _xDriverSet) Reference<XDatabaseMetaData> xMetaData = m_xConnection->getMetaData(); ::rtl::OUString aQuote = getIdentifierQuoteString(); - ::rtl::OUString aFilter; + ::rtl::OUStringBuffer aFilter; ::rtl::OUString sCatalog,sSchema,sTable; Reference<XPropertySet> xTableProp(m_xTable,UNO_QUERY); @@ -252,16 +255,16 @@ void OKeySet::construct(const Reference< XResultSet>& _xDriverSet) static ::rtl::OUString s_sDot(RTL_CONSTASCII_USTRINGPARAM(".")); static ::rtl::OUString s_sParam(RTL_CONSTASCII_USTRINGPARAM(" = ?")); // create the where clause - SelectColumnsMetaData::const_iterator aIter; - for(aIter = (*m_pKeyColumnNames).begin();aIter != (*m_pKeyColumnNames).end();) + aPosEnd = (*m_pKeyColumnNames).end(); + for(aPosIter = (*m_pKeyColumnNames).begin();aPosIter != aPosEnd;) { - aFilter += sComposedName; - aFilter += s_sDot; - aFilter += ::dbtools::quoteName( aQuote,aIter->first); - aFilter += s_sParam; - ++aIter; - if(aIter != (*m_pKeyColumnNames).end()) - aFilter += aAnd; + aFilter.append(sComposedName); + aFilter.append(s_sDot); + aFilter.append(::dbtools::quoteName( aQuote,aPosIter->first)); + aFilter.append(s_sParam); + ++aPosIter; + if(aPosIter != aPosEnd) + aFilter.append(aAnd); } Reference< XMultiServiceFactory > xFactory(m_xConnection, UNO_QUERY_THROW); @@ -293,18 +296,23 @@ void OKeySet::construct(const Reference< XResultSet>& _xDriverSet) // look for columns not in the source columns to use them as filter as well if ( !xSourceColumns->hasByName(*pSelectColumnName) ) { - aFilter += s_sDot; - aFilter += ::dbtools::quoteName( aQuote,*pSelectColumnName); - aFilter += s_sParam; + aFilter.append(s_sDot); + aFilter.append(::dbtools::quoteName( aQuote,*pSelectColumnName)); + aFilter.append(s_sParam); if ( (pSelectColumnName+1) != pSelectColumnEnd ) - aFilter += aAnd; + aFilter.append(aAnd); } } break; } } + } // if ( aSeq.getLength() > 1 ) // special handling for join + const ::rtl::OUString sOldFilter = xAnalyzer->getFilter(); + if ( sOldFilter.getLength() ) + { + aFilter = sOldFilter + aAnd + aFilter.makeStringAndClear(); } - xAnalyzer->setFilter(aFilter); + xAnalyzer->setFilter(aFilter.makeStringAndClear()); m_xStatement = m_xConnection->prepareStatement(xAnalyzer->getQueryWithSubstitution()); ::comphelper::disposeComponent(xAnalyzer); } @@ -368,12 +376,12 @@ Sequence< sal_Int32 > SAL_CALL OKeySet::deleteRows( const Sequence< Any >& rows Reference<XPropertySet> xSet(_xTable,UNO_QUERY); fillTableName(xSet); - ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("DELETE FROM "); - aSql += m_aComposedTableName; - aSql += ::rtl::OUString::createFromAscii(" WHERE "); + ::rtl::OUStringBuffer aSql = ::rtl::OUString::createFromAscii("DELETE FROM "); + aSql.append(m_aComposedTableName); + aSql.append(::rtl::OUString::createFromAscii(" WHERE ")); // list all cloumns that should be set - ::rtl::OUString aQuote = getIdentifierQuoteString(); + const ::rtl::OUString aQuote = getIdentifierQuoteString(); static ::rtl::OUString aAnd = ::rtl::OUString::createFromAscii(" AND "); static ::rtl::OUString aOr = ::rtl::OUString::createFromAscii(" OR "); static ::rtl::OUString aEqual = ::rtl::OUString::createFromAscii(" = ?"); @@ -383,16 +391,18 @@ Sequence< sal_Int32 > SAL_CALL OKeySet::deleteRows( const Sequence< Any >& rows // first the keys Reference<XNameAccess> xKeyColumns = getKeyColumns(); - ::rtl::OUString aCondition = ::rtl::OUString::createFromAscii("( "); + ::rtl::OUStringBuffer aCondition = ::rtl::OUString::createFromAscii("( "); SelectColumnsMetaData::const_iterator aIter = (*m_pKeyColumnNames).begin(); - for(;aIter != (*m_pKeyColumnNames).end();++aIter) + SelectColumnsMetaData::const_iterator aPosEnd = (*m_pKeyColumnNames).end(); + for(;aIter != aPosEnd;++aIter) { - aCondition += ::dbtools::quoteName( aQuote,aIter->first); - aCondition += aEqual; - aCondition += aAnd; + aCondition.append(::dbtools::quoteName( aQuote,aIter->first)); + aCondition.append(aEqual); + aCondition.append(aAnd); } - aCondition = aCondition.replaceAt(aCondition.getLength()-5,5,::rtl::OUString::createFromAscii(" )")); + aCondition.setLength(aCondition.getLength()-5); + const ::rtl::OUString sCon( aCondition.makeStringAndClear() ); const Any* pBegin = rows.getConstArray(); const Any* pEnd = pBegin + rows.getLength(); @@ -400,14 +410,14 @@ Sequence< sal_Int32 > SAL_CALL OKeySet::deleteRows( const Sequence< Any >& rows Sequence< Any > aKeys; for(;pBegin != pEnd;++pBegin) { - aSql += aCondition; - aSql += aOr; + aSql.append(sCon); + aSql.append(aOr); } - aSql = aSql.replaceAt(aSql.getLength()-3,3,::rtl::OUString::createFromAscii(" ")); + aSql.setLength(aSql.getLength()-3); // now create end execute the prepared statement - Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(aSql)); + Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(aSql.makeStringAndClear())); Reference< XParameters > xParameter(xPrep,UNO_QUERY); pBegin = rows.getConstArray(); @@ -418,8 +428,9 @@ Sequence< sal_Int32 > SAL_CALL OKeySet::deleteRows( const Sequence< Any >& rows if(m_aKeyIter != m_aKeyMap.end()) { connectivity::ORowVector< ORowSetValue >::Vector::iterator aKeyIter = m_aKeyIter->second.first->get().begin(); + connectivity::ORowVector< ORowSetValue >::Vector::iterator aKeyEnd = m_aKeyIter->second.first->get().end(); SelectColumnsMetaData::const_iterator aPosIter = (*m_pKeyColumnNames).begin(); - for(sal_uInt16 j = 0;aKeyIter != m_aKeyIter->second.first->get().end();++aKeyIter,++j,++aPosIter) + for(sal_uInt16 j = 0;aKeyIter != aKeyEnd;++aKeyIter,++j,++aPosIter) { setParameter(i++,xParameter,*aKeyIter,aPosIter->second.nType,aPosIter->second.nScale); } @@ -453,13 +464,15 @@ void SAL_CALL OKeySet::updateRow(const ORowSetRow& _rInsertRow ,const ORowSetRow Reference<XPropertySet> xSet(_xTable,UNO_QUERY); fillTableName(xSet); - ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("UPDATE "); - aSql += m_aComposedTableName; - aSql += ::rtl::OUString::createFromAscii(" SET "); + ::rtl::OUStringBuffer aSql = ::rtl::OUString::createFromAscii("UPDATE "); + aSql.append(m_aComposedTableName); + aSql.append(::rtl::OUString::createFromAscii(" SET ")); // list all cloumns that should be set static ::rtl::OUString aPara = ::rtl::OUString::createFromAscii(" = ?,"); ::rtl::OUString aQuote = getIdentifierQuoteString(); static ::rtl::OUString aAnd = ::rtl::OUString::createFromAscii(" AND "); + ::rtl::OUString sIsNull(RTL_CONSTASCII_USTRINGPARAM(" IS NULL")); + ::rtl::OUString sParam(RTL_CONSTASCII_USTRINGPARAM(" = ?")); // use keys and indexes for excat postioning // first the keys @@ -476,91 +489,90 @@ void SAL_CALL OKeySet::updateRow(const ORowSetRow& _rInsertRow ,const ORowSetRow lcl_fillIndexColumns(xIndexes,aAllIndexColumns); ::rtl::OUString aColumnName; - ::rtl::OUString aCondition,sKeyCondition,sIndexCondition,sSetValues; + ::rtl::OUStringBuffer sKeyCondition,sIndexCondition; ::std::vector<sal_Int32> aIndexColumnPositions; + const sal_Int32 nOldLength = aSql.getLength(); sal_Int32 i = 1; // here we build the condition part for the update statement SelectColumnsMetaData::const_iterator aIter = m_pColumnNames->begin(); - for(;aIter != m_pColumnNames->end();++aIter,++i) + SelectColumnsMetaData::const_iterator aEnd = m_pColumnNames->end(); + for(;aIter != aEnd;++aIter,++i) { if(xKeyColumns.is() && xKeyColumns->hasByName(aIter->first)) { - sKeyCondition += ::dbtools::quoteName( aQuote,aIter->first); + sKeyCondition.append(::dbtools::quoteName( aQuote,aIter->first)); if((_rOrginalRow->get())[aIter->second.nPosition].isNull()) - sKeyCondition += ::rtl::OUString::createFromAscii(" IS NULL"); + sKeyCondition.append(sIsNull); else - sKeyCondition += ::rtl::OUString::createFromAscii(" = ?"); - sKeyCondition += aAnd; + sKeyCondition.append(sParam); + sKeyCondition.append(aAnd); } else { + ::std::vector< Reference<XNameAccess> >::const_iterator aIndexEnd = aAllIndexColumns.end(); for( ::std::vector< Reference<XNameAccess> >::const_iterator aIndexIter = aAllIndexColumns.begin(); - aIndexIter != aAllIndexColumns.end();++aIndexIter) + aIndexIter != aIndexEnd;++aIndexIter) { if((*aIndexIter)->hasByName(aIter->first)) { - sIndexCondition += ::dbtools::quoteName( aQuote,aIter->first); + sIndexCondition.append(::dbtools::quoteName( aQuote,aIter->first)); if((_rOrginalRow->get())[aIter->second.nPosition].isNull()) - sIndexCondition += ::rtl::OUString::createFromAscii(" IS NULL"); + sIndexCondition.append(sIsNull); else { - sIndexCondition += ::rtl::OUString::createFromAscii(" = ?"); + sIndexCondition.append(sParam); aIndexColumnPositions.push_back(aIter->second.nPosition); } - sIndexCondition += aAnd; + sIndexCondition.append(aAnd); break; } } } if((_rInsertRow->get())[aIter->second.nPosition].isModified()) { - sSetValues += ::dbtools::quoteName( aQuote,aIter->first); - sSetValues += aPara; + aSql.append(::dbtools::quoteName( aQuote,aIter->first)); + aSql.append(aPara); } } - if(sSetValues.getLength()) + if( aSql.getLength() != nOldLength ) { - sSetValues = sSetValues.replaceAt(sSetValues.getLength()-1,1,::rtl::OUString::createFromAscii(" ")); - aSql += sSetValues; + aSql.setLength(aSql.getLength()-1); } else ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_VALUE_CHANGED ), SQL_GENERAL_ERROR, m_xConnection ); if(sKeyCondition.getLength() || sIndexCondition.getLength()) { + aSql.append(::rtl::OUString::createFromAscii(" WHERE ")); if(sKeyCondition.getLength() && sIndexCondition.getLength()) { - aCondition = sKeyCondition; - aCondition += sIndexCondition; + aSql.append(sKeyCondition.makeStringAndClear()); + aSql.append(sIndexCondition.makeStringAndClear()); } else if(sKeyCondition.getLength()) { - aCondition = sKeyCondition; + aSql.append(sKeyCondition.makeStringAndClear()); } else if(sIndexCondition.getLength()) { - aCondition = sIndexCondition; + aSql.append(sIndexCondition.makeStringAndClear()); } - - aCondition = aCondition.replaceAt(aCondition.getLength()-5,5,::rtl::OUString::createFromAscii(" ")); - - aSql += ::rtl::OUString::createFromAscii(" WHERE "); - aSql += aCondition; + aSql.setLength(aSql.getLength()-5); // remove the last AND } else ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_CONDITION_FOR_PK ), SQL_GENERAL_ERROR, m_xConnection ); // now create end execute the prepared statement - Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(aSql)); + Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(aSql.makeStringAndClear())); Reference< XParameters > xParameter(xPrep,UNO_QUERY); i = 1; // first the set values aIter = m_pColumnNames->begin(); sal_uInt16 j = 0; - for(;aIter != m_pColumnNames->end();++aIter,++j) + for(;aIter != aEnd;++aIter,++j) { sal_Int32 nPos = aIter->second.nPosition; if((_rInsertRow->get())[nPos].isModified()) @@ -571,16 +583,18 @@ void SAL_CALL OKeySet::updateRow(const ORowSetRow& _rInsertRow ,const ORowSetRow } // and then the values of the where condition aIter = (*m_pKeyColumnNames).begin(); + aEnd = (*m_pKeyColumnNames).end(); j = 0; - for(;aIter != (*m_pKeyColumnNames).end();++aIter,++i,++j) + for(;aIter != aEnd;++aIter,++i,++j) { setParameter(i,xParameter,(_rOrginalRow->get())[aIter->second.nPosition],aIter->second.nType,aIter->second.nScale); } // now we have to set the index values ::std::vector<sal_Int32>::iterator aIdxColIter = aIndexColumnPositions.begin(); + ::std::vector<sal_Int32>::iterator aIdxColEnd = aIndexColumnPositions.end(); j = 0; - for(;aIdxColIter != aIndexColumnPositions.end();++aIdxColIter,++i,++j) + for(;aIdxColIter != aIdxColEnd;++aIdxColIter,++i,++j) { setParameter(i,xParameter,(_rOrginalRow->get())[*aIdxColIter],(_rOrginalRow->get())[*aIdxColIter].getTypeKind(),aIter->second.nScale); } @@ -600,46 +614,46 @@ void SAL_CALL OKeySet::updateRow(const ORowSetRow& _rInsertRow ,const ORowSetRow void SAL_CALL OKeySet::insertRow( const ORowSetRow& _rInsertRow,const connectivity::OSQLTable& _xTable ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::insertRow" ); - ::rtl::OUString aSql(::rtl::OUString::createFromAscii("INSERT INTO ")); + ::rtl::OUStringBuffer aSql(::rtl::OUString::createFromAscii("INSERT INTO ")); Reference<XPropertySet> xSet(_xTable,UNO_QUERY); fillTableName(xSet); - aSql += m_aComposedTableName; - aSql += ::rtl::OUString::createFromAscii(" ( "); + aSql.append(m_aComposedTableName); + aSql.append(::rtl::OUString::createFromAscii(" ( ")); // set values and column names - ::rtl::OUString aValues(RTL_CONSTASCII_USTRINGPARAM(" VALUES ( ")); + ::rtl::OUStringBuffer aValues(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" VALUES ( "))); static ::rtl::OUString aPara(RTL_CONSTASCII_USTRINGPARAM("?,")); ::rtl::OUString aQuote = getIdentifierQuoteString(); static ::rtl::OUString aComma(RTL_CONSTASCII_USTRINGPARAM(",")); SelectColumnsMetaData::const_iterator aIter = m_pColumnNames->begin(); + SelectColumnsMetaData::const_iterator aEnd = m_pColumnNames->end(); sal_Int32 j = 1; sal_Bool bModified = sal_False; - for(;aIter != m_pColumnNames->end();++aIter,++j) + for(;aIter != aEnd;++aIter,++j) { if((_rInsertRow->get())[aIter->second.nPosition].isModified()) { - aSql += ::dbtools::quoteName( aQuote,aIter->first); - aSql += aComma; - aValues += aPara; + aSql.append(::dbtools::quoteName( aQuote,aIter->first)); + aSql.append(aComma); + aValues.append(aPara); bModified = sal_True; } } if ( !bModified ) ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_VALUE_CHANGED ), SQL_GENERAL_ERROR, m_xConnection ); - aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString::createFromAscii(")")); - aValues = aValues.replaceAt(aValues.getLength()-1,1,::rtl::OUString::createFromAscii(")")); - - aSql += aValues; + aSql.setCharAt(aSql.getLength()-1,')'); + aValues.setCharAt(aValues.getLength()-1,')'); + aSql.append(aValues.makeStringAndClear()); // now create,fill and execute the prepared statement - Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(aSql)); + Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(aSql.makeStringAndClear())); Reference< XParameters > xParameter(xPrep,UNO_QUERY); - SelectColumnsMetaData::const_iterator aPosIter = m_pColumnNames->begin(); - for(sal_Int32 i = 1;aPosIter != m_pColumnNames->end();++aPosIter) + aIter = m_pColumnNames->begin(); + for(sal_Int32 i = 1;aIter != aEnd;++aIter) { - sal_Int32 nPos = aPosIter->second.nPosition; + const sal_Int32 nPos = aIter->second.nPosition; if((_rInsertRow->get())[nPos].isModified()) { if((_rInsertRow->get())[nPos].isNull()) @@ -647,7 +661,7 @@ void SAL_CALL OKeySet::insertRow( const ORowSetRow& _rInsertRow,const connectivi else { (_rInsertRow->get())[nPos].setSigned(m_aSignedFlags[nPos-1]); - setParameter(i++,xParameter,(_rInsertRow->get())[nPos],aPosIter->second.nType,aPosIter->second.nScale); + setParameter(i++,xParameter,(_rInsertRow->get())[nPos],aIter->second.nType,aIter->second.nScale); } } } @@ -657,11 +671,11 @@ void SAL_CALL OKeySet::insertRow( const ORowSetRow& _rInsertRow,const connectivi if ( m_bInserted ) { // first insert the default values into the insertrow - SelectColumnsMetaData::const_iterator defaultIter = m_pColumnNames->begin(); - for(;defaultIter != m_pColumnNames->end();++defaultIter) + aIter = m_pColumnNames->begin(); + for(;aIter != aEnd;++aIter) { - if ( !(_rInsertRow->get())[defaultIter->second.nPosition].isModified() ) - (_rInsertRow->get())[defaultIter->second.nPosition] = defaultIter->second.sDefaultValue; + if ( !(_rInsertRow->get())[aIter->second.nPosition].isModified() ) + (_rInsertRow->get())[aIter->second.nPosition] = aIter->second.sDefaultValue; } try { @@ -701,17 +715,21 @@ void SAL_CALL OKeySet::insertRow( const ORowSetRow& _rInsertRow,const connectivi if ( !bAutoValuesFetched && m_bInserted ) { // first check if all key column values were set - ::rtl::OUString sQuote = getIdentifierQuoteString(); + const ::rtl::OUString sMax(RTL_CONSTASCII_USTRINGPARAM(" MAX(")); + const ::rtl::OUString sMaxEnd(RTL_CONSTASCII_USTRINGPARAM("),")); + const ::rtl::OUString sQuote = getIdentifierQuoteString(); ::rtl::OUString sMaxStmt; + aEnd = m_pKeyColumnNames->end(); ::std::vector< ::rtl::OUString >::iterator aAutoIter = m_aAutoColumns.begin(); - for (;aAutoIter != m_aAutoColumns.end(); ++aAutoIter) + ::std::vector< ::rtl::OUString >::iterator aAutoEnd = m_aAutoColumns.end(); + for (;aAutoIter != aAutoEnd; ++aAutoIter) { // we will only fetch values which are keycolumns - if ( m_pKeyColumnNames->find(*aAutoIter) != m_pKeyColumnNames->end() ) + if ( m_pKeyColumnNames->find(*aAutoIter) != aEnd ) { - sMaxStmt += ::rtl::OUString::createFromAscii(" MAX("); + sMaxStmt += sMax; sMaxStmt += ::dbtools::quoteName( sQuote,*aAutoIter); - sMaxStmt += ::rtl::OUString::createFromAscii("),"); + sMaxStmt += sMaxEnd; } } @@ -731,12 +749,11 @@ void SAL_CALL OKeySet::insertRow( const ORowSetRow& _rInsertRow,const connectivi if(xRow.is() && xRes->next()) { aAutoIter = m_aAutoColumns.begin(); - ::std::vector< ::rtl::OUString >::iterator aAutoEnd = m_aAutoColumns.end(); for (sal_Int32 i=1;aAutoIter != aAutoEnd; ++aAutoIter,++i) { // we will only fetch values which are keycolumns SelectColumnsMetaData::iterator aFind = m_pKeyColumnNames->find(*aAutoIter); - if(aFind != m_pKeyColumnNames->end()) + if ( aFind != aEnd ) (_rInsertRow->get())[aFind->second.nPosition].fill(i,aFind->second.nType,aFind->second.bNullable,xRow); } } @@ -780,9 +797,9 @@ void SAL_CALL OKeySet::deleteRow(const ORowSetRow& _rDeleteRow,const connectivit Reference<XPropertySet> xSet(_xTable,UNO_QUERY); fillTableName(xSet); - ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("DELETE FROM "); - aSql += m_aComposedTableName; - aSql += ::rtl::OUString::createFromAscii(" WHERE "); + ::rtl::OUStringBuffer aSql = ::rtl::OUString::createFromAscii("DELETE FROM "); + aSql.append(m_aComposedTableName); + aSql.append(::rtl::OUString::createFromAscii(" WHERE ")); // list all cloumns that should be set ::rtl::OUString aQuote = getIdentifierQuoteString(); @@ -800,64 +817,69 @@ void SAL_CALL OKeySet::deleteRow(const ORowSetRow& _rDeleteRow,const connectivit ::std::vector< Reference<XNameAccess> > aAllIndexColumns; lcl_fillIndexColumns(xIndexes,aAllIndexColumns); - ::rtl::OUString aColumnName,sIndexCondition; + ::rtl::OUString aColumnName; + ::rtl::OUStringBuffer sIndexCondition; ::std::vector<sal_Int32> aIndexColumnPositions; SelectColumnsMetaData::const_iterator aIter = m_pColumnNames->begin(); + SelectColumnsMetaData::const_iterator aEnd = m_pColumnNames->end(); sal_Int32 i = 1; - for(i = 1;aIter != m_pColumnNames->end();++aIter,++i) + for(i = 1;aIter != aEnd;++aIter,++i) { if(xKeyColumns.is() && xKeyColumns->hasByName(aIter->first)) { - aSql += ::dbtools::quoteName( aQuote,aIter->first); + aSql.append(::dbtools::quoteName( aQuote,aIter->first)); if((_rDeleteRow->get())[aIter->second.nPosition].isNull()) { OSL_ENSURE(0,"can a primary key be null"); - aSql += ::rtl::OUString::createFromAscii(" IS NULL"); + aSql.append(::rtl::OUString::createFromAscii(" IS NULL")); } else - aSql += ::rtl::OUString::createFromAscii(" = ?"); - aSql += aAnd; + aSql.append(::rtl::OUString::createFromAscii(" = ?")); + aSql.append(aAnd); } else { + ::std::vector< Reference<XNameAccess> >::const_iterator aIndexEnd = aAllIndexColumns.end(); for( ::std::vector< Reference<XNameAccess> >::const_iterator aIndexIter = aAllIndexColumns.begin(); - aIndexIter != aAllIndexColumns.end();++aIndexIter) + aIndexIter != aIndexEnd;++aIndexIter) { if((*aIndexIter)->hasByName(aIter->first)) { - sIndexCondition += ::dbtools::quoteName( aQuote,aIter->first); + sIndexCondition.append(::dbtools::quoteName( aQuote,aIter->first)); if((_rDeleteRow->get())[aIter->second.nPosition].isNull()) - sIndexCondition += ::rtl::OUString::createFromAscii(" IS NULL"); + sIndexCondition.append(::rtl::OUString::createFromAscii(" IS NULL")); else { - sIndexCondition += ::rtl::OUString::createFromAscii(" = ?"); + sIndexCondition.append(::rtl::OUString::createFromAscii(" = ?")); aIndexColumnPositions.push_back(aIter->second.nPosition); } - sIndexCondition += aAnd; + sIndexCondition.append(aAnd); break; } } } } - aSql += sIndexCondition; - aSql = aSql.replaceAt(aSql.getLength()-5,5,::rtl::OUString::createFromAscii(" ")); + aSql.append(sIndexCondition.makeStringAndClear()); + aSql.setLength(aSql.getLength()-5); // now create end execute the prepared statement - Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(aSql)); + Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(aSql.makeStringAndClear())); Reference< XParameters > xParameter(xPrep,UNO_QUERY); aIter = (*m_pKeyColumnNames).begin(); + aEnd = (*m_pKeyColumnNames).end(); i = 1; - for(;aIter != (*m_pKeyColumnNames).end();++aIter,++i) + for(;aIter != aEnd;++aIter,++i) { setParameter(i,xParameter,(_rDeleteRow->get())[aIter->second.nPosition],aIter->second.nType,aIter->second.nScale); } // now we have to set the index values ::std::vector<sal_Int32>::iterator aIdxColIter = aIndexColumnPositions.begin(); - for(;aIdxColIter != aIndexColumnPositions.end();++aIdxColIter,++i) + ::std::vector<sal_Int32>::iterator aIdxColEnd = aIndexColumnPositions.end(); + for(;aIdxColIter != aIdxColEnd;++aIdxColIter,++i) { setParameter(i,xParameter,(_rDeleteRow->get())[*aIdxColIter],(_rDeleteRow->get())[*aIdxColIter].getTypeKind(),aIter->second.nScale); } @@ -1109,12 +1131,20 @@ void SAL_CALL OKeySet::refreshRow() throw(SQLException, RuntimeException) OSL_ENSURE(xParameter.is(),"No Parameter interface!"); xParameter->clearParameters(); sal_Int32 nPos=1; + connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aParaIter = m_aParameterValueForCache.get().begin(); + connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aParaEnd = m_aParameterValueForCache.get().end(); + for(++aParaIter;aParaIter != aParaEnd;++aParaIter,++nPos) + { + ::dbtools::setObjectWithInfo( xParameter, nPos, aParaIter->makeAny(), aParaIter->getTypeKind() ); + } connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aIter = m_aKeyIter->second.first->get().begin(); SelectColumnsMetaData::const_iterator aPosIter = (*m_pKeyColumnNames).begin(); - for(;aPosIter != (*m_pKeyColumnNames).end();++aPosIter,++aIter,++nPos) + SelectColumnsMetaData::const_iterator aPosEnd = (*m_pKeyColumnNames).end(); + for(;aPosIter != aPosEnd;++aPosIter,++aIter,++nPos) setParameter(nPos,xParameter,*aIter,aPosIter->second.nType,aPosIter->second.nScale); aPosIter = (*m_pForeignColumnNames).begin(); - for(;aPosIter != (*m_pForeignColumnNames).end();++aPosIter,++aIter,++nPos) + aPosEnd = (*m_pForeignColumnNames).end(); + for(;aPosIter != aPosEnd;++aPosIter,++aIter,++nPos) setParameter(nPos,xParameter,*aIter,aPosIter->second.nType,aPosIter->second.nScale); m_xSet = m_xStatement->executeQuery(); @@ -1146,7 +1176,7 @@ sal_Bool OKeySet::fetchRow() } // now fetch the values from the missing columns from other tables aPosIter = (*m_pForeignColumnNames).begin(); - aPosEnd = (*m_pForeignColumnNames).end(); + aPosEnd = (*m_pForeignColumnNames).end(); for(;aPosIter != aPosEnd;++aPosIter,++aIter) { const SelectColumnDescription& rColDesc = aPosIter->second; diff --git a/dbaccess/source/core/api/KeySet.hxx b/dbaccess/source/core/api/KeySet.hxx index 35716d0b9..3bda294c1 100644 --- a/dbaccess/source/core/api/KeySet.hxx +++ b/dbaccess/source/core/api/KeySet.hxx @@ -97,6 +97,7 @@ namespace dbaccess ::std::vector< ::rtl::OUString > m_aAutoColumns; // contains all columns which are autoincrement ones + ORowSetValueVector m_aParameterValueForCache; SelectColumnsMetaData* m_pKeyColumnNames; // contains all key column names SelectColumnsMetaData* m_pColumnNames; // contains all column names SelectColumnsMetaData* m_pForeignColumnNames; // contains all column names of the rest @@ -139,7 +140,8 @@ namespace dbaccess OKeySet(const connectivity::OSQLTable& _xTable, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& _xTableKeys, const ::rtl::OUString& _rUpdateTableName, - const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryAnalyzer >& _xComposer); + const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryAnalyzer >& _xComposer, + const ORowSetValueVector& _aParameterValueForCache); // late ctor which can throw exceptions virtual void construct(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _xDriverSet); diff --git a/dbaccess/source/core/api/RowSet.cxx b/dbaccess/source/core/api/RowSet.cxx index e84b69620..1a0a6cbbc 100644 --- a/dbaccess/source/core/api/RowSet.cxx +++ b/dbaccess/source/core/api/RowSet.cxx @@ -657,7 +657,8 @@ void ORowSet::freeResources( bool _bComplete ) MutexGuard aGuard(m_aMutex); // free all clones - for (connectivity::OWeakRefArray::iterator i = m_aClones.begin(); m_aClones.end() != i; i++) + connectivity::OWeakRefArray::iterator aEnd = m_aClones.end(); + for (connectivity::OWeakRefArray::iterator i = m_aClones.begin(); aEnd != i; i++) { Reference< XComponent > xComp(i->get(), UNO_QUERY); if (xComp.is()) @@ -1715,13 +1716,14 @@ Reference< XResultSet > ORowSet::impl_prepareAndExecute_throw() // this exception doesn't matter here because when we catch an exception // then the driver doesn't support this feature } - + m_aParameterValueForCache.get().resize(1); Reference< XParameters > xParam( m_xStatement, UNO_QUERY_THROW ); size_t nParamCount( m_pParameters.is() ? m_pParameters->size() : m_aPrematureParamValues.get().size() ); for ( size_t i=1; i<=nParamCount; ++i ) { ORowSetValue& rParamValue( getParameterStorage( (sal_Int32)i ) ); ::dbtools::setObjectWithInfo( xParam, i, rParamValue.makeAny(), rParamValue.getTypeKind() ); + m_aParameterValueForCache.get().push_back(rParamValue); } xResultSet = m_xStatement->executeQuery(); @@ -1863,7 +1865,7 @@ void ORowSet::execute_NoApprove_NoNewConn(ResettableMutexGuard& _rClearForNotifi { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "frank.schoenheit@sun.com", "ORowSet::execute_NoApprove_NoNewConn: creating cache" ); - m_pCache = new ORowSetCache( xResultSet, m_xComposer.get(), m_aContext, aComposedUpdateTableName, m_bModified, m_bNew ); + m_pCache = new ORowSetCache( xResultSet, m_xComposer.get(), m_aContext, aComposedUpdateTableName, m_bModified, m_bNew,m_aParameterValueForCache ); if ( m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY ) { m_nPrivileges = Privilege::SELECT; @@ -2152,7 +2154,8 @@ void ORowSet::notifyRowSetAndClonesRowDelete( const Any& _rBookmark ) // notify ourself onDeleteRow( _rBookmark ); // notify the clones - for (connectivity::OWeakRefArray::iterator i = m_aClones.begin(); m_aClones.end() != i; i++) + connectivity::OWeakRefArray::iterator aEnd = m_aClones.end(); + for (connectivity::OWeakRefArray::iterator i = m_aClones.begin(); aEnd != i; i++) { Reference< XUnoTunnel > xTunnel(i->get(),UNO_QUERY); if(xTunnel.is()) @@ -2169,7 +2172,8 @@ void ORowSet::notifyRowSetAndClonesRowDeleted( const Any& _rBookmark, sal_Int32 // notify ourself onDeletedRow( _rBookmark, _nPos ); // notify the clones - for (connectivity::OWeakRefArray::iterator i = m_aClones.begin(); m_aClones.end() != i; i++) + connectivity::OWeakRefArray::iterator aEnd = m_aClones.end(); + for (connectivity::OWeakRefArray::iterator i = m_aClones.begin(); aEnd != i; i++) { Reference< XUnoTunnel > xTunnel(i->get(),UNO_QUERY); if(xTunnel.is()) @@ -2822,7 +2826,6 @@ ORowSetClone::ORowSetClone( const ::comphelper::ComponentContext& _rContext, ORo rParent.m_pColumns->getByName(*pIter) >>= xColumn; if(xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_DESCRIPTION)) aDescription = comphelper::getString(xColumn->getPropertyValue(PROPERTY_DESCRIPTION)); - ORowSetColumn* pColumn = new ORowSetColumn( rParent.getMetaData(), this, i, @@ -2856,7 +2859,7 @@ ORowSetClone::ORowSetClone( const ::comphelper::ComponentContext& _rContext, ORo // sdb.RowSet Properties // registerProperty(PROPERTY_CURSORNAME, PROPERTY_ID_CURSORNAME, PropertyAttribute::READONLY, &m_aDataSourceName, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL))); - + registerMayBeVoidProperty(PROPERTY_ACTIVE_CONNECTION,PROPERTY_ID_ACTIVE_CONNECTION, PropertyAttribute::MAYBEVOID|PropertyAttribute::READONLY, &rParent.m_aActiveConnection, ::getCppuType(reinterpret_cast< Reference< XConnection >* >(NULL))); registerProperty(PROPERTY_RESULTSETCONCURRENCY, PROPERTY_ID_RESULTSETCONCURRENCY, PropertyAttribute::READONLY, &m_nResultSetConcurrency,::getCppuType(reinterpret_cast< sal_Int32*>(NULL))); registerProperty(PROPERTY_RESULTSETTYPE, PROPERTY_ID_RESULTSETTYPE, PropertyAttribute::READONLY, &m_nResultSetType, ::getCppuType(reinterpret_cast< sal_Int32*>(NULL))); registerProperty(PROPERTY_FETCHDIRECTION, PROPERTY_ID_FETCHDIRECTION, PropertyAttribute::TRANSIENT, &m_nFetchDirection, ::getCppuType(reinterpret_cast< sal_Int32*>(NULL))); diff --git a/dbaccess/source/core/api/RowSet.hxx b/dbaccess/source/core/api/RowSet.hxx index 01dce838f..278ffa611 100644 --- a/dbaccess/source/core/api/RowSet.hxx +++ b/dbaccess/source/core/api/RowSet.hxx @@ -133,6 +133,7 @@ namespace dbaccess (since we have not been executed, yet) */ ORowSetValueVector m_aPrematureParamValues; + ORowSetValueVector m_aParameterValueForCache; ::std::bit_vector m_aParametersSet; ::cppu::OInterfaceContainerHelper m_aRowsetListeners; diff --git a/dbaccess/source/core/api/RowSetBase.cxx b/dbaccess/source/core/api/RowSetBase.cxx index d9530cb86..bbd2e825a 100644 --- a/dbaccess/source/core/api/RowSetBase.cxx +++ b/dbaccess/source/core/api/RowSetBase.cxx @@ -226,7 +226,10 @@ void SAL_CALL ORowSetBase::disposing(void) m_pColumns->disposing(); } if ( m_pCache ) + { m_pCache->deregisterOldRow(m_aOldRow); + m_pCache->deleteIterator(this); + } m_pCache = NULL; } // ------------------------------------------------------------------------- @@ -1322,7 +1325,8 @@ void ORowSetBase::firePropertyChange(const ORowSetRow& _rOldRow) sal_Int32 i=0; try { - for(TDataColumns::iterator aIter = m_aDataColumns.begin();aIter != m_aDataColumns.end();++aIter,++i) // #104278# OJ ++i inserted + TDataColumns::iterator aEnd = m_aDataColumns.end(); + for(TDataColumns::iterator aIter = m_aDataColumns.begin();aIter != aEnd;++aIter,++i) // #104278# OJ ++i inserted (*aIter)->fireValueChange(_rOldRow.isValid() ? (_rOldRow->get())[i+1] : ::connectivity::ORowSetValue()); } catch(Exception&) diff --git a/dbaccess/source/core/api/RowSetCache.cxx b/dbaccess/source/core/api/RowSetCache.cxx index 1ee01cd63..91ba4a0c7 100644 --- a/dbaccess/source/core/api/RowSetCache.cxx +++ b/dbaccess/source/core/api/RowSetCache.cxx @@ -31,36 +31,89 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_dbaccess.hxx" +#ifndef _COMPHELPER_SEQSTREAM_HXX #include <comphelper/seqstream.hxx> +#endif +#ifndef _COMPHELPER_UNO3_HXX_ #include <comphelper/uno3.hxx> +#endif +#ifndef _COMPHELPER_EXTRACT_HXX_ #include <comphelper/extract.hxx> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XKEYSSUPPLIER_HPP_ #include <com/sun/star/sdbcx/XKeysSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_ #include <com/sun/star/sdbcx/XTablesSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_KEYTYPE_HPP_ #include <com/sun/star/sdbcx/KeyType.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_RESULTSETCONCURRENCY_HPP_ #include <com/sun/star/sdbc/ResultSetConcurrency.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_ #include <com/sun/star/sdbc/ColumnValue.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_ #include <com/sun/star/sdbcx/XColumnsSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_PRIVILEGE_HPP_ #include <com/sun/star/sdbcx/Privilege.hpp> +#endif +#ifndef _DBACORE_DATACOLUMN_HXX_ #include "CRowSetDataColumn.hxx" +#endif +#ifndef DBACCESS_CORE_API_CROWSETCOLUMN_HXX #include "CRowSetColumn.hxx" +#endif +#ifndef DBACCESS_CORE_API_ROWSETBASE_HXX #include "RowSetBase.hxx" +#endif +#ifndef _DBHELPER_DBEXCEPTION_HXX_ #include <connectivity/dbexception.hxx> +#endif +#ifndef _CONNECTIVITY_SQLPARSE_HXX #include <connectivity/sqlparse.hxx> +#endif +#ifndef _CONNECTIVITY_SQLNODE_HXX #include <connectivity/sqlnode.hxx> +#endif +#ifndef _CONNECTIVITY_PARSE_SQLITERATOR_HXX_ #include <connectivity/sqliterator.hxx> +#endif +#ifndef _COMPHELPER_PROPERTY_HXX_ #include <comphelper/property.hxx> +#endif +#ifndef _COM_SUN_STAR_SDBCX_COMPAREBOOKMARK_HPP_ #include <com/sun/star/sdbcx/CompareBookmark.hpp> +#endif +#ifndef _TOOLS_DEBUG_HXX #include <tools/debug.hxx> +#endif #include <algorithm> +#ifndef DBACCESS_CORE_API_ROWSETCACHE_HXX #include "RowSetCache.hxx" +#endif +#ifndef _DBA_CORE_RESOURCE_HXX_ #include "core_resource.hxx" +#endif +#ifndef _DBA_CORE_RESOURCE_HRC_ #include "core_resource.hrc" +#endif +#ifndef DBACCESS_CORE_API_BOOKMARKSET_HXX #include "BookmarkSet.hxx" +#endif +#ifndef DBACCESS_CORE_API_STATICSET_HXX #include "StaticSet.hxx" +#endif +#ifndef DBACCESS_CORE_API_KEYSET_HXX #include "KeySet.hxx" +#endif +#ifndef DBACCESS_SHARED_DBASTRINGS_HRC #include "dbastrings.hrc" -#include <rtl/logfile.hxx> +#endif using namespace dbaccess; using namespace dbtools; @@ -84,7 +137,8 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs, const ::comphelper::ComponentContext& _rContext, const ::rtl::OUString& _rUpdateTableName, sal_Bool& _bModified, - sal_Bool& _bNew) + sal_Bool& _bNew, + const ORowSetValueVector& _aParameterValueForCache) :m_xSet(_xRs) ,m_xMetaData(Reference< XResultSetMetaDataSupplier >(_xRs,UNO_QUERY)->getMetaData()) ,m_aContext( _rContext ) @@ -105,7 +159,6 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs, ,m_bModified(_bModified) ,m_bNew(_bNew) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::ORowSetCache" ); DBG_CTOR(ORowSetCache,NULL); // check if all keys of the updateable table are fetched @@ -194,18 +247,41 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs, } Reference< XPropertySet> xProp(_xRs,UNO_QUERY); - sal_Bool bBookmarkable = xProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_ISBOOKMARKABLE) && - any2bool(xProp->getPropertyValue(PROPERTY_ISBOOKMARKABLE)) && Reference< XRowLocate >(_xRs, UNO_QUERY).is(); - sal_Bool bNeedKeySet = !bBookmarkable; + sal_Bool bNeedKeySet = !(xProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_ISBOOKMARKABLE) && + any2bool(xProp->getPropertyValue(PROPERTY_ISBOOKMARKABLE)) && Reference< XRowLocate >(_xRs, UNO_QUERY).is() ); bNeedKeySet = bNeedKeySet || (xProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_RESULTSETCONCURRENCY) && ::comphelper::getINT32(xProp->getPropertyValue(PROPERTY_RESULTSETCONCURRENCY)) == ResultSetConcurrency::READ_ONLY); // first check if resultset is bookmarkable - if ( !bNeedKeySet ) + if(!bNeedKeySet) { - bNeedKeySet = impl_createBookmarkSet_nothrow(_xRs); + try + { + m_pCacheSet = new OBookmarkSet(); + m_xCacheSet = m_pCacheSet; + m_pCacheSet->construct(_xRs); + + // check privileges + m_nPrivileges = Privilege::SELECT; + if(Reference<XResultSetUpdate>(_xRs,UNO_QUERY).is()) // this interface is optional so we have to check it + { + Reference<XPropertySet> xTable(m_aUpdateTable,UNO_QUERY); + if(xTable.is() && xTable->getPropertySetInfo()->hasPropertyByName(PROPERTY_PRIVILEGES)) + { + m_nPrivileges = 0; + xTable->getPropertyValue(PROPERTY_PRIVILEGES) >>= m_nPrivileges; + if(!m_nPrivileges) + m_nPrivileges = Privilege::SELECT; + } + } + } + catch(const SQLException&) + { + bNeedKeySet = sal_True; + } + } - if ( bNeedKeySet ) + if(bNeedKeySet) { // need to check if we could handle this select clause bAllKeysFound = bAllKeysFound && (nTablesCount == 1 || checkJoin(xConnection,_xAnalyzer,aUpdateTableName)); @@ -213,16 +289,11 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs, // || !(comphelper::hasProperty(PROPERTY_CANUPDATEINSERTEDROWS,xProp) && any2bool(xProp->getPropertyValue(PROPERTY_CANUPDATEINSERTEDROWS))) // oj removed because keyset uses only the next// || (xProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_RESULTSETTYPE) && comphelper::getINT32(xProp->getPropertyValue(PROPERTY_RESULTSETTYPE)) == ResultSetType::FORWARD_ONLY) - if ( !bAllKeysFound ) + if(!bAllKeysFound ) { - if ( bBookmarkable ) - impl_createBookmarkSet_nothrow(_xRs); - else - { - m_pCacheSet = new OStaticSet(); - m_xCacheSet = m_pCacheSet; - m_pCacheSet->construct(_xRs); - } + m_pCacheSet = new OStaticSet(); + m_xCacheSet = m_pCacheSet; + m_pCacheSet->construct(_xRs); m_nPrivileges = Privilege::SELECT; } else @@ -258,7 +329,7 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs, } } - OKeySet* pKeySet = new OKeySet(m_aUpdateTable,xUpdateTableKeys,aUpdateTableName ,_xAnalyzer); + OKeySet* pKeySet = new OKeySet(m_aUpdateTable,xUpdateTableKeys,aUpdateTableName ,_xAnalyzer,_aParameterValueForCache); try { m_pCacheSet = pKeySet; @@ -298,6 +369,7 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs, ::comphelper::getINT32(xProp->getPropertyValue(PROPERTY_RESULTSETCONCURRENCY)) == ResultSetConcurrency::READ_ONLY) m_nPrivileges = Privilege::SELECT; } + // ------------------------------------------------------------------------- ORowSetCache::~ORowSetCache() { @@ -320,40 +392,10 @@ ORowSetCache::~ORowSetCache() DBG_DTOR(ORowSetCache,NULL); } -// ----------------------------------------------------------------------------- -sal_Bool ORowSetCache::impl_createBookmarkSet_nothrow(const Reference< XResultSet >& _xRs) -{ - sal_Bool bRet = sal_False; - try - { - m_pCacheSet = new OBookmarkSet(); - m_xCacheSet = m_pCacheSet; - m_pCacheSet->construct(_xRs); - // check privileges - m_nPrivileges = Privilege::SELECT; - if(Reference<XResultSetUpdate>(_xRs,UNO_QUERY).is()) // this interface is optional so we have to check it - { - Reference<XPropertySet> xTable(m_aUpdateTable,UNO_QUERY); - if(xTable.is() && xTable->getPropertySetInfo()->hasPropertyByName(PROPERTY_PRIVILEGES)) - { - m_nPrivileges = 0; - xTable->getPropertyValue(PROPERTY_PRIVILEGES) >>= m_nPrivileges; - if(!m_nPrivileges) - m_nPrivileges = Privilege::SELECT; - } - } - } - catch(const SQLException&) - { - bRet = sal_True; - } - return bRet; -} // ------------------------------------------------------------------------- void ORowSetCache::setMaxRowSize(sal_Int32 _nSize) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::setMaxRowSize" ); if(_nSize == m_nFetchSize) return; @@ -375,7 +417,8 @@ void ORowSetCache::setMaxRowSize(sal_Int32 _nSize) ::std::map<sal_Int32,sal_Bool> aCacheIterToChange; // first get the positions where they stand now ORowSetCacheMap::iterator aCacheIter = m_aCacheIterators.begin(); - for(;aCacheIter != m_aCacheIterators.end();++aCacheIter) + ORowSetCacheMap::iterator aCacheEnd = m_aCacheIterators.end(); + for(;aCacheIter != aCacheEnd;++aCacheIter) { aCacheIterToChange[aCacheIter->first] = sal_False; if ( !aCacheIter->second.pRowSet->isInsertRow() @@ -425,14 +468,12 @@ void ORowSetCache::setMaxRowSize(sal_Int32 _nSize) // XResultSetMetaDataSupplier Reference< XResultSetMetaData > ORowSetCache::getMetaData( ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::getMetaData" ); return m_xMetaData; } // ------------------------------------------------------------------------- // ::com::sun::star::sdbcx::XRowLocate Any ORowSetCache::getBookmark( ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::getBookmark" ); if(m_bAfterLast) throwFunctionSequenceException(m_xSet.get()); @@ -457,7 +498,6 @@ Any ORowSetCache::getBookmark( ) // ------------------------------------------------------------------------- sal_Bool ORowSetCache::moveToBookmark( const Any& bookmark ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::moveToBookmark" ); if ( m_pCacheSet->moveToBookmark(bookmark) ) { m_bBeforeFirst = sal_False; @@ -488,7 +528,6 @@ sal_Bool ORowSetCache::moveToBookmark( const Any& bookmark ) // ------------------------------------------------------------------------- sal_Bool ORowSetCache::moveRelativeToBookmark( const Any& bookmark, sal_Int32 rows ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::moveRelativeToBookmark" ); sal_Bool bRet( moveToBookmark( bookmark ) ); if ( bRet ) { @@ -504,20 +543,17 @@ sal_Bool ORowSetCache::moveRelativeToBookmark( const Any& bookmark, sal_Int32 ro // ------------------------------------------------------------------------- sal_Int32 ORowSetCache::compareBookmarks( const Any& _first, const Any& _second ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::compareBookmarks" ); return (!_first.hasValue() || !_second.hasValue()) ? CompareBookmark::NOT_COMPARABLE : m_pCacheSet->compareBookmarks(_first,_second); } // ------------------------------------------------------------------------- sal_Bool ORowSetCache::hasOrderedBookmarks( ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::hasOrderedBookmarks" ); return m_pCacheSet->hasOrderedBookmarks(); } // ------------------------------------------------------------------------- sal_Int32 ORowSetCache::hashBookmark( const Any& bookmark ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::hashBookmark" ); return m_pCacheSet->hashBookmark(bookmark); } @@ -526,7 +562,6 @@ sal_Int32 ORowSetCache::hashBookmark( const Any& bookmark ) // ----------------------------------------------------------------------------- void ORowSetCache::updateValue(sal_Int32 columnIndex,const ORowSetValue& x) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::updateValue" ); checkUpdateConditions(columnIndex); @@ -537,7 +572,6 @@ void ORowSetCache::updateValue(sal_Int32 columnIndex,const ORowSetValue& x) // ------------------------------------------------------------------------- void ORowSetCache::updateBinaryStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::updateBinaryStream" ); checkUpdateConditions(columnIndex); @@ -549,7 +583,6 @@ void ORowSetCache::updateBinaryStream( sal_Int32 columnIndex, const Reference< : // ------------------------------------------------------------------------- void ORowSetCache::updateCharacterStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::updateCharacterStream" ); checkUpdateConditions(columnIndex); @@ -562,7 +595,6 @@ void ORowSetCache::updateCharacterStream( sal_Int32 columnIndex, const Reference // ------------------------------------------------------------------------- void ORowSetCache::updateObject( sal_Int32 columnIndex, const Any& x ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::updateObject" ); checkUpdateConditions(columnIndex); @@ -573,7 +605,6 @@ void ORowSetCache::updateObject( sal_Int32 columnIndex, const Any& x ) // ------------------------------------------------------------------------- void ORowSetCache::updateNumericObject( sal_Int32 columnIndex, const Any& x, sal_Int32 /*scale*/ ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::updateNumericObject" ); checkUpdateConditions(columnIndex); @@ -585,7 +616,6 @@ void ORowSetCache::updateNumericObject( sal_Int32 columnIndex, const Any& x, sal // XResultSet sal_Bool ORowSetCache::next( ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::next" ); if(!isAfterLast()) @@ -610,7 +640,6 @@ sal_Bool ORowSetCache::next( ) // ------------------------------------------------------------------------- sal_Bool ORowSetCache::isBeforeFirst( ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::isBeforeFirst" ); // return !m_nPosition; return m_bBeforeFirst; @@ -618,21 +647,18 @@ sal_Bool ORowSetCache::isBeforeFirst( ) // ------------------------------------------------------------------------- sal_Bool ORowSetCache::isAfterLast( ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::isAfterLast" ); return m_bAfterLast; } // ------------------------------------------------------------------------- sal_Bool ORowSetCache::isFirst( ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::isFirst" ); return m_nPosition == 1; // ask resultset for } // ------------------------------------------------------------------------- sal_Bool ORowSetCache::isLast( ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::isLast" ); // return m_bRowCountFinal ? (m_nPosition==m_nRowCount) : m_pCacheSet->isLast(); return m_nPosition == m_nRowCount; @@ -640,7 +666,6 @@ sal_Bool ORowSetCache::isLast( ) // ------------------------------------------------------------------------- sal_Bool ORowSetCache::beforeFirst( ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::beforeFirst" ); if(!m_bBeforeFirst) @@ -657,7 +682,6 @@ sal_Bool ORowSetCache::beforeFirst( ) // ------------------------------------------------------------------------- sal_Bool ORowSetCache::afterLast( ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::afterLast" ); if(!m_bAfterLast) @@ -681,12 +705,10 @@ sal_Bool ORowSetCache::afterLast( ) // ------------------------------------------------------------------------- sal_Bool ORowSetCache::fillMatrix(sal_Int32& _nNewStartPos,sal_Int32 _nNewEndPos) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::fillMatrix" ); OSL_ENSURE(_nNewStartPos != _nNewEndPos,"ORowSetCache::fillMatrix: StartPos and EndPos can not be equal!"); // fill the whole window with new data ORowSetMatrix::iterator aIter = m_pMatrix->begin(); sal_Bool bCheck = m_pCacheSet->absolute(_nNewStartPos); // -1 no need to - const sal_Int32 nColumnCount = m_xMetaData->getColumnCount(); sal_Int32 i=_nNewStartPos; for(;i<_nNewEndPos;++i,++aIter) @@ -694,7 +716,7 @@ sal_Bool ORowSetCache::fillMatrix(sal_Int32& _nNewStartPos,sal_Int32 _nNewEndPos if(bCheck) { if(!aIter->isValid()) - *aIter = new ORowSetValueVector(nColumnCount); + *aIter = new ORowSetValueVector(m_xMetaData->getColumnCount()); m_pCacheSet->fillValueRow(*aIter,i); } else @@ -711,22 +733,23 @@ sal_Bool ORowSetCache::fillMatrix(sal_Int32& _nNewStartPos,sal_Int32 _nNewEndPos if(m_nRowCount > m_nFetchSize) { ORowSetMatrix::iterator aEnd = aIter; + ORowSetMatrix::iterator aRealEnd = m_pMatrix->end(); sal_Int32 nPos = m_nRowCount - m_nFetchSize + 1; _nNewStartPos = nPos; bCheck = m_pCacheSet->absolute(_nNewStartPos); - for(;bCheck && aIter != m_pMatrix->end();++aIter) + for(;bCheck && aIter != aRealEnd;++aIter) { if(bCheck) { if(!aIter->isValid()) - *aIter = new ORowSetValueVector(nColumnCount); + *aIter = new ORowSetValueVector(m_xMetaData->getColumnCount()); m_pCacheSet->fillValueRow(*aIter,nPos++); } bCheck = m_pCacheSet->next(); } if(aIter != aEnd) - ::std::rotate(m_pMatrix->begin(),aEnd,m_pMatrix->end()); + ::std::rotate(m_pMatrix->begin(),aEnd,aRealEnd); } break; } @@ -752,7 +775,6 @@ sal_Bool ORowSetCache::fillMatrix(sal_Int32& _nNewStartPos,sal_Int32 _nNewEndPos // ------------------------------------------------------------------------- sal_Bool ORowSetCache::moveWindow() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::moveWindow" ); sal_Bool bRet = sal_True; @@ -803,7 +825,8 @@ sal_Bool ORowSetCache::moveWindow() ptrdiff_t nNewDist = aEnd - m_pMatrix->begin(); ptrdiff_t nOffSet = m_pMatrix->end() - aEnd; ORowSetCacheMap::iterator aCacheIter = m_aCacheIterators.begin(); - for(;aCacheIter != m_aCacheIterators.end();++aCacheIter) + ORowSetCacheMap::iterator aCacheEnd = m_aCacheIterators.end(); + for(;aCacheIter != aCacheEnd;++aCacheIter) { if ( !aCacheIter->second.pRowSet->isInsertRow() && aCacheIter->second.aIterator != m_pMatrix->end() && !m_bModified ) @@ -990,7 +1013,6 @@ sal_Bool ORowSetCache::moveWindow() // ------------------------------------------------------------------------- sal_Bool ORowSetCache::first( ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::first" ); // first move to the first row // then check if the cache window is at the begining // when not postionize the window and fill it with data @@ -1016,7 +1038,6 @@ sal_Bool ORowSetCache::first( ) // ------------------------------------------------------------------------- sal_Bool ORowSetCache::last( ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::last" ); sal_Bool bRet = m_pCacheSet->last(); if(bRet) { @@ -1056,13 +1077,11 @@ sal_Bool ORowSetCache::last( ) // ------------------------------------------------------------------------- sal_Int32 ORowSetCache::getRow( ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::getRow" ); return (isBeforeFirst() || isAfterLast()) ? 0 : m_nPosition; } // ------------------------------------------------------------------------- sal_Bool ORowSetCache::absolute( sal_Int32 row ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::absolute" ); if(!row ) throw SQLException(DBACORE_RESSTRING(RID_STR_NO_ABS_ZERO),NULL,SQLSTATE_GENERAL,1000,Any() ); @@ -1116,7 +1135,6 @@ sal_Bool ORowSetCache::absolute( sal_Int32 row ) // ------------------------------------------------------------------------- sal_Bool ORowSetCache::relative( sal_Int32 rows ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::relative" ); sal_Bool bErg = sal_True; if(rows) { @@ -1145,7 +1163,6 @@ sal_Bool ORowSetCache::relative( sal_Int32 rows ) // ------------------------------------------------------------------------- sal_Bool ORowSetCache::previous( ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::previous" ); sal_Bool bRet = sal_False; if(!isBeforeFirst()) { @@ -1177,7 +1194,6 @@ sal_Bool ORowSetCache::previous( ) // ------------------------------------------------------------------------- void ORowSetCache::refreshRow( ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::refreshRow" ); if(isAfterLast()) throw SQLException(DBACORE_RESSTRING(RID_STR_NO_REFESH_AFTERLAST),NULL,SQLSTATE_GENERAL,1000,Any() ); OSL_ENSURE(m_aMatrixIter != m_pMatrix->end(),"refreshRow() called for invalid row!"); @@ -1191,20 +1207,17 @@ void ORowSetCache::refreshRow( ) // ------------------------------------------------------------------------- sal_Bool ORowSetCache::rowUpdated( ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::rowUpdated" ); return m_pCacheSet->rowUpdated(); } // ------------------------------------------------------------------------- sal_Bool ORowSetCache::rowInserted( ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::rowInserted" ); return m_pCacheSet->rowInserted(); } // ------------------------------------------------------------------------- // XResultSetUpdate sal_Bool ORowSetCache::insertRow( ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::insertRow" ); if ( !m_bNew || !m_aInsertRow->isValid() ) throw SQLException(DBACORE_RESSTRING(RID_STR_NO_MOVETOINSERTROW_CALLED),NULL,SQLSTATE_GENERAL,1000,Any() ); @@ -1228,7 +1241,6 @@ sal_Bool ORowSetCache::insertRow( ) // ------------------------------------------------------------------------- void ORowSetCache::resetInsertRow(sal_Bool _bClearInsertRow) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::resetInsertRow" ); if ( _bClearInsertRow ) clearInsertRow(); m_bNew = sal_False; @@ -1237,7 +1249,6 @@ void ORowSetCache::resetInsertRow(sal_Bool _bClearInsertRow) // ------------------------------------------------------------------------- void ORowSetCache::cancelRowModification() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::cancelRowModification" ); // clear the insertrow references -> implies that the current row of the rowset changes as well ORowSetCacheMap::iterator aCacheIter = m_aCacheIterators.begin(); ORowSetCacheMap::iterator aCacheEnd = m_aCacheIterators.end(); @@ -1251,7 +1262,6 @@ void ORowSetCache::cancelRowModification() // ------------------------------------------------------------------------- void ORowSetCache::updateRow( ORowSetMatrix::iterator& _rUpdateRow ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::updateRow" ); if(isAfterLast() || isBeforeFirst()) throw SQLException(DBACORE_RESSTRING(RID_STR_NO_UPDATEROW),NULL,SQLSTATE_GENERAL,1000,Any() ); @@ -1275,7 +1285,6 @@ void ORowSetCache::updateRow( ORowSetMatrix::iterator& _rUpdateRow ) // ------------------------------------------------------------------------- bool ORowSetCache::deleteRow( ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::deleteRow" ); if(isAfterLast() || isBeforeFirst()) throw SQLException(DBACORE_RESSTRING(RID_STR_NO_DELETEROW),NULL,SQLSTATE_GENERAL,1000,Any() ); @@ -1291,7 +1300,8 @@ bool ORowSetCache::deleteRow( ) // (*m_pMatrix)[(m_nPosition - m_nStartPos)] = NULL; // set the deleted row to NULL - for(++aPos;aPos != m_pMatrix->end() && aPos->isValid();++aPos) + ORowSetMatrix::iterator aEnd = m_pMatrix->end(); + for(++aPos;aPos != aEnd && aPos->isValid();++aPos) { *(aPos-1) = *aPos; (*aPos) = NULL; @@ -1304,7 +1314,6 @@ bool ORowSetCache::deleteRow( ) // ------------------------------------------------------------------------- void ORowSetCache::cancelRowUpdates( ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::cancelRowUpdates" ); m_bNew = m_bModified = sal_False; if(!m_nPosition) { @@ -1323,7 +1332,6 @@ void ORowSetCache::cancelRowUpdates( ) // ------------------------------------------------------------------------- void ORowSetCache::moveToInsertRow( ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::moveToInsertRow" ); m_bNew = sal_True; m_bUpdated = m_bAfterLast = sal_False; @@ -1333,7 +1341,8 @@ void ORowSetCache::moveToInsertRow( ) // we don't unbound the bookmark column ORowSetValueVector::Vector::iterator aIter = (*m_aInsertRow)->get().begin()+1; - for(;aIter != (*m_aInsertRow)->get().end();++aIter) + ORowSetValueVector::Vector::iterator aEnd = (*m_aInsertRow)->get().end(); + for(;aIter != aEnd;++aIter) { aIter->setBound(sal_False); aIter->setModified(sal_False); @@ -1343,7 +1352,6 @@ void ORowSetCache::moveToInsertRow( ) // ------------------------------------------------------------------------- ORowSetCacheIterator ORowSetCache::createIterator(ORowSetBase* _pRowSet) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::createIterator" ); ORowSetCacheIterator_Helper aHelper; aHelper.aIterator = m_pMatrix->end(); @@ -1351,14 +1359,29 @@ ORowSetCacheIterator ORowSetCache::createIterator(ORowSetBase* _pRowSet) return ORowSetCacheIterator(m_aCacheIterators.insert(m_aCacheIterators.begin(),ORowSetCacheMap::value_type(m_aCacheIterators.size()+1,aHelper)),this,_pRowSet); } // ----------------------------------------------------------------------------- +void ORowSetCache::deleteIterator(const ORowSetBase* _pRowSet) +{ + ORowSetCacheMap::iterator aCacheIter = m_aCacheIterators.begin(); + for(;aCacheIter != m_aCacheIterators.end();) + { + if ( aCacheIter->second.pRowSet == _pRowSet ) + { + m_aCacheIterators.erase(aCacheIter); + aCacheIter = m_aCacheIterators.begin(); + } // if ( aCacheIter->second.pRowSet == _pRowSet ) + else + ++aCacheIter; + } +} +// ----------------------------------------------------------------------------- void ORowSetCache::rotateCacheIterator(ORowSetMatrix::difference_type _nDist) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::rotateCacheIterator" ); if(_nDist) { // now correct the iterator in our iterator vector ORowSetCacheMap::iterator aCacheIter = m_aCacheIterators.begin(); - for(;aCacheIter != m_aCacheIterators.end();++aCacheIter) + ORowSetCacheMap::iterator aCacheEnd = m_aCacheIterators.end(); + for(;aCacheIter != aCacheEnd;++aCacheIter) { if ( !aCacheIter->second.pRowSet->isInsertRow() && aCacheIter->second.aIterator != m_pMatrix->end() && !m_bModified ) @@ -1382,7 +1405,6 @@ void ORowSetCache::rotateCacheIterator(ORowSetMatrix::difference_type _nDist) // ------------------------------------------------------------------------- void ORowSetCache::setUpdateIterator(const ORowSetMatrix::iterator& _rOriginalRow) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::setUpdateIterator" ); m_aInsertRow = m_pInsertMatrix->begin(); if(!m_aInsertRow->isValid()) *m_aInsertRow = new ORowSetValueVector(m_xMetaData->getColumnCount()); @@ -1390,13 +1412,13 @@ void ORowSetCache::setUpdateIterator(const ORowSetMatrix::iterator& _rOriginalRo (*(*m_aInsertRow)) = (*(*_rOriginalRow)); // we don't unbound the bookmark column ORowSetValueVector::Vector::iterator aIter = (*m_aInsertRow)->get().begin(); - for(;aIter != (*m_aInsertRow)->get().end();++aIter) + ORowSetValueVector::Vector::iterator aEnd = (*m_aInsertRow)->get().end(); + for(;aIter != aEnd;++aIter) aIter->setModified(sal_False); } // ----------------------------------------------------------------------------- void ORowSetCache::checkPositionFlags() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::checkPositionFlags" ); if(m_bRowCountFinal) { m_bAfterLast = m_nPosition > m_nRowCount; @@ -1407,14 +1429,12 @@ void ORowSetCache::checkPositionFlags() // ----------------------------------------------------------------------------- void ORowSetCache::checkUpdateConditions(sal_Int32 columnIndex) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::checkUpdateConditions" ); if(m_bAfterLast || columnIndex >= (sal_Int32)(*m_aInsertRow)->get().size()) throwFunctionSequenceException(m_xSet.get()); } //------------------------------------------------------------------------------ sal_Bool ORowSetCache::checkInnerJoin(const ::connectivity::OSQLParseNode *pNode,const Reference< XConnection>& _xConnection,const ::rtl::OUString& _sUpdateTableName) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::checkInnerJoin" ); sal_Bool bOk = sal_False; if (pNode->count() == 3 && // Ausdruck is geklammert SQL_ISPUNCTUATION(pNode->getChild(0),"(") && @@ -1456,7 +1476,6 @@ sal_Bool ORowSetCache::checkJoin(const Reference< XConnection>& _xConnection, const Reference< XSingleSelectQueryAnalyzer >& _xAnalyzer, const ::rtl::OUString& _sUpdateTableName ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::checkJoin" ); sal_Bool bOk = sal_False; ::rtl::OUString sSql = _xAnalyzer->getQuery(); ::rtl::OUString sErrorMsg; @@ -1515,7 +1534,6 @@ sal_Bool ORowSetCache::checkJoin(const Reference< XConnection>& _xConnection, // ----------------------------------------------------------------------------- void ORowSetCache::clearInsertRow() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::clearInsertRow" ); // we don't unbound the bookmark column if ( m_aInsertRow != m_pInsertMatrix->end() && m_aInsertRow->isValid() ) { @@ -1532,7 +1550,6 @@ void ORowSetCache::clearInsertRow() // ----------------------------------------------------------------------------- ORowSetMatrix::iterator ORowSetCache::calcPosition() const { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::calcPosition" ); sal_Int32 nValue = (m_nPosition - m_nStartPos) - 1; CHECK_MATRIX_POS(nValue); return ( nValue < 0 || nValue >= static_cast<sal_Int32>(m_pMatrix->size()) ) ? m_pMatrix->end() : (m_pMatrix->begin() + nValue); @@ -1541,7 +1558,6 @@ ORowSetMatrix::iterator ORowSetCache::calcPosition() const TORowSetOldRowHelperRef ORowSetCache::registerOldRow() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::registerOldRow" ); TORowSetOldRowHelperRef pRef = new ORowSetOldRowHelper(ORowSetRow()); m_aOldRows.push_back(pRef); return pRef; @@ -1549,8 +1565,8 @@ TORowSetOldRowHelperRef ORowSetCache::registerOldRow() // ----------------------------------------------------------------------------- void ORowSetCache::deregisterOldRow(const TORowSetOldRowHelperRef& _rRow) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::deregisterOldRow" ); - for (TOldRowSetRows::iterator aOldRowIter = m_aOldRows.begin(); aOldRowIter != m_aOldRows.end(); ++aOldRowIter) + TOldRowSetRows::iterator aOldRowEnd = m_aOldRows.end(); + for (TOldRowSetRows::iterator aOldRowIter = m_aOldRows.begin(); aOldRowIter != aOldRowEnd; ++aOldRowIter) { if ( aOldRowIter->getBodyPtr() == _rRow.getBodyPtr() ) { @@ -1563,8 +1579,8 @@ void ORowSetCache::deregisterOldRow(const TORowSetOldRowHelperRef& _rRow) // ----------------------------------------------------------------------------- sal_Bool ORowSetCache::reFillMatrix(sal_Int32 _nNewStartPos,sal_Int32 _nNewEndPos) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::reFillMatrix" ); - for (TOldRowSetRows::iterator aOldRowIter = m_aOldRows.begin(); aOldRowIter != m_aOldRows.end(); ++aOldRowIter) + TOldRowSetRows::iterator aOldRowEnd = m_aOldRows.end(); + for (TOldRowSetRows::iterator aOldRowIter = m_aOldRows.begin(); aOldRowIter != aOldRowEnd; ++aOldRowIter) { if ( aOldRowIter->isValid() && aOldRowIter->getBody().getRow().isValid() ) aOldRowIter->getBody().setRow(new ORowSetValueVector(aOldRowIter->getBody().getRow().getBody()) ); @@ -1578,7 +1594,6 @@ sal_Bool ORowSetCache::reFillMatrix(sal_Int32 _nNewStartPos,sal_Int32 _nNewEndPo // ----------------------------------------------------------------------------- sal_Bool ORowSetCache::fill(ORowSetMatrix::iterator& _aIter,const ORowSetMatrix::iterator& _aEnd,sal_Int32& _nPos,sal_Bool _bCheck) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::fill" ); sal_Int32 nColumnCount = m_xMetaData->getColumnCount(); for(; _bCheck && _aIter != _aEnd;) { @@ -1586,7 +1601,8 @@ sal_Bool ORowSetCache::fill(ORowSetMatrix::iterator& _aIter,const ORowSetMatrix: *_aIter = new ORowSetValueVector(nColumnCount); else { - for (TOldRowSetRows::iterator aOldRowIter = m_aOldRows.begin(); aOldRowIter != m_aOldRows.end(); ++aOldRowIter) + TOldRowSetRows::iterator aOldRowEnd = m_aOldRows.end(); + for (TOldRowSetRows::iterator aOldRowIter = m_aOldRows.begin(); aOldRowIter != aOldRowEnd; ++aOldRowIter) { if ( aOldRowIter->getBody().getRow().isEqualBody(*_aIter) ) *_aIter = new ORowSetValueVector(nColumnCount); diff --git a/dbaccess/source/core/api/RowSetCache.hxx b/dbaccess/source/core/api/RowSetCache.hxx index 9013bf394..94ea9822e 100644 --- a/dbaccess/source/core/api/RowSetCache.hxx +++ b/dbaccess/source/core/api/RowSetCache.hxx @@ -194,13 +194,15 @@ namespace dbaccess const ::comphelper::ComponentContext& _rContext, const ::rtl::OUString& _rUpdateTableName, sal_Bool& _bModified, - sal_Bool& _bNew); + sal_Bool& _bNew, + const ORowSetValueVector& _aParameterValueForCache); ~ORowSetCache(); // called from the rowset when a updateXXX was called for the first time void setUpdateIterator(const ORowSetMatrix::iterator& _rOriginalRow); ORowSetCacheIterator createIterator(ORowSetBase* _pRowSet); + void deleteIterator(const ORowSetBase* _pRowSet); // sets the size of the matrix void setMaxRowSize(sal_Int32 _nSize); diff --git a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx index ab952d356..574bd1778 100644 --- a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx +++ b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx @@ -262,7 +262,8 @@ OSingleSelectQueryComposer::~OSingleSelectQueryComposer() delete *aColIter; ::std::vector<OPrivateTables*>::iterator aTabIter = m_aTablesCollection.begin(); - for(;aTabIter != m_aTablesCollection.end();++aTabIter) + ::std::vector<OPrivateTables*>::iterator aTabEnd = m_aTablesCollection.end(); + for(;aTabIter != aTabEnd;++aTabIter) delete *aTabIter; } // ------------------------------------------------------------------------- @@ -572,14 +573,19 @@ void OSingleSelectQueryComposer::setSingleAdditiveClause( SQLPart _ePart, const *pComposer, getKeyword( _ePart ) ); // construct the complete statement - ::rtl::OUString aSql(m_aPureSelectSQL); + ::rtl::OUStringBuffer aSql(m_aPureSelectSQL); for ( SQLPart eLoopParts = Where; eLoopParts != SQLPartCount; incSQLPart( eLoopParts ) ) - aSql += aClauses[ eLoopParts ]; + aSql.append(aClauses[ eLoopParts ]); // set the query - setQuery_Impl(aSql); - // parameters may also have changed - clearParametersCollection(); + setQuery_Impl(aSql.makeStringAndClear()); + + // clear column collections which (might) have changed + clearColumns( ParameterColumns ); + if ( _ePart == Order ) + clearColumns( OrderColumns ); + if ( _ePart == Group ) + clearColumns( GroupByColumns ); // also, since the "additive filter" change, we need to rebuild our "additive" statement aSql = m_aPureSelectSQL; @@ -590,10 +596,10 @@ void OSingleSelectQueryComposer::setSingleAdditiveClause( SQLPart _ePart, const aClauses[ _ePart ] = getComposedClause( ::rtl::OUString(), _rClause, *pComposer, getKeyword( _ePart ) ); // and parse it, so that m_aAdditiveIterator is up to date for ( SQLPart eLoopParts = Where; eLoopParts != SQLPartCount; incSQLPart( eLoopParts ) ) - aSql += aClauses[ eLoopParts ]; + aSql.append(aClauses[ eLoopParts ]); try { - parseAndCheck_throwError( m_aSqlParser, aSql, m_aAdditiveIterator, *this ); + parseAndCheck_throwError( m_aSqlParser, aSql.makeStringAndClear(), m_aAdditiveIterator, *this ); } catch( const Exception& e ) { @@ -642,7 +648,8 @@ Reference< XNameAccess > SAL_CALL OSingleSelectQueryComposer::getTables( ) thro { const OSQLTables& aTables = m_aSqlIterator.getTables(); ::std::vector< ::rtl::OUString> aNames; - for(OSQLTables::const_iterator aIter = aTables.begin(); aIter != aTables.end();++aIter) + OSQLTables::const_iterator aEnd = aTables.end(); + for(OSQLTables::const_iterator aIter = aTables.begin(); aIter != aEnd;++aIter) aNames.push_back(aIter->first); m_pTables = new OPrivateTables(aTables,m_xMetaData->supportsMixedCaseQuotedIdentifiers(),*this,m_aMutex,aNames); @@ -674,26 +681,42 @@ Reference< XNameAccess > SAL_CALL OSingleSelectQueryComposer::getColumns( ) thr bCase = m_xMetaData->supportsMixedCaseQuotedIdentifiers(); aSelectColumns = m_aSqlIterator.getSelectColumns(); - ::rtl::OUString sSql = m_aPureSelectSQL; - sSql += STR_WHERE; - sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" 0 = 1 ")); - ::rtl::OUString sGroupBy = getSQLPart(Group,m_aSqlIterator,sal_True); + ::rtl::OUStringBuffer aSQL; + aSQL.append( m_aPureSelectSQL ); + aSQL.append( STR_WHERE ); + + // preserve the original WHERE clause + // #i102234# / 2009-06-02 / frank.schoenheit@sun.com + ::rtl::OUString sOriginalWhereClause = getSQLPart( Where, m_aSqlIterator, sal_False ); + if ( sOriginalWhereClause.getLength() ) + { + aSQL.appendAscii( " ( 0 = 1 ) AND ( " ); + aSQL.append( sOriginalWhereClause ); + aSQL.appendAscii( " ) " ); + } + else + { + aSQL.appendAscii( " ( 0 = 1 ) " ); + } + + ::rtl::OUString sGroupBy = getSQLPart( Group, m_aSqlIterator, sal_True ); if ( sGroupBy.getLength() ) - sSql += sGroupBy; + aSQL.append( sGroupBy ); + ::rtl::OUString sSQL( aSQL.makeStringAndClear() ); // normalize the statement so that it doesn't contain any application-level features anymore ::rtl::OUString sError; - const ::std::auto_ptr< OSQLParseNode > pStatementTree( m_aSqlParser.parseTree( sError, sSql, false ) ); + const ::std::auto_ptr< OSQLParseNode > pStatementTree( m_aSqlParser.parseTree( sError, sSQL, false ) ); DBG_ASSERT( pStatementTree.get(), "OSingleSelectQueryComposer::getColumns: could not parse the column retrieval statement!" ); if ( pStatementTree.get() ) - if ( !pStatementTree->parseNodeToExecutableStatement( sSql, m_xConnection, m_aSqlParser, NULL ) ) + if ( !pStatementTree->parseNodeToExecutableStatement( sSQL, m_xConnection, m_aSqlParser, NULL ) ) break; Reference< XResultSetMetaData > xResultSetMeta; Reference< XResultSetMetaDataSupplier > xResMetaDataSup; try { - xPreparedStatement.set( m_xConnection->prepareStatement( sSql ), UNO_QUERY_THROW ); + xPreparedStatement.set( m_xConnection->prepareStatement( sSQL ), UNO_QUERY_THROW ); xResMetaDataSup.set( xPreparedStatement, UNO_QUERY_THROW ); xResultSetMeta.set( xResMetaDataSup->getMetaData(), UNO_QUERY_THROW ); } @@ -705,7 +728,7 @@ Reference< XNameAccess > SAL_CALL OSingleSelectQueryComposer::getColumns( ) thr Reference< XPropertySet > xStatementProps( xStatement, UNO_QUERY_THROW ); try { xStatementProps->setPropertyValue( PROPERTY_ESCAPE_PROCESSING, makeAny( sal_False ) ); } catch ( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); } - xResMetaDataSup.set( xStatement->executeQuery( sSql ), UNO_QUERY_THROW ); + xResMetaDataSup.set( xStatement->executeQuery( sSQL ), UNO_QUERY_THROW ); xResultSetMeta.set( xResMetaDataSup->getMetaData(), UNO_QUERY_THROW ); } @@ -1232,7 +1255,8 @@ Reference< XIndexAccess > SAL_CALL OSingleSelectQueryComposer::getParameters( ) { ::vos::ORef< OSQLColumns> aCols = m_aSqlIterator.getParameters(); ::std::vector< ::rtl::OUString> aNames; - for(OSQLColumns::Vector::const_iterator aIter = aCols->get().begin(); aIter != aCols->get().end();++aIter) + OSQLColumns::Vector::const_iterator aEnd = aCols->get().end(); + for(OSQLColumns::Vector::const_iterator aIter = aCols->get().begin(); aIter != aEnd;++aIter) aNames.push_back(getString((*aIter)->getPropertyValue(PROPERTY_NAME))); m_aCurrentColumns[ParameterColumns] = new OPrivateColumns(aCols,m_xMetaData->supportsMixedCaseQuotedIdentifiers(),*this,m_aMutex,aNames,sal_True); } @@ -1240,14 +1264,15 @@ Reference< XIndexAccess > SAL_CALL OSingleSelectQueryComposer::getParameters( ) return m_aCurrentColumns[ParameterColumns]; } // ----------------------------------------------------------------------------- -void OSingleSelectQueryComposer::clearParametersCollection() +void OSingleSelectQueryComposer::clearColumns( const EColumnType _eType ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::clearParametersCollection" ); - if ( m_aCurrentColumns[ParameterColumns] ) + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::clearColumns" ); + OPrivateColumns* pColumns = m_aCurrentColumns[ _eType ]; + if ( pColumns != NULL ) { - m_aCurrentColumns[ParameterColumns]->disposing(); - m_aColumnsCollection.push_back(m_aCurrentColumns[ParameterColumns]); - m_aCurrentColumns[ParameterColumns] = NULL; + pColumns->disposing(); + m_aColumnsCollection.push_back( pColumns ); + m_aCurrentColumns[ _eType ] = NULL; } } // ----------------------------------------------------------------------------- @@ -1285,7 +1310,8 @@ Reference< XIndexAccess > OSingleSelectQueryComposer::setCurrentColumns( EColumn if ( !m_aCurrentColumns[_eType] ) { ::std::vector< ::rtl::OUString> aNames; - for(OSQLColumns::Vector::const_iterator aIter = _rCols->get().begin(); aIter != _rCols->get().end();++aIter) + OSQLColumns::Vector::const_iterator aEnd = _rCols->get().end(); + for(OSQLColumns::Vector::const_iterator aIter = _rCols->get().begin(); aIter != aEnd;++aIter) aNames.push_back(getString((*aIter)->getPropertyValue(PROPERTY_NAME))); m_aCurrentColumns[_eType] = new OPrivateColumns(_rCols,m_xMetaData->supportsMixedCaseQuotedIdentifiers(),*this,m_aMutex,aNames,sal_True); } @@ -1340,75 +1366,75 @@ namespace { ::rtl::OUString lcl_getCondition(const Sequence< Sequence< PropertyValue > >& filter ) { - ::rtl::OUString sRet; + ::rtl::OUStringBuffer sRet; const Sequence< PropertyValue >* pOrIter = filter.getConstArray(); const Sequence< PropertyValue >* pOrEnd = pOrIter + filter.getLength(); while ( pOrIter != pOrEnd ) { if ( pOrIter->getLength() ) { - sRet += L_BRACKET; + sRet.append(L_BRACKET); const PropertyValue* pAndIter = pOrIter->getConstArray(); const PropertyValue* pAndEnd = pAndIter + pOrIter->getLength(); while ( pAndIter != pAndEnd ) { - sRet += pAndIter->Name; + sRet.append(pAndIter->Name); ::rtl::OUString sValue; pAndIter->Value >>= sValue; switch( pAndIter->Handle ) { case SQLFilterOperator::EQUAL: - sRet += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" = ")); - sRet += sValue; + sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" = "))); + sRet.append(sValue); break; case SQLFilterOperator::NOT_EQUAL: - sRet += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" <> ")); - sRet += sValue; + sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" <> "))); + sRet.append(sValue); break; case SQLFilterOperator::LESS: - sRet += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" < ")); - sRet += sValue; + sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" < "))); + sRet.append(sValue); break; case SQLFilterOperator::GREATER: - sRet += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" > ")); - sRet += sValue; + sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" > "))); + sRet.append(sValue); break; case SQLFilterOperator::LESS_EQUAL: - sRet += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" <= ")); - sRet += sValue; + sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" <= "))); + sRet.append(sValue); break; case SQLFilterOperator::GREATER_EQUAL: - sRet += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" >= ")); - sRet += sValue; + sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" >= "))); + sRet.append(sValue); break; case SQLFilterOperator::LIKE: - sRet += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" LIKE ")); - sRet += sValue; + sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" LIKE "))); + sRet.append(sValue); break; case SQLFilterOperator::NOT_LIKE: - sRet += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" NOT LIKE ")); - sRet += sValue; + sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" NOT LIKE "))); + sRet.append(sValue); break; case SQLFilterOperator::SQLNULL: - sRet += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" IS NULL")) ; + sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" IS NULL")) ); break; case SQLFilterOperator::NOT_SQLNULL: - sRet += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" IS NOT NULL")) ; + sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" IS NOT NULL")) ); break; default: throw IllegalArgumentException(); } ++pAndIter; if ( pAndIter != pAndEnd ) - sRet += STR_AND; + sRet.append(STR_AND); } - sRet += R_BRACKET; + sRet.append(R_BRACKET); } ++pOrIter; if ( pOrIter != pOrEnd && sRet.getLength() ) - sRet += STR_OR; + sRet.append(STR_OR); } - return sRet; + return sRet.makeStringAndClear(); } } // ----------------------------------------------------------------------------- @@ -1431,7 +1457,8 @@ void OSingleSelectQueryComposer::setConditionByColumn( const Reference< XPropert if ( !column.is() || !column->getPropertySetInfo()->hasPropertyByName(PROPERTY_VALUE) - || !column->getPropertySetInfo()->hasPropertyByName(PROPERTY_NAME) ) + || !column->getPropertySetInfo()->hasPropertyByName(PROPERTY_NAME) + || !column->getPropertySetInfo()->hasPropertyByName(PROPERTY_TYPE)) throw SQLException(DBACORE_RESSTRING(RID_STR_COLUMN_NOT_VALID),*this,SQLSTATE_GENERAL,1000,Any() ); sal_Int32 nType = 0; diff --git a/dbaccess/source/core/api/resultset.cxx b/dbaccess/source/core/api/resultset.cxx index 8e91bda0e..f70e67f0f 100644 --- a/dbaccess/source/core/api/resultset.cxx +++ b/dbaccess/source/core/api/resultset.cxx @@ -1,1211 +1,1211 @@ -/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: resultset.cxx,v $
- * $Revision: 1.21 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_dbaccess.hxx"
-#ifndef _DBA_COREAPI_RESULTSET_HXX_
-#include <resultset.hxx>
-#endif
-#ifndef DBACCESS_SHARED_DBASTRINGS_HRC
-#include "dbastrings.hrc"
-#endif
-#ifndef _DBASHARED_APITOOLS_HXX_
-#include "apitools.hxx"
-#endif
-#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
-#include <com/sun/star/lang/DisposedException.hpp>
-#endif
-#ifndef _COM_SUN_STAR_SDBC_RESULTSETTYPE_HPP_
-#include <com/sun/star/sdbc/ResultSetType.hpp>
-#endif
-#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
-#include <cppuhelper/typeprovider.hxx>
-#endif
-#ifndef _COMPHELPER_PROPERTY_HXX_
-#include <comphelper/property.hxx>
-#endif
-#ifndef _COMPHELPER_SEQUENCE_HXX_
-#include <comphelper/sequence.hxx>
-#endif
-#ifndef _COMPHELPER_TYPES_HXX_
-#include <comphelper/types.hxx>
-#endif
-#ifndef _TOOLS_DEBUG_HXX //autogen
-#include <tools/debug.hxx>
-#endif
-#ifndef TOOLS_DIAGNOSE_EX_H
-#include <tools/diagnose_ex.h>
-#endif
-#ifndef _DBA_COREAPI_DATACOLUMN_HXX_
-#include <datacolumn.hxx>
-#endif
-#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
-#include <com/sun/star/beans/PropertyAttribute.hpp>
-#endif
-#ifndef _DBHELPER_DBEXCEPTION_HXX_
-#include <connectivity/dbexception.hxx>
-#endif
-#ifndef _CONNECTIVITY_DBTOOLS_HXX_
-#include <connectivity/dbtools.hxx>
-#endif
-#ifndef _CPPUHELPER_EXC_HLP_HXX_
-#include <cppuhelper/exc_hlp.hxx>
-#endif
-#ifndef _OSL_THREAD_H_
-#include <osl/thread.h>
-#endif
-#include <rtl/logfile.hxx>
-
-
-using namespace ::com::sun::star::sdbc;
-using namespace ::com::sun::star::sdbcx;
-//using namespace ::com::sun::star::sdb;
-using namespace ::com::sun::star::beans;
-using namespace ::com::sun::star::uno;
-using namespace ::com::sun::star::lang;
-using namespace ::com::sun::star::container;
-using namespace ::cppu;
-using namespace ::osl;
-using namespace dbaccess;
-using namespace dbtools;
-
-DBG_NAME(OResultSet)
-
-//--------------------------------------------------------------------------
-OResultSet::OResultSet(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet >& _xResultSet,
- const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xStatement,
- sal_Bool _bCaseSensitive)
- :OResultSetBase(m_aMutex)
- ,OPropertySetHelper(OResultSetBase::rBHelper)
- ,m_xDelegatorResultSet(_xResultSet)
- ,m_aWarnings( Reference< XWarningsSupplier >( _xResultSet, UNO_QUERY ) )
- ,m_bIsBookmarkable(sal_False)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::OResultSet" );
- DBG_CTOR(OResultSet, NULL);
-
- m_pColumns = new OColumns(*this, m_aMutex, _bCaseSensitive, ::std::vector< ::rtl::OUString>(), NULL,NULL);
-
- try
- {
- m_aStatement = _xStatement;
- m_xDelegatorResultSetUpdate = m_xDelegatorResultSetUpdate.query( m_xDelegatorResultSet );
- m_xDelegatorRow = m_xDelegatorRow.query( m_xDelegatorResultSet );
- m_xDelegatorRowUpdate = m_xDelegatorRowUpdate.query( m_xDelegatorResultSet );
-
- Reference< XPropertySet > xSet(m_xDelegatorResultSet, UNO_QUERY);
- xSet->getPropertyValue(PROPERTY_RESULTSETTYPE) >>= m_nResultSetType;
- xSet->getPropertyValue(PROPERTY_RESULTSETCONCURRENCY) >>= m_nResultSetConcurrency;
-
- // test for Bookmarks
- if (ResultSetType::FORWARD_ONLY != m_nResultSetType)
- {
- Reference <XPropertySetInfo > xInfo(xSet->getPropertySetInfo());
- if (xInfo->hasPropertyByName(PROPERTY_ISBOOKMARKABLE))
- {
- m_bIsBookmarkable = ::comphelper::getBOOL(xSet->getPropertyValue(PROPERTY_ISBOOKMARKABLE));
- OSL_ENSURE( !m_bIsBookmarkable || Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY).is(),
- "OResultSet::OResultSet: aggregate is inconsistent in it's bookmarkable attribute!" );
- m_bIsBookmarkable = m_bIsBookmarkable && Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY).is();
- }
- }
- }
- catch(Exception&)
- {
- }
-}
-
-//--------------------------------------------------------------------------
-OResultSet::~OResultSet()
-{
- m_pColumns->acquire();
- m_pColumns->disposing();
- delete m_pColumns;
-
- DBG_DTOR(OResultSet, NULL);
-}
-
-// com::sun::star::lang::XTypeProvider
-//--------------------------------------------------------------------------
-Sequence< Type > OResultSet::getTypes() throw (RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getTypes" );
- OTypeCollection aTypes(::getCppuType( (const Reference< XPropertySet > *)0 ),
- OResultSetBase::getTypes());
-
- return aTypes.getTypes();
-}
-
-//--------------------------------------------------------------------------
-Sequence< sal_Int8 > OResultSet::getImplementationId() throw (RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getImplementationId" );
- static OImplementationId * pId = 0;
- if (! pId)
- {
- MutexGuard aGuard( Mutex::getGlobalMutex() );
- if (! pId)
- {
- static OImplementationId aId;
- pId = &aId;
- }
- }
- return pId->getImplementationId();
-}
-
-// com::sun::star::uno::XInterface
-//--------------------------------------------------------------------------
-Any OResultSet::queryInterface( const Type & rType ) throw (RuntimeException)
-{
- //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::queryInterface" );
- Any aIface = OResultSetBase::queryInterface( rType );
- if (!aIface.hasValue())
- aIface = ::cppu::queryInterface(
- rType,
- static_cast< XPropertySet * >( this ));
-
- return aIface;
-}
-
-//--------------------------------------------------------------------------
-void OResultSet::acquire() throw ()
-{
- OResultSetBase::acquire();
-}
-
-//--------------------------------------------------------------------------
-void OResultSet::release() throw ()
-{
- OResultSetBase::release();
-}
-
-
-// OResultSetBase
-//------------------------------------------------------------------------------
-void OResultSet::disposing()
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::disposing" );
- OPropertySetHelper::disposing();
-
- MutexGuard aGuard(m_aMutex);
-
- // free the columns
- m_pColumns->disposing();
-
- // close the pending result set
- Reference< XCloseable > (m_xDelegatorResultSet, UNO_QUERY)->close();
-
- m_xDelegatorResultSet = NULL;
- m_xDelegatorRow = NULL;
- m_xDelegatorRowUpdate = NULL;
-
- m_aStatement = Reference< XInterface >();
-}
-
-// XCloseable
-//------------------------------------------------------------------------------
-void OResultSet::close(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::close" );
- {
- MutexGuard aGuard( m_aMutex );
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
- }
- dispose();
-}
-
-// XServiceInfo
-//------------------------------------------------------------------------------
-rtl::OUString OResultSet::getImplementationName( ) throw(RuntimeException)
-{
- //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getImplementationName" );
- return rtl::OUString::createFromAscii("com.sun.star.sdb.OResultSet");
-}
-
-//------------------------------------------------------------------------------
-sal_Bool OResultSet::supportsService( const ::rtl::OUString& _rServiceName ) throw (RuntimeException)
-{
- //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::supportsService" );
- return ::comphelper::findValue(getSupportedServiceNames(), _rServiceName, sal_True).getLength() != 0;
-}
-
-//------------------------------------------------------------------------------
-Sequence< ::rtl::OUString > OResultSet::getSupportedServiceNames( ) throw (RuntimeException)
-{
- //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getSupportedServiceNames" );
- Sequence< ::rtl::OUString > aSNS( 2 );
- aSNS[0] = SERVICE_SDBC_RESULTSET;
- aSNS[1] = SERVICE_SDB_RESULTSET;
- return aSNS;
-}
-
-// com::sun::star::beans::XPropertySet
-//------------------------------------------------------------------------------
-Reference< XPropertySetInfo > OResultSet::getPropertySetInfo() throw (RuntimeException)
-{
- //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getPropertySetInfo" );
- return createPropertySetInfo( getInfoHelper() ) ;
-}
-
-// comphelper::OPropertyArrayUsageHelper
-//------------------------------------------------------------------------------
-::cppu::IPropertyArrayHelper* OResultSet::createArrayHelper( ) const
-{
- //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::createArrayHelper" );
- BEGIN_PROPERTY_HELPER(6)
- DECL_PROP1(CURSORNAME, ::rtl::OUString, READONLY);
- DECL_PROP0(FETCHDIRECTION, sal_Int32);
- DECL_PROP0(FETCHSIZE, sal_Int32);
- DECL_PROP1_BOOL(ISBOOKMARKABLE, READONLY);
- DECL_PROP1(RESULTSETCONCURRENCY, sal_Int32, READONLY);
- DECL_PROP1(RESULTSETTYPE, sal_Int32, READONLY);
- END_PROPERTY_HELPER();
-}
-
-// cppu::OPropertySetHelper
-//------------------------------------------------------------------------------
-::cppu::IPropertyArrayHelper& OResultSet::getInfoHelper()
-{
- //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getInfoHelper" );
- return *getArrayHelper();
-}
-
-//------------------------------------------------------------------------------
-sal_Bool OResultSet::convertFastPropertyValue(Any & rConvertedValue, Any & rOldValue, sal_Int32 nHandle, const Any& rValue ) throw( IllegalArgumentException )
-{
- //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::convertFastPropertyValue" );
- // be lazy ...
- rConvertedValue = rValue;
- getFastPropertyValue( rOldValue, nHandle );
- return sal_True;
-}
-
-//------------------------------------------------------------------------------
-void OResultSet::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue ) throw (Exception)
-{
- //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::setFastPropertyValue_NoBroadcast" );
- // set it for the driver result set
- Reference< XPropertySet > xSet(m_xDelegatorResultSet, UNO_QUERY);
- switch (nHandle)
- {
- case PROPERTY_ID_FETCHDIRECTION:
- xSet->setPropertyValue(PROPERTY_FETCHDIRECTION, rValue);
- break;
- case PROPERTY_ID_FETCHSIZE:
- xSet->setPropertyValue(PROPERTY_FETCHSIZE, rValue);
- break;
- default:
- DBG_ERROR("unknown Property");
- }
-}
-
-//------------------------------------------------------------------------------
-void OResultSet::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const
-{
- //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getFastPropertyValue" );
- switch (nHandle)
- {
- case PROPERTY_ID_ISBOOKMARKABLE:
- {
- sal_Bool bVal = m_bIsBookmarkable;
- rValue.setValue(&bVal, getBooleanCppuType());
- } break;
- default:
- {
- // get the property name
- ::rtl::OUString aPropName;
- sal_Int16 nAttributes;
- const_cast<OResultSet*>(this)->getInfoHelper().
- fillPropertyMembersByHandle(&aPropName, &nAttributes, nHandle);
- OSL_ENSURE(aPropName.getLength(), "property not found?");
-
- // now read the value
- rValue = Reference< XPropertySet >(m_xDelegatorResultSet, UNO_QUERY)->getPropertyValue(aPropName);
- }
- }
-}
-
-// XWarningsSupplier
-//------------------------------------------------------------------------------
-Any OResultSet::getWarnings(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getWarnings" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
- return m_aWarnings.getWarnings();
-}
-
-//------------------------------------------------------------------------------
-void OResultSet::clearWarnings(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::clearWarnings" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
- m_aWarnings.clearWarnings();
-}
-
-// ::com::sun::star::sdbc::XResultSetMetaDataSupplier
-//------------------------------------------------------------------------------
-Reference< XResultSetMetaData > OResultSet::getMetaData(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getMetaData" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return Reference< XResultSetMetaDataSupplier >(m_xDelegatorResultSet, UNO_QUERY)->getMetaData();
-}
-
-// ::com::sun::star::sdbc::XColumnLocate
-//------------------------------------------------------------------------------
-sal_Int32 OResultSet::findColumn(const rtl::OUString& columnName) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::findColumn" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return Reference< XColumnLocate >(m_xDelegatorResultSet, UNO_QUERY)->findColumn(columnName);
-}
-
-//------------------------------------------------------------------------------
-namespace
-{
- static Reference< XDatabaseMetaData > lcl_getDBMetaDataFromStatement_nothrow( const Reference< XInterface >& _rxStatement )
- {
- Reference< XDatabaseMetaData > xDBMetaData;
- try
- {
- Reference< XStatement > xStatement( _rxStatement, UNO_QUERY );
- Reference< XPreparedStatement > xPreparedStatement( _rxStatement, UNO_QUERY );
- Reference< XConnection > xConn;
- if ( xStatement.is() )
- xConn = xStatement->getConnection();
- else if ( xPreparedStatement.is() )
- xConn = xPreparedStatement->getConnection();
- if ( xConn.is() )
- xDBMetaData = xConn->getMetaData();
- }
- catch( const Exception& )
- {
- DBG_UNHANDLED_EXCEPTION();
- }
- return xDBMetaData;
- }
-}
-// ::com::sun::star::sdbcx::XColumnsSupplier
-//------------------------------------------------------------------------------
-Reference< ::com::sun::star::container::XNameAccess > OResultSet::getColumns(void) throw( RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getColumns" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- // do we have to populate the columns
- if (!m_pColumns->isInitialized())
- {
- // get the metadata
- Reference< XResultSetMetaData > xMetaData = Reference< XResultSetMetaDataSupplier >(m_xDelegatorResultSet, UNO_QUERY)->getMetaData();
-
- sal_Int32 nColCount = 0;
- // do we have columns
- try
- {
- Reference< XDatabaseMetaData > xDBMetaData( lcl_getDBMetaDataFromStatement_nothrow( getStatement() ) );
- nColCount = xMetaData->getColumnCount();
-
- for ( sal_Int32 i = 0; i < nColCount; ++i)
- {
- // retrieve the name of the column
- rtl::OUString sName = xMetaData->getColumnName(i + 1);
- ODataColumn* pColumn = new ODataColumn(xMetaData, m_xDelegatorRow, m_xDelegatorRowUpdate, i + 1, xDBMetaData);
-
- // don't silently assume that the name is unique - result set implementations
- // are allowed to return duplicate names, but we are required to have
- // unique column names
- if ( m_pColumns->hasByName( sName ) )
- sName = ::dbtools::createUniqueName( m_pColumns, sName );
-
- m_pColumns->append( sName, pColumn );
- }
- }
- catch ( const SQLException& )
- {
- DBG_UNHANDLED_EXCEPTION();
- }
- m_pColumns->setInitialized();
-
- #if OSL_DEBUG_LEVEL > 0
- // some sanity checks. Especially in case we auto-adjusted the column names above,
- // this might be reasonable
- try
- {
- const Reference< XNameAccess > xColNames( static_cast< XNameAccess* >( m_pColumns ), UNO_SET_THROW );
- const Sequence< ::rtl::OUString > aNames( xColNames->getElementNames() );
- OSL_POSTCOND( aNames.getLength() == nColCount,
- "OResultSet::getColumns: invalid column count!" );
- for ( const ::rtl::OUString* pName = aNames.getConstArray();
- pName != aNames.getConstArray() + aNames.getLength();
- ++pName
- )
- {
- Reference< XPropertySet > xColProps( xColNames->getByName( *pName ), UNO_QUERY_THROW );
- ::rtl::OUString sName;
- OSL_VERIFY( xColProps->getPropertyValue( PROPERTY_NAME ) >>= sName );
- OSL_POSTCOND( sName == *pName, "OResultSet::getColumns: invalid column name!" );
- }
-
- }
- catch( const Exception& )
- {
- DBG_UNHANDLED_EXCEPTION();
- }
- #endif
- }
- return m_pColumns;
-}
-
-// ::com::sun::star::sdbc::XRow
-//------------------------------------------------------------------------------
-sal_Bool OResultSet::wasNull(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::wasNull" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorRow->wasNull();
-}
-//------------------------------------------------------------------------------
-rtl::OUString OResultSet::getString(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
-{
- //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getString" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorRow->getString(columnIndex);
-}
-//------------------------------------------------------------------------------
-sal_Bool OResultSet::getBoolean(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
-{
- //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getBoolean" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorRow->getBoolean(columnIndex);
-}
-//------------------------------------------------------------------------------
-sal_Int8 OResultSet::getByte(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getByte" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorRow->getByte(columnIndex);
-}
-//------------------------------------------------------------------------------
-sal_Int16 OResultSet::getShort(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getShort" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorRow->getShort(columnIndex);
-}
-//------------------------------------------------------------------------------
-sal_Int32 OResultSet::getInt(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getInt" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorRow->getInt(columnIndex);
-}
-//------------------------------------------------------------------------------
-sal_Int64 OResultSet::getLong(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getLong" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorRow->getLong(columnIndex);
-}
-//------------------------------------------------------------------------------
-float OResultSet::getFloat(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getFloat" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorRow->getFloat(columnIndex);
-}
-//------------------------------------------------------------------------------
-double OResultSet::getDouble(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getDouble" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorRow->getDouble(columnIndex);
-}
-//------------------------------------------------------------------------------
-Sequence< sal_Int8 > OResultSet::getBytes(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getBytes" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorRow->getBytes(columnIndex);
-}
-//------------------------------------------------------------------------------
-::com::sun::star::util::Date OResultSet::getDate(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getDate" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorRow->getDate(columnIndex);
-}
-//------------------------------------------------------------------------------
-::com::sun::star::util::Time OResultSet::getTime(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getTime" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorRow->getTime(columnIndex);
-}
-//------------------------------------------------------------------------------
-::com::sun::star::util::DateTime OResultSet::getTimestamp(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getTimestamp" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorRow->getTimestamp(columnIndex);
-}
-//------------------------------------------------------------------------------
-Reference< ::com::sun::star::io::XInputStream > OResultSet::getBinaryStream(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getBinaryStream" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorRow->getBinaryStream(columnIndex);
-}
-//------------------------------------------------------------------------------
-Reference< ::com::sun::star::io::XInputStream > OResultSet::getCharacterStream(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getCharacterStream" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorRow->getCharacterStream(columnIndex);
-}
-//------------------------------------------------------------------------------
-Any OResultSet::getObject(sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess > & typeMap) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getObject" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorRow->getObject(columnIndex, typeMap);
-}
-//------------------------------------------------------------------------------
-Reference< XRef > OResultSet::getRef(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getRef" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorRow->getRef(columnIndex);
-}
-//------------------------------------------------------------------------------
-Reference< XBlob > OResultSet::getBlob(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getBlob" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorRow->getBlob(columnIndex);
-}
-//------------------------------------------------------------------------------
-Reference< XClob > OResultSet::getClob(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getClob" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorRow->getClob(columnIndex);
-}
-//------------------------------------------------------------------------------
-Reference< XArray > OResultSet::getArray(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getArray" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorRow->getArray(columnIndex);
-}
-
-// ::com::sun::star::sdbc::XRowUpdate
-//------------------------------------------------------------------------------
-void OResultSet::updateNull(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateNull" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkReadOnly();
-
- m_xDelegatorRowUpdate->updateNull(columnIndex);
-}
-
-//------------------------------------------------------------------------------
-void OResultSet::updateBoolean(sal_Int32 columnIndex, sal_Bool x) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateBoolean" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkReadOnly();
-
- m_xDelegatorRowUpdate->updateBoolean(columnIndex, x);
-}
-//------------------------------------------------------------------------------
-void OResultSet::updateByte(sal_Int32 columnIndex, sal_Int8 x) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateByte" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkReadOnly();
-
- m_xDelegatorRowUpdate->updateByte(columnIndex, x);
-}
-//------------------------------------------------------------------------------
-void OResultSet::updateShort(sal_Int32 columnIndex, sal_Int16 x) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateShort" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkReadOnly();
-
- m_xDelegatorRowUpdate->updateShort(columnIndex, x);
-}
-//------------------------------------------------------------------------------
-void OResultSet::updateInt(sal_Int32 columnIndex, sal_Int32 x) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateInt" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkReadOnly();
-
- m_xDelegatorRowUpdate->updateInt(columnIndex, x);
-}
-//------------------------------------------------------------------------------
-void OResultSet::updateLong(sal_Int32 columnIndex, sal_Int64 x) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateLong" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkReadOnly();
-
- m_xDelegatorRowUpdate->updateLong(columnIndex, x);
-}
-//------------------------------------------------------------------------------
-void OResultSet::updateFloat(sal_Int32 columnIndex, float x) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateFloat" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkReadOnly();
-
- m_xDelegatorRowUpdate->updateFloat(columnIndex, x);
-}
-//------------------------------------------------------------------------------
-void OResultSet::updateDouble(sal_Int32 columnIndex, double x) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateDouble" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkReadOnly();
-
- m_xDelegatorRowUpdate->updateDouble(columnIndex, x);
-}
-//------------------------------------------------------------------------------
-void OResultSet::updateString(sal_Int32 columnIndex, const rtl::OUString& x) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateString" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkReadOnly();
-
- m_xDelegatorRowUpdate->updateString(columnIndex, x);
-}
-//------------------------------------------------------------------------------
-void OResultSet::updateBytes(sal_Int32 columnIndex, const Sequence< sal_Int8 >& x) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateBytes" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkReadOnly();
-
- m_xDelegatorRowUpdate->updateBytes(columnIndex, x);
-}
-//------------------------------------------------------------------------------
-void OResultSet::updateDate(sal_Int32 columnIndex, const ::com::sun::star::util::Date& x) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateDate" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkReadOnly();
-
- m_xDelegatorRowUpdate->updateDate(columnIndex, x);
-}
-//------------------------------------------------------------------------------
-void OResultSet::updateTime(sal_Int32 columnIndex, const ::com::sun::star::util::Time& x) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateTime" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkReadOnly();
-
- m_xDelegatorRowUpdate->updateTime(columnIndex, x);
-}
-//------------------------------------------------------------------------------
-void OResultSet::updateTimestamp(sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateTimestamp" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkReadOnly();
-
- m_xDelegatorRowUpdate->updateTimestamp(columnIndex, x);
-}
-//------------------------------------------------------------------------------
-void OResultSet::updateBinaryStream(sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream > & x, sal_Int32 length) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateBinaryStream" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkReadOnly();
-
- m_xDelegatorRowUpdate->updateBinaryStream(columnIndex, x, length);
-}
-//------------------------------------------------------------------------------
-void OResultSet::updateCharacterStream(sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream > & x, sal_Int32 length) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateCharacterStream" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkReadOnly();
-
- m_xDelegatorRowUpdate->updateCharacterStream(columnIndex, x, length);
-}
-//------------------------------------------------------------------------------
-void OResultSet::updateNumericObject(sal_Int32 columnIndex, const Any& x, sal_Int32 scale) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateNumericObject" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkReadOnly();
-
- m_xDelegatorRowUpdate->updateNumericObject(columnIndex, x, scale);
-}
-
-//------------------------------------------------------------------------------
-void OResultSet::updateObject(sal_Int32 columnIndex, const Any& x) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateObject" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkReadOnly();
-
- m_xDelegatorRowUpdate->updateObject(columnIndex, x);
-}
-
-// ::com::sun::star::sdbc::XResultSet
-//------------------------------------------------------------------------------
-sal_Bool OResultSet::next(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::next" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorResultSet->next();
-}
-
-//------------------------------------------------------------------------------
-sal_Bool OResultSet::isBeforeFirst(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::isBeforeFirst" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorResultSet->isBeforeFirst();
-}
-
-//------------------------------------------------------------------------------
-sal_Bool OResultSet::isAfterLast(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::isAfterLast" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorResultSet->isAfterLast();
-}
-
-//------------------------------------------------------------------------------
-sal_Bool OResultSet::isFirst(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::isFirst" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorResultSet->isFirst();
-}
-
-//------------------------------------------------------------------------------
-sal_Bool OResultSet::isLast(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::isLast" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorResultSet->isLast();
-}
-
-//------------------------------------------------------------------------------
-void OResultSet::beforeFirst(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::beforeFirst" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- m_xDelegatorResultSet->beforeFirst();
-}
-
-//------------------------------------------------------------------------------
-void OResultSet::afterLast(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::afterLast" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- m_xDelegatorResultSet->afterLast();
-}
-
-//------------------------------------------------------------------------------
-sal_Bool OResultSet::first(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::first" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorResultSet->first();
-}
-
-//------------------------------------------------------------------------------
-sal_Bool OResultSet::last(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::last" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorResultSet->last();
-}
-
-//------------------------------------------------------------------------------
-sal_Int32 OResultSet::getRow(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getRow" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorResultSet->getRow();
-}
-
-//------------------------------------------------------------------------------
-sal_Bool OResultSet::absolute(sal_Int32 row) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::absolute" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorResultSet->absolute(row);
-}
-
-//------------------------------------------------------------------------------
-sal_Bool OResultSet::relative(sal_Int32 rows) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::relative" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorResultSet->relative(rows);
-}
-
-//------------------------------------------------------------------------------
-sal_Bool OResultSet::previous(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::previous" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorResultSet->previous();
-}
-
-//------------------------------------------------------------------------------
-void OResultSet::refreshRow(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::refreshRow" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- m_xDelegatorResultSet->refreshRow();
-}
-
-//------------------------------------------------------------------------------
-sal_Bool OResultSet::rowUpdated(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::rowUpdated" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorResultSet->rowUpdated();
-}
-
-//------------------------------------------------------------------------------
-sal_Bool OResultSet::rowInserted(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::rowInserted" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorResultSet->rowInserted();
-}
-
-//------------------------------------------------------------------------------
-sal_Bool OResultSet::rowDeleted(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::rowDeleted" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorResultSet->rowDeleted();
-}
-
-//------------------------------------------------------------------------------
-Reference< XInterface > OResultSet::getStatement(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getStatement" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_aStatement;
-}
-
-// ::com::sun::star::sdbcx::XRowLocate
-//------------------------------------------------------------------------------
-Any OResultSet::getBookmark(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getBookmark" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkBookmarkable();
-
- return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY)->getBookmark();
-}
-
-//------------------------------------------------------------------------------
-sal_Bool OResultSet::moveToBookmark(const Any& bookmark) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::moveToBookmark" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkBookmarkable();
-
- return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY)->moveToBookmark(bookmark);
-}
-
-//------------------------------------------------------------------------------
-sal_Bool OResultSet::moveRelativeToBookmark(const Any& bookmark, sal_Int32 rows) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::moveRelativeToBookmark" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkBookmarkable();
-
- return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY)->moveRelativeToBookmark(bookmark, rows);
-}
-
-//------------------------------------------------------------------------------
-sal_Int32 OResultSet::compareBookmarks(const Any& _first, const Any& _second) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::compareBookmarks" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkBookmarkable();
-
- return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY)->compareBookmarks(_first, _second);
-}
-
-//------------------------------------------------------------------------------
-sal_Bool OResultSet::hasOrderedBookmarks(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::hasOrderedBookmarks" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkBookmarkable();
-
- return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY)->hasOrderedBookmarks();
-}
-
-//------------------------------------------------------------------------------
-sal_Int32 OResultSet::hashBookmark(const Any& bookmark) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::hashBookmark" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkBookmarkable();
-
- return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY)->hashBookmark(bookmark);
-}
-
-// ::com::sun::star::sdbc::XResultSetUpdate
-//------------------------------------------------------------------------------
-void OResultSet::insertRow(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::insertRow" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkReadOnly();
-
- m_xDelegatorResultSetUpdate->insertRow();
-}
-
-//------------------------------------------------------------------------------
-void OResultSet::updateRow(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateRow" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkReadOnly();
-
- m_xDelegatorResultSetUpdate->updateRow();
-}
-
-//------------------------------------------------------------------------------
-void OResultSet::deleteRow(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::deleteRow" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkReadOnly();
-
- m_xDelegatorResultSetUpdate->deleteRow();
-}
-
-//------------------------------------------------------------------------------
-void OResultSet::cancelRowUpdates(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::cancelRowUpdates" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkReadOnly();
-
- m_xDelegatorResultSetUpdate->cancelRowUpdates();
-}
-
-//------------------------------------------------------------------------------
-void OResultSet::moveToInsertRow(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::moveToInsertRow" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkReadOnly();
-
- m_xDelegatorResultSetUpdate->moveToInsertRow();
-}
-
-//------------------------------------------------------------------------------
-void OResultSet::moveToCurrentRow(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::moveToCurrentRow" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkReadOnly();
-
- m_xDelegatorResultSetUpdate->moveToCurrentRow();
-}
-
-// -----------------------------------------------------------------------------
-void OResultSet::checkReadOnly() const
-{
- //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::checkReadOnly" );
- if ( ( m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY )
- || !m_xDelegatorResultSetUpdate.is()
- )
- throwSQLException( "The result set is read-only.", SQL_GENERAL_ERROR, *const_cast< OResultSet* >( this ) );
-}
-
-// -----------------------------------------------------------------------------
-void OResultSet::checkBookmarkable() const
-{
- //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::checkBookmarkable" );
- if ( !m_bIsBookmarkable )
- throwSQLException( "The result set does not have bookmark support.", SQL_GENERAL_ERROR, *const_cast< OResultSet* >( this ) );
-}
-// -----------------------------------------------------------------------------
-
+/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: resultset.cxx,v $ + * $Revision: 1.21 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dbaccess.hxx" +#ifndef _DBA_COREAPI_RESULTSET_HXX_ +#include <resultset.hxx> +#endif +#ifndef DBACCESS_SHARED_DBASTRINGS_HRC +#include "dbastrings.hrc" +#endif +#ifndef _DBASHARED_APITOOLS_HXX_ +#include "apitools.hxx" +#endif +#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ +#include <com/sun/star/lang/DisposedException.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_RESULTSETTYPE_HPP_ +#include <com/sun/star/sdbc/ResultSetType.hpp> +#endif +#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_ +#include <cppuhelper/typeprovider.hxx> +#endif +#ifndef _COMPHELPER_PROPERTY_HXX_ +#include <comphelper/property.hxx> +#endif +#ifndef _COMPHELPER_SEQUENCE_HXX_ +#include <comphelper/sequence.hxx> +#endif +#ifndef _COMPHELPER_TYPES_HXX_ +#include <comphelper/types.hxx> +#endif +#ifndef _TOOLS_DEBUG_HXX //autogen +#include <tools/debug.hxx> +#endif +#ifndef TOOLS_DIAGNOSE_EX_H +#include <tools/diagnose_ex.h> +#endif +#ifndef _DBA_COREAPI_DATACOLUMN_HXX_ +#include <datacolumn.hxx> +#endif +#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_ +#include <com/sun/star/beans/PropertyAttribute.hpp> +#endif +#ifndef _DBHELPER_DBEXCEPTION_HXX_ +#include <connectivity/dbexception.hxx> +#endif +#ifndef _CONNECTIVITY_DBTOOLS_HXX_ +#include <connectivity/dbtools.hxx> +#endif +#ifndef _CPPUHELPER_EXC_HLP_HXX_ +#include <cppuhelper/exc_hlp.hxx> +#endif +#ifndef _OSL_THREAD_H_ +#include <osl/thread.h> +#endif +#include <rtl/logfile.hxx> + + +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::sdbcx; +//using namespace ::com::sun::star::sdb; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::container; +using namespace ::cppu; +using namespace ::osl; +using namespace dbaccess; +using namespace dbtools; + +DBG_NAME(OResultSet) + +//-------------------------------------------------------------------------- +OResultSet::OResultSet(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet >& _xResultSet, + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xStatement, + sal_Bool _bCaseSensitive) + :OResultSetBase(m_aMutex) + ,OPropertySetHelper(OResultSetBase::rBHelper) + ,m_xDelegatorResultSet(_xResultSet) + ,m_aWarnings( Reference< XWarningsSupplier >( _xResultSet, UNO_QUERY ) ) + ,m_bIsBookmarkable(sal_False) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::OResultSet" ); + DBG_CTOR(OResultSet, NULL); + + m_pColumns = new OColumns(*this, m_aMutex, _bCaseSensitive, ::std::vector< ::rtl::OUString>(), NULL,NULL); + + try + { + m_aStatement = _xStatement; + m_xDelegatorResultSetUpdate = m_xDelegatorResultSetUpdate.query( m_xDelegatorResultSet ); + m_xDelegatorRow = m_xDelegatorRow.query( m_xDelegatorResultSet ); + m_xDelegatorRowUpdate = m_xDelegatorRowUpdate.query( m_xDelegatorResultSet ); + + Reference< XPropertySet > xSet(m_xDelegatorResultSet, UNO_QUERY); + xSet->getPropertyValue(PROPERTY_RESULTSETTYPE) >>= m_nResultSetType; + xSet->getPropertyValue(PROPERTY_RESULTSETCONCURRENCY) >>= m_nResultSetConcurrency; + + // test for Bookmarks + if (ResultSetType::FORWARD_ONLY != m_nResultSetType) + { + Reference <XPropertySetInfo > xInfo(xSet->getPropertySetInfo()); + if (xInfo->hasPropertyByName(PROPERTY_ISBOOKMARKABLE)) + { + m_bIsBookmarkable = ::comphelper::getBOOL(xSet->getPropertyValue(PROPERTY_ISBOOKMARKABLE)); + OSL_ENSURE( !m_bIsBookmarkable || Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY).is(), + "OResultSet::OResultSet: aggregate is inconsistent in it's bookmarkable attribute!" ); + m_bIsBookmarkable = m_bIsBookmarkable && Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY).is(); + } + } + } + catch(Exception&) + { + } +} + +//-------------------------------------------------------------------------- +OResultSet::~OResultSet() +{ + m_pColumns->acquire(); + m_pColumns->disposing(); + delete m_pColumns; + + DBG_DTOR(OResultSet, NULL); +} + +// com::sun::star::lang::XTypeProvider +//-------------------------------------------------------------------------- +Sequence< Type > OResultSet::getTypes() throw (RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getTypes" ); + OTypeCollection aTypes(::getCppuType( (const Reference< XPropertySet > *)0 ), + OResultSetBase::getTypes()); + + return aTypes.getTypes(); +} + +//-------------------------------------------------------------------------- +Sequence< sal_Int8 > OResultSet::getImplementationId() throw (RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getImplementationId" ); + static OImplementationId * pId = 0; + if (! pId) + { + MutexGuard aGuard( Mutex::getGlobalMutex() ); + if (! pId) + { + static OImplementationId aId; + pId = &aId; + } + } + return pId->getImplementationId(); +} + +// com::sun::star::uno::XInterface +//-------------------------------------------------------------------------- +Any OResultSet::queryInterface( const Type & rType ) throw (RuntimeException) +{ + //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::queryInterface" ); + Any aIface = OResultSetBase::queryInterface( rType ); + if (!aIface.hasValue()) + aIface = ::cppu::queryInterface( + rType, + static_cast< XPropertySet * >( this )); + + return aIface; +} + +//-------------------------------------------------------------------------- +void OResultSet::acquire() throw () +{ + OResultSetBase::acquire(); +} + +//-------------------------------------------------------------------------- +void OResultSet::release() throw () +{ + OResultSetBase::release(); +} + + +// OResultSetBase +//------------------------------------------------------------------------------ +void OResultSet::disposing() +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::disposing" ); + OPropertySetHelper::disposing(); + + MutexGuard aGuard(m_aMutex); + + // free the columns + m_pColumns->disposing(); + + // close the pending result set + Reference< XCloseable > (m_xDelegatorResultSet, UNO_QUERY)->close(); + + m_xDelegatorResultSet = NULL; + m_xDelegatorRow = NULL; + m_xDelegatorRowUpdate = NULL; + + m_aStatement = Reference< XInterface >(); +} + +// XCloseable +//------------------------------------------------------------------------------ +void OResultSet::close(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::close" ); + { + MutexGuard aGuard( m_aMutex ); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + } + dispose(); +} + +// XServiceInfo +//------------------------------------------------------------------------------ +rtl::OUString OResultSet::getImplementationName( ) throw(RuntimeException) +{ + //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getImplementationName" ); + return rtl::OUString::createFromAscii("com.sun.star.sdb.OResultSet"); +} + +//------------------------------------------------------------------------------ +sal_Bool OResultSet::supportsService( const ::rtl::OUString& _rServiceName ) throw (RuntimeException) +{ + //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::supportsService" ); + return ::comphelper::findValue(getSupportedServiceNames(), _rServiceName, sal_True).getLength() != 0; +} + +//------------------------------------------------------------------------------ +Sequence< ::rtl::OUString > OResultSet::getSupportedServiceNames( ) throw (RuntimeException) +{ + //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getSupportedServiceNames" ); + Sequence< ::rtl::OUString > aSNS( 2 ); + aSNS[0] = SERVICE_SDBC_RESULTSET; + aSNS[1] = SERVICE_SDB_RESULTSET; + return aSNS; +} + +// com::sun::star::beans::XPropertySet +//------------------------------------------------------------------------------ +Reference< XPropertySetInfo > OResultSet::getPropertySetInfo() throw (RuntimeException) +{ + //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getPropertySetInfo" ); + return createPropertySetInfo( getInfoHelper() ) ; +} + +// comphelper::OPropertyArrayUsageHelper +//------------------------------------------------------------------------------ +::cppu::IPropertyArrayHelper* OResultSet::createArrayHelper( ) const +{ + //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::createArrayHelper" ); + BEGIN_PROPERTY_HELPER(6) + DECL_PROP1(CURSORNAME, ::rtl::OUString, READONLY); + DECL_PROP0(FETCHDIRECTION, sal_Int32); + DECL_PROP0(FETCHSIZE, sal_Int32); + DECL_PROP1_BOOL(ISBOOKMARKABLE, READONLY); + DECL_PROP1(RESULTSETCONCURRENCY, sal_Int32, READONLY); + DECL_PROP1(RESULTSETTYPE, sal_Int32, READONLY); + END_PROPERTY_HELPER(); +} + +// cppu::OPropertySetHelper +//------------------------------------------------------------------------------ +::cppu::IPropertyArrayHelper& OResultSet::getInfoHelper() +{ + //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getInfoHelper" ); + return *getArrayHelper(); +} + +//------------------------------------------------------------------------------ +sal_Bool OResultSet::convertFastPropertyValue(Any & rConvertedValue, Any & rOldValue, sal_Int32 nHandle, const Any& rValue ) throw( IllegalArgumentException ) +{ + //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::convertFastPropertyValue" ); + // be lazy ... + rConvertedValue = rValue; + getFastPropertyValue( rOldValue, nHandle ); + return sal_True; +} + +//------------------------------------------------------------------------------ +void OResultSet::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue ) throw (Exception) +{ + //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::setFastPropertyValue_NoBroadcast" ); + // set it for the driver result set + Reference< XPropertySet > xSet(m_xDelegatorResultSet, UNO_QUERY); + switch (nHandle) + { + case PROPERTY_ID_FETCHDIRECTION: + xSet->setPropertyValue(PROPERTY_FETCHDIRECTION, rValue); + break; + case PROPERTY_ID_FETCHSIZE: + xSet->setPropertyValue(PROPERTY_FETCHSIZE, rValue); + break; + default: + DBG_ERROR("unknown Property"); + } +} + +//------------------------------------------------------------------------------ +void OResultSet::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const +{ + //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getFastPropertyValue" ); + switch (nHandle) + { + case PROPERTY_ID_ISBOOKMARKABLE: + { + sal_Bool bVal = m_bIsBookmarkable; + rValue.setValue(&bVal, getBooleanCppuType()); + } break; + default: + { + // get the property name + ::rtl::OUString aPropName; + sal_Int16 nAttributes; + const_cast<OResultSet*>(this)->getInfoHelper(). + fillPropertyMembersByHandle(&aPropName, &nAttributes, nHandle); + OSL_ENSURE(aPropName.getLength(), "property not found?"); + + // now read the value + rValue = Reference< XPropertySet >(m_xDelegatorResultSet, UNO_QUERY)->getPropertyValue(aPropName); + } + } +} + +// XWarningsSupplier +//------------------------------------------------------------------------------ +Any OResultSet::getWarnings(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getWarnings" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + return m_aWarnings.getWarnings(); +} + +//------------------------------------------------------------------------------ +void OResultSet::clearWarnings(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::clearWarnings" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + m_aWarnings.clearWarnings(); +} + +// ::com::sun::star::sdbc::XResultSetMetaDataSupplier +//------------------------------------------------------------------------------ +Reference< XResultSetMetaData > OResultSet::getMetaData(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getMetaData" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return Reference< XResultSetMetaDataSupplier >(m_xDelegatorResultSet, UNO_QUERY)->getMetaData(); +} + +// ::com::sun::star::sdbc::XColumnLocate +//------------------------------------------------------------------------------ +sal_Int32 OResultSet::findColumn(const rtl::OUString& columnName) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::findColumn" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return Reference< XColumnLocate >(m_xDelegatorResultSet, UNO_QUERY)->findColumn(columnName); +} + +//------------------------------------------------------------------------------ +namespace +{ + static Reference< XDatabaseMetaData > lcl_getDBMetaDataFromStatement_nothrow( const Reference< XInterface >& _rxStatement ) + { + Reference< XDatabaseMetaData > xDBMetaData; + try + { + Reference< XStatement > xStatement( _rxStatement, UNO_QUERY ); + Reference< XPreparedStatement > xPreparedStatement( _rxStatement, UNO_QUERY ); + Reference< XConnection > xConn; + if ( xStatement.is() ) + xConn = xStatement->getConnection(); + else if ( xPreparedStatement.is() ) + xConn = xPreparedStatement->getConnection(); + if ( xConn.is() ) + xDBMetaData = xConn->getMetaData(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return xDBMetaData; + } +} +// ::com::sun::star::sdbcx::XColumnsSupplier +//------------------------------------------------------------------------------ +Reference< ::com::sun::star::container::XNameAccess > OResultSet::getColumns(void) throw( RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getColumns" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + // do we have to populate the columns + if (!m_pColumns->isInitialized()) + { + // get the metadata + Reference< XResultSetMetaData > xMetaData = Reference< XResultSetMetaDataSupplier >(m_xDelegatorResultSet, UNO_QUERY)->getMetaData(); + + sal_Int32 nColCount = 0; + // do we have columns + try + { + Reference< XDatabaseMetaData > xDBMetaData( lcl_getDBMetaDataFromStatement_nothrow( getStatement() ) ); + nColCount = xMetaData->getColumnCount(); + + for ( sal_Int32 i = 0; i < nColCount; ++i) + { + // retrieve the name of the column + rtl::OUString sName = xMetaData->getColumnName(i + 1); + ODataColumn* pColumn = new ODataColumn(xMetaData, m_xDelegatorRow, m_xDelegatorRowUpdate, i + 1, xDBMetaData); + + // don't silently assume that the name is unique - result set implementations + // are allowed to return duplicate names, but we are required to have + // unique column names + if ( m_pColumns->hasByName( sName ) ) + sName = ::dbtools::createUniqueName( m_pColumns, sName ); + + m_pColumns->append( sName, pColumn ); + } + } + catch ( const SQLException& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + m_pColumns->setInitialized(); + + #if OSL_DEBUG_LEVEL > 0 + // some sanity checks. Especially in case we auto-adjusted the column names above, + // this might be reasonable + try + { + const Reference< XNameAccess > xColNames( static_cast< XNameAccess* >( m_pColumns ), UNO_SET_THROW ); + const Sequence< ::rtl::OUString > aNames( xColNames->getElementNames() ); + OSL_POSTCOND( aNames.getLength() == nColCount, + "OResultSet::getColumns: invalid column count!" ); + for ( const ::rtl::OUString* pName = aNames.getConstArray(); + pName != aNames.getConstArray() + aNames.getLength(); + ++pName + ) + { + Reference< XPropertySet > xColProps( xColNames->getByName( *pName ), UNO_QUERY_THROW ); + ::rtl::OUString sName; + OSL_VERIFY( xColProps->getPropertyValue( PROPERTY_NAME ) >>= sName ); + OSL_POSTCOND( sName == *pName, "OResultSet::getColumns: invalid column name!" ); + } + + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + #endif + } + return m_pColumns; +} + +// ::com::sun::star::sdbc::XRow +//------------------------------------------------------------------------------ +sal_Bool OResultSet::wasNull(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::wasNull" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorRow->wasNull(); +} +//------------------------------------------------------------------------------ +rtl::OUString OResultSet::getString(sal_Int32 columnIndex) throw( SQLException, RuntimeException ) +{ + //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getString" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorRow->getString(columnIndex); +} +//------------------------------------------------------------------------------ +sal_Bool OResultSet::getBoolean(sal_Int32 columnIndex) throw( SQLException, RuntimeException ) +{ + //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getBoolean" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorRow->getBoolean(columnIndex); +} +//------------------------------------------------------------------------------ +sal_Int8 OResultSet::getByte(sal_Int32 columnIndex) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getByte" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorRow->getByte(columnIndex); +} +//------------------------------------------------------------------------------ +sal_Int16 OResultSet::getShort(sal_Int32 columnIndex) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getShort" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorRow->getShort(columnIndex); +} +//------------------------------------------------------------------------------ +sal_Int32 OResultSet::getInt(sal_Int32 columnIndex) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getInt" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorRow->getInt(columnIndex); +} +//------------------------------------------------------------------------------ +sal_Int64 OResultSet::getLong(sal_Int32 columnIndex) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getLong" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorRow->getLong(columnIndex); +} +//------------------------------------------------------------------------------ +float OResultSet::getFloat(sal_Int32 columnIndex) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getFloat" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorRow->getFloat(columnIndex); +} +//------------------------------------------------------------------------------ +double OResultSet::getDouble(sal_Int32 columnIndex) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getDouble" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorRow->getDouble(columnIndex); +} +//------------------------------------------------------------------------------ +Sequence< sal_Int8 > OResultSet::getBytes(sal_Int32 columnIndex) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getBytes" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorRow->getBytes(columnIndex); +} +//------------------------------------------------------------------------------ +::com::sun::star::util::Date OResultSet::getDate(sal_Int32 columnIndex) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getDate" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorRow->getDate(columnIndex); +} +//------------------------------------------------------------------------------ +::com::sun::star::util::Time OResultSet::getTime(sal_Int32 columnIndex) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getTime" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorRow->getTime(columnIndex); +} +//------------------------------------------------------------------------------ +::com::sun::star::util::DateTime OResultSet::getTimestamp(sal_Int32 columnIndex) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getTimestamp" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorRow->getTimestamp(columnIndex); +} +//------------------------------------------------------------------------------ +Reference< ::com::sun::star::io::XInputStream > OResultSet::getBinaryStream(sal_Int32 columnIndex) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getBinaryStream" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorRow->getBinaryStream(columnIndex); +} +//------------------------------------------------------------------------------ +Reference< ::com::sun::star::io::XInputStream > OResultSet::getCharacterStream(sal_Int32 columnIndex) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getCharacterStream" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorRow->getCharacterStream(columnIndex); +} +//------------------------------------------------------------------------------ +Any OResultSet::getObject(sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess > & typeMap) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getObject" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorRow->getObject(columnIndex, typeMap); +} +//------------------------------------------------------------------------------ +Reference< XRef > OResultSet::getRef(sal_Int32 columnIndex) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getRef" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorRow->getRef(columnIndex); +} +//------------------------------------------------------------------------------ +Reference< XBlob > OResultSet::getBlob(sal_Int32 columnIndex) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getBlob" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorRow->getBlob(columnIndex); +} +//------------------------------------------------------------------------------ +Reference< XClob > OResultSet::getClob(sal_Int32 columnIndex) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getClob" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorRow->getClob(columnIndex); +} +//------------------------------------------------------------------------------ +Reference< XArray > OResultSet::getArray(sal_Int32 columnIndex) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getArray" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorRow->getArray(columnIndex); +} + +// ::com::sun::star::sdbc::XRowUpdate +//------------------------------------------------------------------------------ +void OResultSet::updateNull(sal_Int32 columnIndex) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateNull" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkReadOnly(); + + m_xDelegatorRowUpdate->updateNull(columnIndex); +} + +//------------------------------------------------------------------------------ +void OResultSet::updateBoolean(sal_Int32 columnIndex, sal_Bool x) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateBoolean" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkReadOnly(); + + m_xDelegatorRowUpdate->updateBoolean(columnIndex, x); +} +//------------------------------------------------------------------------------ +void OResultSet::updateByte(sal_Int32 columnIndex, sal_Int8 x) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateByte" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkReadOnly(); + + m_xDelegatorRowUpdate->updateByte(columnIndex, x); +} +//------------------------------------------------------------------------------ +void OResultSet::updateShort(sal_Int32 columnIndex, sal_Int16 x) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateShort" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkReadOnly(); + + m_xDelegatorRowUpdate->updateShort(columnIndex, x); +} +//------------------------------------------------------------------------------ +void OResultSet::updateInt(sal_Int32 columnIndex, sal_Int32 x) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateInt" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkReadOnly(); + + m_xDelegatorRowUpdate->updateInt(columnIndex, x); +} +//------------------------------------------------------------------------------ +void OResultSet::updateLong(sal_Int32 columnIndex, sal_Int64 x) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateLong" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkReadOnly(); + + m_xDelegatorRowUpdate->updateLong(columnIndex, x); +} +//------------------------------------------------------------------------------ +void OResultSet::updateFloat(sal_Int32 columnIndex, float x) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateFloat" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkReadOnly(); + + m_xDelegatorRowUpdate->updateFloat(columnIndex, x); +} +//------------------------------------------------------------------------------ +void OResultSet::updateDouble(sal_Int32 columnIndex, double x) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateDouble" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkReadOnly(); + + m_xDelegatorRowUpdate->updateDouble(columnIndex, x); +} +//------------------------------------------------------------------------------ +void OResultSet::updateString(sal_Int32 columnIndex, const rtl::OUString& x) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateString" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkReadOnly(); + + m_xDelegatorRowUpdate->updateString(columnIndex, x); +} +//------------------------------------------------------------------------------ +void OResultSet::updateBytes(sal_Int32 columnIndex, const Sequence< sal_Int8 >& x) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateBytes" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkReadOnly(); + + m_xDelegatorRowUpdate->updateBytes(columnIndex, x); +} +//------------------------------------------------------------------------------ +void OResultSet::updateDate(sal_Int32 columnIndex, const ::com::sun::star::util::Date& x) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateDate" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkReadOnly(); + + m_xDelegatorRowUpdate->updateDate(columnIndex, x); +} +//------------------------------------------------------------------------------ +void OResultSet::updateTime(sal_Int32 columnIndex, const ::com::sun::star::util::Time& x) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateTime" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkReadOnly(); + + m_xDelegatorRowUpdate->updateTime(columnIndex, x); +} +//------------------------------------------------------------------------------ +void OResultSet::updateTimestamp(sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateTimestamp" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkReadOnly(); + + m_xDelegatorRowUpdate->updateTimestamp(columnIndex, x); +} +//------------------------------------------------------------------------------ +void OResultSet::updateBinaryStream(sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream > & x, sal_Int32 length) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateBinaryStream" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkReadOnly(); + + m_xDelegatorRowUpdate->updateBinaryStream(columnIndex, x, length); +} +//------------------------------------------------------------------------------ +void OResultSet::updateCharacterStream(sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream > & x, sal_Int32 length) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateCharacterStream" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkReadOnly(); + + m_xDelegatorRowUpdate->updateCharacterStream(columnIndex, x, length); +} +//------------------------------------------------------------------------------ +void OResultSet::updateNumericObject(sal_Int32 columnIndex, const Any& x, sal_Int32 scale) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateNumericObject" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkReadOnly(); + + m_xDelegatorRowUpdate->updateNumericObject(columnIndex, x, scale); +} + +//------------------------------------------------------------------------------ +void OResultSet::updateObject(sal_Int32 columnIndex, const Any& x) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateObject" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkReadOnly(); + + m_xDelegatorRowUpdate->updateObject(columnIndex, x); +} + +// ::com::sun::star::sdbc::XResultSet +//------------------------------------------------------------------------------ +sal_Bool OResultSet::next(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::next" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorResultSet->next(); +} + +//------------------------------------------------------------------------------ +sal_Bool OResultSet::isBeforeFirst(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::isBeforeFirst" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorResultSet->isBeforeFirst(); +} + +//------------------------------------------------------------------------------ +sal_Bool OResultSet::isAfterLast(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::isAfterLast" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorResultSet->isAfterLast(); +} + +//------------------------------------------------------------------------------ +sal_Bool OResultSet::isFirst(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::isFirst" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorResultSet->isFirst(); +} + +//------------------------------------------------------------------------------ +sal_Bool OResultSet::isLast(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::isLast" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorResultSet->isLast(); +} + +//------------------------------------------------------------------------------ +void OResultSet::beforeFirst(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::beforeFirst" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + m_xDelegatorResultSet->beforeFirst(); +} + +//------------------------------------------------------------------------------ +void OResultSet::afterLast(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::afterLast" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + m_xDelegatorResultSet->afterLast(); +} + +//------------------------------------------------------------------------------ +sal_Bool OResultSet::first(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::first" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorResultSet->first(); +} + +//------------------------------------------------------------------------------ +sal_Bool OResultSet::last(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::last" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorResultSet->last(); +} + +//------------------------------------------------------------------------------ +sal_Int32 OResultSet::getRow(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getRow" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorResultSet->getRow(); +} + +//------------------------------------------------------------------------------ +sal_Bool OResultSet::absolute(sal_Int32 row) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::absolute" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorResultSet->absolute(row); +} + +//------------------------------------------------------------------------------ +sal_Bool OResultSet::relative(sal_Int32 rows) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::relative" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorResultSet->relative(rows); +} + +//------------------------------------------------------------------------------ +sal_Bool OResultSet::previous(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::previous" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorResultSet->previous(); +} + +//------------------------------------------------------------------------------ +void OResultSet::refreshRow(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::refreshRow" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + m_xDelegatorResultSet->refreshRow(); +} + +//------------------------------------------------------------------------------ +sal_Bool OResultSet::rowUpdated(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::rowUpdated" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorResultSet->rowUpdated(); +} + +//------------------------------------------------------------------------------ +sal_Bool OResultSet::rowInserted(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::rowInserted" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorResultSet->rowInserted(); +} + +//------------------------------------------------------------------------------ +sal_Bool OResultSet::rowDeleted(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::rowDeleted" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorResultSet->rowDeleted(); +} + +//------------------------------------------------------------------------------ +Reference< XInterface > OResultSet::getStatement(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getStatement" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_aStatement; +} + +// ::com::sun::star::sdbcx::XRowLocate +//------------------------------------------------------------------------------ +Any OResultSet::getBookmark(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getBookmark" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkBookmarkable(); + + return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY)->getBookmark(); +} + +//------------------------------------------------------------------------------ +sal_Bool OResultSet::moveToBookmark(const Any& bookmark) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::moveToBookmark" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkBookmarkable(); + + return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY)->moveToBookmark(bookmark); +} + +//------------------------------------------------------------------------------ +sal_Bool OResultSet::moveRelativeToBookmark(const Any& bookmark, sal_Int32 rows) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::moveRelativeToBookmark" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkBookmarkable(); + + return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY)->moveRelativeToBookmark(bookmark, rows); +} + +//------------------------------------------------------------------------------ +sal_Int32 OResultSet::compareBookmarks(const Any& _first, const Any& _second) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::compareBookmarks" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkBookmarkable(); + + return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY)->compareBookmarks(_first, _second); +} + +//------------------------------------------------------------------------------ +sal_Bool OResultSet::hasOrderedBookmarks(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::hasOrderedBookmarks" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkBookmarkable(); + + return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY)->hasOrderedBookmarks(); +} + +//------------------------------------------------------------------------------ +sal_Int32 OResultSet::hashBookmark(const Any& bookmark) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::hashBookmark" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkBookmarkable(); + + return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY)->hashBookmark(bookmark); +} + +// ::com::sun::star::sdbc::XResultSetUpdate +//------------------------------------------------------------------------------ +void OResultSet::insertRow(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::insertRow" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkReadOnly(); + + m_xDelegatorResultSetUpdate->insertRow(); +} + +//------------------------------------------------------------------------------ +void OResultSet::updateRow(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateRow" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkReadOnly(); + + m_xDelegatorResultSetUpdate->updateRow(); +} + +//------------------------------------------------------------------------------ +void OResultSet::deleteRow(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::deleteRow" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkReadOnly(); + + m_xDelegatorResultSetUpdate->deleteRow(); +} + +//------------------------------------------------------------------------------ +void OResultSet::cancelRowUpdates(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::cancelRowUpdates" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkReadOnly(); + + m_xDelegatorResultSetUpdate->cancelRowUpdates(); +} + +//------------------------------------------------------------------------------ +void OResultSet::moveToInsertRow(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::moveToInsertRow" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkReadOnly(); + + m_xDelegatorResultSetUpdate->moveToInsertRow(); +} + +//------------------------------------------------------------------------------ +void OResultSet::moveToCurrentRow(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::moveToCurrentRow" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkReadOnly(); + + m_xDelegatorResultSetUpdate->moveToCurrentRow(); +} + +// ----------------------------------------------------------------------------- +void OResultSet::checkReadOnly() const +{ + //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::checkReadOnly" ); + if ( ( m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY ) + || !m_xDelegatorResultSetUpdate.is() + ) + throwSQLException( "The result set is read-only.", SQL_GENERAL_ERROR, *const_cast< OResultSet* >( this ) ); +} + +// ----------------------------------------------------------------------------- +void OResultSet::checkBookmarkable() const +{ + //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::checkBookmarkable" ); + if ( !m_bIsBookmarkable ) + throwSQLException( "The result set does not have bookmark support.", SQL_GENERAL_ERROR, *const_cast< OResultSet* >( this ) ); +} +// ----------------------------------------------------------------------------- + diff --git a/dbaccess/source/core/api/statement.cxx b/dbaccess/source/core/api/statement.cxx index 1611cb84c..da5532ea3 100644 --- a/dbaccess/source/core/api/statement.cxx +++ b/dbaccess/source/core/api/statement.cxx @@ -111,12 +111,14 @@ Sequence< Type > OStatementBase::getTypes() throw (RuntimeException) ::getCppuType( (const Reference< XWarningsSupplier > *)0 ), ::getCppuType( (const Reference< XCloseable > *)0 ), ::getCppuType( (const Reference< XMultipleResults > *)0 ), - ::getCppuType( (const Reference< XPreparedBatchExecution > *)0 ), ::getCppuType( (const Reference< ::com::sun::star::util::XCancellable > *)0 ), OSubComponent::getTypes() ); Reference< XGeneratedResultSet > xGRes(m_xAggregateAsSet, UNO_QUERY); if ( xGRes.is() ) aTypes = OTypeCollection(::getCppuType( (const Reference< XGeneratedResultSet > *)0 ),aTypes.getTypes()); + Reference< XPreparedBatchExecution > xPreparedBatchExecution(m_xAggregateAsSet, UNO_QUERY); + if ( xPreparedBatchExecution.is() ) + aTypes = OTypeCollection(::getCppuType( (const Reference< XPreparedBatchExecution > *)0 ),aTypes.getTypes()); return aTypes.getTypes(); } @@ -134,7 +136,6 @@ Any OStatementBase::queryInterface( const Type & rType ) throw (RuntimeException static_cast< XPropertySet * >( this ), static_cast< XWarningsSupplier * >( this ), static_cast< XCloseable * >( this ), - static_cast< XPreparedBatchExecution * >( this ), static_cast< XMultipleResults * >( this ), static_cast< ::com::sun::star::util::XCancellable * >( this )); if ( !aIface.hasValue() ) @@ -142,6 +143,12 @@ Any OStatementBase::queryInterface( const Type & rType ) throw (RuntimeException Reference< XGeneratedResultSet > xGRes(m_xAggregateAsSet, UNO_QUERY); if ( ::getCppuType( (const Reference< XGeneratedResultSet > *)0 ) == rType && xGRes.is() ) aIface = ::cppu::queryInterface(rType,static_cast< XGeneratedResultSet * >( this )); + } // if ( !aIface.hasValue() ) + if ( !aIface.hasValue() ) + { + Reference< XPreparedBatchExecution > xGRes(m_xAggregateAsSet, UNO_QUERY); + if ( ::getCppuType( (const Reference< XPreparedBatchExecution > *)0 ) == rType && xGRes.is() ) + aIface = ::cppu::queryInterface(rType,static_cast< XPreparedBatchExecution * >( this )); } } return aIface; @@ -583,6 +590,46 @@ sal_Bool OStatement::execute( const rtl::OUString& _rSQL ) throw( SQLException, ::rtl::OUString sSQL( impl_doEscapeProcessing_nothrow( _rSQL ) ); return m_xAggregateStatement->execute( sSQL ); } +//------------------------------------------------------------------------------ +void OStatement::addBatch( const rtl::OUString& _rSQL ) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatement::execute" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + + // first check the meta data + Reference<XDatabaseMetaData> xMeta = Reference< XConnection > (m_xParent, UNO_QUERY)->getMetaData(); + if (!xMeta.is() && !xMeta->supportsBatchUpdates()) + throwFunctionSequenceException(*this); + + ::rtl::OUString sSQL( impl_doEscapeProcessing_nothrow( _rSQL ) ); + Reference< XBatchExecution >(m_xAggregateAsSet, UNO_QUERY)->addBatch( sSQL ); +} +//------------------------------------------------------------------------------ +void OStatement::clearBatch( ) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatement::execute" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + // first check the meta data + Reference<XDatabaseMetaData> xMeta = Reference< XConnection > (m_xParent, UNO_QUERY)->getMetaData(); + if (!xMeta.is() && !xMeta->supportsBatchUpdates()) + throwFunctionSequenceException(*this); + + Reference< XBatchExecution >(m_xAggregateAsSet, UNO_QUERY)->clearBatch(); +} +//------------------------------------------------------------------------------ +Sequence< sal_Int32 > OStatement::executeBatch( ) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatement::execute" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); + // first check the meta data + Reference<XDatabaseMetaData> xMeta = Reference< XConnection > (m_xParent, UNO_QUERY)->getMetaData(); + if (!xMeta.is() && !xMeta->supportsBatchUpdates()) + throwFunctionSequenceException(*this); + return Reference< XBatchExecution >(m_xAggregateAsSet, UNO_QUERY)->executeBatch( ); +} //------------------------------------------------------------------------------ Reference< XConnection > OStatement::getConnection(void) throw( SQLException, RuntimeException ) |