dbaccess/source/core/api/KeySet.cxx | 189 ++++++++++++++++++----------- dbaccess/source/core/api/KeySet.hxx | 19 ++ dbaccess/source/core/api/OptimisticSet.cxx | 13 + dbaccess/source/core/api/OptimisticSet.hxx | 1 4 files changed, 146 insertions(+), 76 deletions(-)
New commits: commit 8b66c00a0c87f81ecb78b27dbf0a6ded6e94a048 Author: Lionel Elie Mamane <lio...@mamane.lu> Date: Wed Feb 27 06:54:28 2013 +0100 janitorial: simplify test expression without semantics change The "sComposerFilter != m_sRowSetFilter" could not influence the result. Proof. The right hand-side of the || is evaluated only when m_sRowSetFilter.isEmpty() So the only case where the removed test could have an influence is when m_sRowSetFilter.isEmpty(). However, the right hand-side of the && is evaluated only when !sComposerFilter.isEmpty(). We have m_sRowSetFilter.isEmpty() and !sComposerFilter.isEmpty(). In particular, (sComposerFilter != m_sRowSetFilter) is true. Qed. Change-Id: I1484d78cf2d7a5e8ca44f382eb7c440c84d8c10e diff --git a/dbaccess/source/core/api/OptimisticSet.cxx b/dbaccess/source/core/api/OptimisticSet.cxx index 546a984..cbfcb62 100644 --- a/dbaccess/source/core/api/OptimisticSet.cxx +++ b/dbaccess/source/core/api/OptimisticSet.cxx @@ -157,7 +157,7 @@ void OptimisticSet::makeNewStatement( ) fillJoinedColumns_throw(m_aSqlIterator.getJoinConditions()); const ::rtl::OUString sComposerFilter = m_xComposer->getFilter(); - if ( !m_sRowSetFilter.isEmpty() || (!sComposerFilter.isEmpty() && sComposerFilter != m_sRowSetFilter) ) + if ( !m_sRowSetFilter.isEmpty() || !sComposerFilter.isEmpty() ) { FilterCreator aFilterCreator; if ( !sComposerFilter.isEmpty() && sComposerFilter != m_sRowSetFilter ) commit cb9e5e786beef004aedf6d6cc7dbd989bd6a05be Author: Lionel Elie Mamane <lio...@mamane.lu> Date: Wed Feb 27 06:53:34 2013 +0100 fdo#51976 make "refetch one row" query easier to optimise Instead of playing tricks with parameters that when filled in force a part of the WHERE clause to have not influence, actually use several different statements and hardcode in each the kind of test to be done Change-Id: I93e1978f0420bc627a02291f209c788b9b4f2e96 diff --git a/dbaccess/source/core/api/KeySet.cxx b/dbaccess/source/core/api/KeySet.cxx index 6970db2..6252eec 100644 --- a/dbaccess/source/core/api/KeySet.cxx +++ b/dbaccess/source/core/api/KeySet.cxx @@ -64,6 +64,7 @@ using namespace ::com::sun::star::io; using namespace ::com::sun::star; using namespace ::cppu; using namespace ::osl; +using std::vector; namespace { @@ -130,8 +131,15 @@ OKeySet::OKeySet(const connectivity::OSQLTable& _xTable, OKeySet::~OKeySet() { - tryDispose(m_xStatement); tryDispose(m_xSet); + // m_xStatement is necessarily one of those + const vStatements_t::const_iterator end(m_vStatements.end()); + for(vStatements_t::iterator i(m_vStatements.begin()); + i != end; + ++i) + { + tryDispose(i->second); + } m_xComposer = NULL; @@ -221,13 +229,22 @@ SAL_WNODEPRECATED_DECLARATIONS_POP namespace { - void appendOneKeyColumnClause( const OUString &tblName, const OUString &colName, OUStringBuffer &o_buf ) + void appendOneKeyColumnClause( const OUString &tblName, const OUString &colName, const connectivity::ORowSetValue &_rValue, OUStringBuffer &o_buf ) { - static OUString s_sDot("."); - static OUString s_sParam0(" ( 1 = ? AND "); - static OUString s_sParam1(" = ? OR 1 = ? AND "); - static OUString s_sParam2(" IS NULL ) "); - o_buf.append(s_sParam0 + tblName + s_sDot + colName + s_sParam1 + tblName + s_sDot + colName + s_sParam2); + static const OUString s_sDot("."); + OUString fullName; + if (tblName.isEmpty()) + fullName = colName; + else + fullName = tblName + s_sDot + colName; + if ( _rValue.isNull() ) + { + o_buf.append(fullName + " IS NULL "); + } + else + { + o_buf.append(fullName + " = ? "); + } } } @@ -235,58 +252,60 @@ void OKeySet::setOneKeyColumnParameter( sal_Int32 &nPos, const Reference< XParam { if ( _rValue.isNull() ) { - _xParameter->setByte( nPos++, 0 ); - // We do the full call so that the right sqlType is passed to setNull - setParameter( nPos++, _xParameter, _rValue, _nType, _nScale ); - _xParameter->setByte( nPos++, 1 ); + // Nothing to do, appendOneKeyColumnClause took care of it, + // the "IS NULL" is hardcoded in the query } else { - _xParameter->setByte( nPos++, 1 ); setParameter( nPos++, _xParameter, _rValue, _nType, _nScale ); - _xParameter->setByte( nPos++, 0 ); } } OUStringBuffer OKeySet::createKeyFilter() { - static OUString aAnd(" AND "); + connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aIter = m_aKeyIter->second.first->get().begin(); + + static const OUString aAnd(" AND "); const OUString aQuote = getIdentifierQuoteString(); OUStringBuffer aFilter; // create the where clause Reference<XDatabaseMetaData> xMeta = m_xConnection->getMetaData(); - SelectColumnsMetaData::iterator aPosEnd = m_pKeyColumnNames->end(); - for(SelectColumnsMetaData::iterator aPosIter = m_pKeyColumnNames->begin();aPosIter != aPosEnd;) + SelectColumnsMetaData::const_iterator aPosEnd = m_pKeyColumnNames->end(); + for(SelectColumnsMetaData::const_iterator aPosIter = m_pKeyColumnNames->begin();aPosIter != aPosEnd; ++aPosIter) { - appendOneKeyColumnClause(::dbtools::quoteTableName( xMeta,aPosIter->second.sTableName,::dbtools::eInDataManipulation), - ::dbtools::quoteName( aQuote,aPosIter->second.sRealName), + if ( ! aFilter.isEmpty() ) + aFilter.append(aAnd); + appendOneKeyColumnClause(::dbtools::quoteTableName(xMeta, aPosIter->second.sTableName, ::dbtools::eInDataManipulation), + ::dbtools::quoteName(aQuote, aPosIter->second.sRealName), + *aIter++, aFilter); - ++aPosIter; - if(aPosIter != aPosEnd) + } + aPosEnd = m_pForeignColumnNames->end(); + for(SelectColumnsMetaData::const_iterator aPosIter = m_pForeignColumnNames->begin(); aPosIter != aPosEnd; ++aPosIter) + { + if ( ! aFilter.isEmpty() ) aFilter.append(aAnd); + appendOneKeyColumnClause(::dbtools::quoteTableName(xMeta, aPosIter->second.sTableName, ::dbtools::eInDataManipulation), + ::dbtools::quoteName(aQuote, aPosIter->second.sRealName), + *aIter++, + aFilter); } return aFilter; } -void OKeySet::construct(const Reference< XResultSet>& _xDriverSet,const OUString& i_sRowSetFilter) +void OKeySet::construct(const Reference< XResultSet>& _xDriverSet, const OUString& i_sRowSetFilter) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "ocke.jans...@sun.com", "OKeySet::construct" ); + OCacheSet::construct(_xDriverSet,i_sRowSetFilter); + initColumns(); + m_sRowSetFilter = i_sRowSetFilter; - Reference<XNameAccess> xKeyColumns = getKeyColumns(); Reference<XDatabaseMetaData> xMeta = m_xConnection->getMetaData(); - Reference<XColumnsSupplier> xQueryColSup(m_xComposer,UNO_QUERY); + Reference<XColumnsSupplier> xQueryColSup(m_xComposer, UNO_QUERY); const Reference<XNameAccess> xQueryColumns = xQueryColSup->getColumns(); - findTableColumnsMatching_throw(makeAny(m_xTable),m_sUpdateTableName,xMeta,xQueryColumns,m_pKeyColumnNames); - - // the first row is empty because it's now easier for us to distinguish when we are beforefirst or first - // without extra variable to be set - OKeySetValue keySetValue((ORowSetValueVector *)NULL,::std::pair<sal_Int32,Reference<XRow> >(0,(Reference<XRow>)NULL)); - m_aKeyMap.insert(OKeySetMatrix::value_type(0, keySetValue)); - m_aKeyIter = m_aKeyMap.begin(); - - OUStringBuffer aFilter = createKeyFilter(); + findTableColumnsMatching_throw( makeAny(m_xTable), m_sUpdateTableName, xMeta, xQueryColumns, m_pKeyColumnNames ); Reference< XSingleSelectQueryComposer> xSourceComposer(m_xComposer,UNO_QUERY); Reference< XMultiServiceFactory > xFactory(m_xConnection, UNO_QUERY_THROW); @@ -297,8 +316,6 @@ void OKeySet::construct(const Reference< XResultSet>& _xDriverSet,const OUString const Sequence< OUString> aSeq = xSelectTables->getElementNames(); if ( aSeq.getLength() > 1 ) // special handling for join { - static OUString aAnd(" AND "); - const OUString aQuote = getIdentifierQuoteString(); const OUString* pIter = aSeq.getConstArray(); const OUString* const pEnd = pIter + aSeq.getLength(); for(;pIter != pEnd;++pIter) @@ -309,31 +326,63 @@ void OKeySet::construct(const Reference< XResultSet>& _xDriverSet,const OUString Reference<XPropertySet> xProp(xSelColSup,uno::UNO_QUERY); OUString sSelectTableName = ::dbtools::composeTableName( xMeta, xProp, ::dbtools::eInDataManipulation, false, false, false ); - ::dbaccess::getColumnPositions(xQueryColumns,xSelColSup->getColumns()->getElementNames(),sSelectTableName,(*m_pForeignColumnNames)); + ::dbaccess::getColumnPositions(xQueryColumns, xSelColSup->getColumns()->getElementNames(), sSelectTableName, (*m_pForeignColumnNames), true); - const SelectColumnsMetaData::iterator aPosEnd = (*m_pForeignColumnNames).end(); - for(SelectColumnsMetaData::iterator aPosIter = (*m_pForeignColumnNames).begin();aPosIter != aPosEnd;++aPosIter) - { - // look for columns not in the source columns to use them as filter as well - if ( aFilter.getLength() ) - aFilter.append(aAnd); - appendOneKeyColumnClause(::dbtools::quoteName( aQuote,sSelectTableName), - ::dbtools::quoteName( aQuote,aPosIter->second.sRealName), - aFilter); - } - break; + // LEM: there used to be a break here; however, I see no reason to stop + // at first non-updateTable, so I removed it. (think of multiple joins...) } } } - executeStatement(aFilter,i_sRowSetFilter,xAnalyzer); + + // the first row is empty because it's now easier for us to distinguish when we are beforefirst or first + // without extra variable to be set + OKeySetValue keySetValue((ORowSetValueVector *)NULL,::std::pair<sal_Int32,Reference<XRow> >(0,(Reference<XRow>)NULL)); + m_aKeyMap.insert(OKeySetMatrix::value_type(0, keySetValue)); + m_aKeyIter = m_aKeyMap.begin(); +} + +void OKeySet::ensureStatement( ) +{ + // do we already have a statement for the current combination of NULLness + // of key & foreign columns? + FilterColumnsNULL_t FilterColumnsNULL; + FilterColumnsNULL.reserve(m_aKeyIter->second.first->get().size()); + connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aIter = m_aKeyIter->second.first->get().begin(); + const connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aEnd = m_aKeyIter->second.first->get().end(); + for( ; aIter != aEnd; ++aIter ) + FilterColumnsNULL.push_back(aIter->isNull()); + vStatements_t::iterator pNewStatement(m_vStatements.find(FilterColumnsNULL)); + if(pNewStatement == m_vStatements.end()) + { + // no: make a new one + makeNewStatement(); + std::pair< vStatements_t::iterator, bool > insert_result + (m_vStatements.insert(vStatements_t::value_type(FilterColumnsNULL, m_xStatement))); + assert(insert_result.second); + } + else + // yes: use it + m_xStatement = pNewStatement->second; } -void OKeySet::executeStatement(OUStringBuffer& io_aFilter,const OUString& i_sRowSetFilter,Reference<XSingleSelectQueryComposer>& io_xAnalyzer) + +void OKeySet::makeNewStatement() { - bool bFilterSet = !i_sRowSetFilter.isEmpty(); + Reference< XSingleSelectQueryComposer> xSourceComposer(m_xComposer,UNO_QUERY); + Reference< XMultiServiceFactory > xFactory(m_xConnection, UNO_QUERY_THROW); + Reference<XSingleSelectQueryComposer> xAnalyzer(xFactory->createInstance(SERVICE_NAME_SINGLESELECTQUERYCOMPOSER),UNO_QUERY); + xAnalyzer->setElementaryQuery(xSourceComposer->getElementaryQuery()); + + OUStringBuffer aFilter(createKeyFilter()); + executeStatement(aFilter, xAnalyzer); +} + +void OKeySet::executeStatement(OUStringBuffer& io_aFilter, Reference<XSingleSelectQueryComposer>& io_xAnalyzer) +{ + bool bFilterSet = !m_sRowSetFilter.isEmpty(); if ( bFilterSet ) { FilterCreator aFilterCreator; - aFilterCreator.append( i_sRowSetFilter ); + aFilterCreator.append( m_sRowSetFilter ); aFilterCreator.append( io_aFilter.makeStringAndClear() ); io_aFilter = aFilterCreator.getComposedAndClear(); } @@ -1298,6 +1347,7 @@ sal_Bool SAL_CALL OKeySet::previous( ) throw(SQLException, RuntimeException) bool OKeySet::doTryRefetch_throw() throw(SQLException, RuntimeException) { + ensureStatement( ); // we just reassign the base members Reference< XParameters > xParameter(m_xStatement,UNO_QUERY); OSL_ENSURE(xParameter.is(),"No Parameter interface!"); @@ -1346,7 +1396,7 @@ void SAL_CALL OKeySet::refreshRow() throw(SQLException, RuntimeException) invalidateRow(); - if(isBeforeFirst() || isAfterLast() || !m_xStatement.is()) + if(isBeforeFirst() || isAfterLast()) return; if ( m_aKeyIter->second.second.second.is() ) @@ -1667,16 +1717,19 @@ void getColumnPositions(const Reference<XNameAccess>& _rxQueryColumns, sal_Int32 nNullable = ColumnValue::NULLABLE_UNKNOWN; OSL_VERIFY( xQueryColumnProp->getPropertyValue( PROPERTY_ISNULLABLE ) >>= nNullable ); + SelectColumnDescription aColDesc( nPos, nType, nScale, nNullable != sdbc::ColumnValue::NO_NULLS, sColumnDefault ); + OUString sName; if ( i_bAppendTableName ) { - OUString sName = sTableName + "." + sRealName; - SelectColumnDescription aColDesc( nPos, nType,nScale,nNullable != sdbc::ColumnValue::NO_NULLS, sColumnDefault ); + sName = sTableName + "." + sRealName; aColDesc.sRealName = sRealName; aColDesc.sTableName = sTableName; - o_rColumnNames[sName] = aColDesc; } else - o_rColumnNames[sRealName] = SelectColumnDescription( nPos, nType,nScale,nNullable != sdbc::ColumnValue::NO_NULLS, sColumnDefault ); + { + sName = sRealName; + } + o_rColumnNames[sName] = aColDesc; break; } diff --git a/dbaccess/source/core/api/KeySet.hxx b/dbaccess/source/core/api/KeySet.hxx index 44edc44..1185790 100644 --- a/dbaccess/source/core/api/KeySet.hxx +++ b/dbaccess/source/core/api/KeySet.hxx @@ -25,6 +25,7 @@ #include <cppuhelper/implbase1.hxx> #include <memory> #include <map> +#include <vector> #include <com/sun/star/lang/XUnoTunnel.hpp> #include <com/sun/star/sdb/XSingleSelectQueryAnalyzer.hpp> @@ -91,11 +92,21 @@ namespace dbaccess SAL_WNODEPRECATED_DECLARATIONS_POP connectivity::OSQLTable m_xTable; // reference to our table ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess> m_xTableKeys; + // we need a different SQL (statement) for each different combination + // of NULLness of key & foreign columns; + // each subclause is either "colName = ?" or "colName IS NULL" + // (we avoid the standard "colName IS NOT DISTINCT FROM ?" because it is not widely supported) + typedef ::std::vector< bool > FilterColumnsNULL_t; + typedef ::std::map< FilterColumnsNULL_t, + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > > + vStatements_t; + vStatements_t m_vStatements; ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement> m_xStatement; ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet> m_xSet; ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow> m_xRow; ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryAnalyzer > m_xComposer; - ::rtl::OUString m_sUpdateTableName; + const ::rtl::OUString m_sUpdateTableName; + ::rtl::OUString m_sRowSetFilter; ::std::vector< ::rtl::OUString > m_aFilterColumns; sal_Int32& m_rRowCount; @@ -124,17 +135,19 @@ namespace dbaccess const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& i_xQueryColumns, ::std::auto_ptr<SelectColumnsMetaData>& o_pKeyColumnNames); SAL_WNODEPRECATED_DECLARATIONS_POP + void ensureStatement( ); + virtual void makeNewStatement( ); void setOneKeyColumnParameter( sal_Int32 &nPos, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XParameters > &_xParameter, const connectivity::ORowSetValue &_rValue, sal_Int32 _nType, sal_Int32 _nScale ) const; - ::rtl::OUStringBuffer createKeyFilter(); + ::rtl::OUStringBuffer createKeyFilter( ); bool doTryRefetch_throw() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);; void tryRefetch(const ORowSetRow& _rInsertRow,bool bRefetch); void executeUpdate(const ORowSetRow& _rInsertRow ,const ORowSetRow& _rOrginalRow,const ::rtl::OUString& i_sSQL,const ::rtl::OUString& i_sTableName,const ::std::vector<sal_Int32>& _aIndexColumnPositions = ::std::vector<sal_Int32>()); void executeInsert( const ORowSetRow& _rInsertRow,const ::rtl::OUString& i_sSQL,const ::rtl::OUString& i_sTableName = ::rtl::OUString(),bool bRefetch = false); - void executeStatement(::rtl::OUStringBuffer& io_aFilter,const ::rtl::OUString& i_sRowSetFilter,::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer>& io_xAnalyzer); + void executeStatement(::rtl::OUStringBuffer& io_aFilter, ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer>& io_xAnalyzer); virtual ~OKeySet(); public: diff --git a/dbaccess/source/core/api/OptimisticSet.cxx b/dbaccess/source/core/api/OptimisticSet.cxx index 34f545b..546a984 100644 --- a/dbaccess/source/core/api/OptimisticSet.cxx +++ b/dbaccess/source/core/api/OptimisticSet.cxx @@ -1,4 +1,3 @@ - /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. @@ -108,8 +107,11 @@ OptimisticSet::~OptimisticSet() void OptimisticSet::construct(const Reference< XResultSet>& _xDriverSet,const ::rtl::OUString& i_sRowSetFilter) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "ocke.jans...@sun.com", "OptimisticSet::construct" ); + OCacheSet::construct(_xDriverSet,i_sRowSetFilter); + initColumns(); + m_sRowSetFilter = i_sRowSetFilter; Reference<XDatabaseMetaData> xMeta = m_xConnection->getMetaData(); bool bCase = (xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers()) ? true : false; @@ -134,7 +136,10 @@ void OptimisticSet::construct(const Reference< XResultSet>& _xDriverSet,const :: OKeySetValue keySetValue((ORowSetValueVector *)NULL,::std::pair<sal_Int32,Reference<XRow> >(0,(Reference<XRow>)NULL)); m_aKeyMap.insert(OKeySetMatrix::value_type(0,keySetValue)); m_aKeyIter = m_aKeyMap.begin(); +} +void OptimisticSet::makeNewStatement( ) +{ ::rtl::OUStringBuffer aFilter = createKeyFilter(); Reference< XSingleSelectQueryComposer> xSourceComposer(m_xComposer,UNO_QUERY); @@ -152,12 +157,12 @@ void OptimisticSet::construct(const Reference< XResultSet>& _xDriverSet,const :: fillJoinedColumns_throw(m_aSqlIterator.getJoinConditions()); const ::rtl::OUString sComposerFilter = m_xComposer->getFilter(); - if ( !i_sRowSetFilter.isEmpty() || (!sComposerFilter.isEmpty() && sComposerFilter != i_sRowSetFilter) ) + if ( !m_sRowSetFilter.isEmpty() || (!sComposerFilter.isEmpty() && sComposerFilter != m_sRowSetFilter) ) { FilterCreator aFilterCreator; - if ( !sComposerFilter.isEmpty() && sComposerFilter != i_sRowSetFilter ) + if ( !sComposerFilter.isEmpty() && sComposerFilter != m_sRowSetFilter ) aFilterCreator.append( sComposerFilter ); - aFilterCreator.append( i_sRowSetFilter ); + aFilterCreator.append( m_sRowSetFilter ); aFilterCreator.append( aFilter.makeStringAndClear() ); aFilter = aFilterCreator.getComposedAndClear(); } diff --git a/dbaccess/source/core/api/OptimisticSet.hxx b/dbaccess/source/core/api/OptimisticSet.hxx index a35f18e..0e97233 100644 --- a/dbaccess/source/core/api/OptimisticSet.hxx +++ b/dbaccess/source/core/api/OptimisticSet.hxx @@ -50,6 +50,7 @@ namespace dbaccess void fillJoinedColumns_throw(const ::std::vector< ::connectivity::TNodePair>& i_aJoinColumns); void fillJoinedColumns_throw(const ::rtl::OUString& i_sLeftColumn,const ::rtl::OUString& i_sRightColumn); protected: + virtual void makeNewStatement( ); virtual ~OptimisticSet(); public: OptimisticSet(const ::comphelper::ComponentContext& _rContext, commit a4322a23a90320f013169d9c925b8a6387f3d50a Author: Lionel Elie Mamane <lio...@mamane.lu> Date: Wed Feb 27 06:47:14 2013 +0100 janitorial: save one object Change-Id: I52b7d8204bb2d34639dea544833318fe86a5ddcf diff --git a/dbaccess/source/core/api/KeySet.cxx b/dbaccess/source/core/api/KeySet.cxx index ff036af..6970db2 100644 --- a/dbaccess/source/core/api/KeySet.cxx +++ b/dbaccess/source/core/api/KeySet.cxx @@ -1641,9 +1641,7 @@ void getColumnPositions(const Reference<XNameAccess>& _rxQueryColumns, const OUString* pTblColumnIter = _aColumnNames.getConstArray(); const OUString* pTblColumnEnd = pTblColumnIter + _aColumnNames.getLength(); - - ::comphelper::UStringMixLess aTmp(o_rColumnNames.key_comp()); - ::comphelper::UStringMixEqual bCase(aTmp.isCaseSensitive()); + ::comphelper::UStringMixEqual bCase(o_rColumnNames.key_comp().isCaseSensitive()); for(sal_Int32 nPos = 1;pSelIter != pSelEnd;++pSelIter,++nPos) { commit 0c878187501586072eb74b2867417283bc47fe8c Author: Lionel Elie Mamane <lio...@mamane.lu> Date: Wed Feb 27 06:32:38 2013 +0100 janitorial - more const qualifiers - remove unnecessary cast - don't hardcode magic number (length of hardcoded string) Change-Id: Id8165ec556c913213b5be22c731b78f6b325f22c diff --git a/dbaccess/source/core/api/KeySet.cxx b/dbaccess/source/core/api/KeySet.cxx index 261249b..ff036af 100644 --- a/dbaccess/source/core/api/KeySet.cxx +++ b/dbaccess/source/core/api/KeySet.cxx @@ -300,7 +300,7 @@ void OKeySet::construct(const Reference< XResultSet>& _xDriverSet,const OUString static OUString aAnd(" AND "); const OUString aQuote = getIdentifierQuoteString(); const OUString* pIter = aSeq.getConstArray(); - const OUString* pEnd = pIter + aSeq.getLength(); + const OUString* const pEnd = pIter + aSeq.getLength(); for(;pIter != pEnd;++pIter) { if ( *pIter != m_sUpdateTableName ) @@ -443,12 +443,12 @@ Sequence< sal_Int32 > SAL_CALL OKeySet::deleteRows( const Sequence< Any >& rows OUStringBuffer aCondition("( "); SelectColumnsMetaData::const_iterator aIter = (*m_pKeyColumnNames).begin(); - SelectColumnsMetaData::const_iterator aPosEnd = (*m_pKeyColumnNames).end(); + const SelectColumnsMetaData::const_iterator aPosEnd = (*m_pKeyColumnNames).end(); for(;aIter != aPosEnd;++aIter) { aCondition.append(::dbtools::quoteName( aQuote,aIter->second.sRealName) + aEqual + aAnd); } - aCondition.setLength(aCondition.getLength()-5); + aCondition.setLength(aCondition.getLength() - aAnd.getLength()); const OUString sCon( aCondition.makeStringAndClear() ); const Any* pBegin = rows.getConstArray(); @@ -911,7 +911,7 @@ void OKeySet::copyRowValue(const ORowSetRow& _rInsertRow,ORowSetRow& _rKeyRow,sa // update the key values SelectColumnsMetaData::const_iterator aPosIter = (*m_pKeyColumnNames).begin(); - SelectColumnsMetaData::const_iterator aPosEnd = (*m_pKeyColumnNames).end(); + const SelectColumnsMetaData::const_iterator aPosEnd = (*m_pKeyColumnNames).end(); for(;aPosIter != aPosEnd;++aPosIter,++aIter) { impl_convertValue_throw(_rInsertRow,aPosIter->second); @@ -1325,12 +1325,12 @@ bool OKeySet::doTryRefetch_throw() throw(SQLException, RuntimeException) // now set the primary key column values connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aIter = m_aKeyIter->second.first->get().begin(); - SelectColumnsMetaData::const_iterator aPosIter = (*m_pKeyColumnNames).begin(); - SelectColumnsMetaData::const_iterator aPosEnd = (*m_pKeyColumnNames).end(); + SelectColumnsMetaData::const_iterator aPosIter = m_pKeyColumnNames->begin(); + SelectColumnsMetaData::const_iterator aPosEnd = m_pKeyColumnNames->end(); for(;aPosIter != aPosEnd;++aPosIter,++aIter) setOneKeyColumnParameter(nPos,xParameter,*aIter,aPosIter->second.nType,aPosIter->second.nScale); - aPosIter = (*m_pForeignColumnNames).begin(); - aPosEnd = (*m_pForeignColumnNames).end(); + aPosIter = m_pForeignColumnNames->begin(); + aPosEnd = m_pForeignColumnNames->end(); for(;aPosIter != aPosEnd;++aPosIter,++aIter) setOneKeyColumnParameter(nPos,xParameter,*aIter,aPosIter->second.nType,aPosIter->second.nScale); @@ -1643,7 +1643,7 @@ void getColumnPositions(const Reference<XNameAccess>& _rxQueryColumns, ::comphelper::UStringMixLess aTmp(o_rColumnNames.key_comp()); - ::comphelper::UStringMixEqual bCase(static_cast< ::comphelper::UStringMixLess*>(&aTmp)->isCaseSensitive()); + ::comphelper::UStringMixEqual bCase(aTmp.isCaseSensitive()); for(sal_Int32 nPos = 1;pSelIter != pSelEnd;++pSelIter,++nPos) { commit 1b77302ef95f1eaf77baabd98883ed649fa25242 Author: Lionel Elie Mamane <lio...@mamane.lu> Date: Wed Feb 27 06:30:56 2013 +0100 spelling in comments Change-Id: I3a7df167a91dd6ef845d16d5e6cf46ff5a82d455 diff --git a/dbaccess/source/core/api/KeySet.cxx b/dbaccess/source/core/api/KeySet.cxx index 99022cf..261249b 100644 --- a/dbaccess/source/core/api/KeySet.cxx +++ b/dbaccess/source/core/api/KeySet.cxx @@ -182,7 +182,7 @@ void OKeySet::findTableColumnsMatching_throw( const Any& i_aTable, // For instance, imagine a "SELECT alias.col FROM table AS alias". Now i_aTable would be the table named // "table", so our sUpdateTableName would be "table" as well - not the information about the "alias" is // already lost here. - // now getColumnPositions would travers the columns, and check which of them belong to the table denoted + // now getColumnPositions would traverse the columns, and check which of them belong to the table denoted // by sUpdateTableName. Since the latter is "table", but the columns only know that they belong to a table // named "alias", there will be no matching - so getColumnPositions wouldn't find anything. @@ -518,7 +518,7 @@ void SAL_CALL OKeySet::updateRow(const ORowSetRow& _rInsertRow ,const ORowSetRow OUString sIsNull(" IS NULL"); OUString sParam(" = ?"); - // use keys and indexes for excat postioning + // use keys and indexes for exact postioning // first the keys Reference<XNameAccess> xKeyColumns = getKeyColumns(); @@ -1042,7 +1042,7 @@ void SAL_CALL OKeySet::moveToCurrentRow( ) throw(SQLException, RuntimeException Reference<XNameAccess> OKeySet::getKeyColumns() const { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "ocke.jans...@sun.com", "OKeySet::getKeyColumns" ); - // use keys and indexes for excat postioning + // use keys and indexes for exact postioning // first the keys Reference<XIndexAccess> xKeys = m_xTableKeys; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits