diff options
author | Lionel Elie Mamane <lionel@mamane.lu> | 2015-01-22 10:49:42 +0100 |
---|---|---|
committer | Lionel Elie Mamane <lionel@mamane.lu> | 2015-01-22 13:18:53 +0100 |
commit | d7c9a1d9d65fe8b1a56c5c280d2ca6640a549d2f (patch) | |
tree | 5a0d60174eb2df5f7514a2f4c6e25ad41a59d75d /dbaccess | |
parent | b1dbc511eeaf88e3b4b5a8a2dce129d251d2dcb6 (diff) |
fdo#88475 RowSetBase: reposition cache before interrogating it
This partially reverts:
commit d20232a77565f46fedc0b556f4d50addff4d3559
Author: Lionel Elie Mamane <lionel@mamane.lu>
Date: Thu Dec 6 13:22:06 2012 +0100
Don't force refresh when higher up code did not request it
Change-Id: I0f415c96fc05c1d776d14885751aef020c42f4ae
which did not take into account that the cache is shared with the
clones.
Finish the above commit more deeply, that is
more aggressively avoid moving the cache if we don't need to:
when we merely reposition the cache in case another RowSet(Clone)
has moved it, no need to force a move and by that to force a refresh.
Change-Id: I28d62673fdf10ee6507d38bb7c79c08e4b40902f
Diffstat (limited to 'dbaccess')
-rw-r--r-- | dbaccess/source/core/api/RowSet.cxx | 8 | ||||
-rw-r--r-- | dbaccess/source/core/api/RowSetBase.cxx | 23 | ||||
-rw-r--r-- | dbaccess/source/core/api/RowSetBase.hxx | 8 |
3 files changed, 19 insertions, 20 deletions
diff --git a/dbaccess/source/core/api/RowSet.cxx b/dbaccess/source/core/api/RowSet.cxx index 0756e8b0a1cd..079673d307cc 100644 --- a/dbaccess/source/core/api/RowSet.cxx +++ b/dbaccess/source/core/api/RowSet.cxx @@ -1019,7 +1019,7 @@ void SAL_CALL ORowSet::deleteRow( ) throw(SQLException, RuntimeException, std:: // this call position the cache indirect Any aBookmarkToDelete( m_aBookmark ); - positionCache( MOVE_NONE_REFRESH_ONLY ); + positionCache( MOVE_NONE ); sal_Int32 nDeletePosition = m_pCache->getRow(); notifyRowSetAndClonesRowDelete( aBookmarkToDelete ); @@ -1066,7 +1066,7 @@ void ORowSet::implCancelRowUpdates( bool _bNotifyModified ) if ( m_bNew || m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY ) throwFunctionSequenceException(*this); - positionCache( MOVE_NONE_REFRESH_ONLY ); + positionCache( MOVE_NONE ); ORowSetRow aOldValues; if ( !m_bModified && _bNotifyModified && !m_aCurrentRow.isNull() ) @@ -1194,7 +1194,7 @@ void SAL_CALL ORowSet::moveToInsertRow( ) throw(SQLException, RuntimeException, setCurrentRow( true, false, aOldValues, aGuard); } else - positionCache( MOVE_NONE_REFRESH_ONLY ); + positionCache( MOVE_NONE ); // check before because the resultset could be empty if ( !m_bBeforeFirst @@ -1283,7 +1283,7 @@ void SAL_CALL ORowSet::moveToCurrentRow( ) throw(SQLException, RuntimeException if ( notifyAllListenersCursorBeforeMove( aGuard ) ) { - positionCache( MOVE_NONE_REFRESH_ONLY ); + positionCache( MOVE_NONE_REFRESH ); ORowSetNotifier aNotifier( this ); diff --git a/dbaccess/source/core/api/RowSetBase.cxx b/dbaccess/source/core/api/RowSetBase.cxx index 57a3dc12e7b6..bfaf44d5421b 100644 --- a/dbaccess/source/core/api/RowSetBase.cxx +++ b/dbaccess/source/core/api/RowSetBase.cxx @@ -221,7 +221,7 @@ const ORowSetValue& ORowSetBase::impl_getValue(sal_Int32 columnIndex) if ( !bValidCurrentRow ) { // currentrow is null when the clone moves the window - positionCache( MOVE_NONE_REFRESH_ONLY ); + positionCache( MOVE_NONE ); m_aCurrentRow = m_pCache->m_aMatrixIter; m_bIsInsertRow = false; OSL_ENSURE(!m_aCurrentRow.isNull(),"ORowSetBase::getValue: we don't stand on a valid row! Row is null."); @@ -348,7 +348,7 @@ Reference< ::com::sun::star::io::XInputStream > SAL_CALL ORowSetBase::getBinaryS bool bValidCurrentRow = ( !m_aCurrentRow.isNull() && m_aCurrentRow != m_pCache->getEnd() && m_aCurrentRow->is() ); if ( !bValidCurrentRow ) { - positionCache( MOVE_NONE_REFRESH_ONLY ); + positionCache( MOVE_NONE ); m_aCurrentRow = m_pCache->m_aMatrixIter; m_bIsInsertRow = false; OSL_ENSURE(!m_aCurrentRow.isNull(),"ORowSetBase::getBinaryStream: we don't stand on a valid row! Row is null."); @@ -657,6 +657,7 @@ sal_Bool SAL_CALL ORowSetBase::isFirst( ) throw(SQLException, RuntimeException, if ( impl_rowDeleted() ) return ( m_nDeletedPosition == 1 ); + positionCache( MOVE_NONE ); bool bIsFirst = m_pCache->isFirst(); SAL_INFO("dbaccess", "ORowSetBase::isFirst() = " << bIsFirst << " Clone = " << m_bClone); @@ -686,6 +687,7 @@ sal_Bool SAL_CALL ORowSetBase::isLast( ) throw(SQLException, RuntimeException, return ( m_nDeletedPosition == impl_getRowCount() ); } + positionCache( MOVE_NONE ); bool bIsLast = m_pCache->isLast(); SAL_INFO("dbaccess", "ORowSetBase::isLast() = " << bIsLast << " Clone = " << m_bClone); @@ -857,13 +859,7 @@ sal_Int32 ORowSetBase::impl_getRow() nPos = 0; else { - if ( m_pCache->isAfterLast() - || m_pCache->isBeforeFirst() - || ( m_pCache->compareBookmarks( m_aBookmark, m_pCache->getBookmark() ) != CompareBookmark::EQUAL ) - ) - { - positionCache( MOVE_NONE_REFRESH_ONLY ); - } + positionCache( MOVE_NONE ); nPos = m_pCache->getRow(); } SAL_INFO("dbaccess", "ORowSetBase::impl_getRow() = " << nPos << " Clone = " << m_bClone); @@ -1103,7 +1099,7 @@ void SAL_CALL ORowSetBase::refreshRow( ) throw(SQLException, RuntimeException, { bool bWasNew = m_pCache->m_bNew || impl_rowDeleted(); ORowSetRow aOldValues = getOldRow(bWasNew); - positionCache( MOVE_NONE_REFRESH_ONLY ); + positionCache( MOVE_NONE ); m_pCache->refreshRow(); firePropertyChange(aOldValues); } @@ -1237,7 +1233,7 @@ void ORowSetBase::positionCache( CursorMoveDirection _ePrepareForDirection ) bool bSuccess = false; if ( m_aBookmark.hasValue() ) { - if ( _ePrepareForDirection == MOVE_NONE_REFRESH_ONLY || + if (_ePrepareForDirection == MOVE_NONE_REFRESH || m_pCache->compareBookmarks( m_aBookmark, m_pCache->getBookmark() ) != CompareBookmark::EQUAL ) bSuccess = m_pCache->moveToBookmark( m_aBookmark ); else @@ -1278,7 +1274,8 @@ void ORowSetBase::positionCache( CursorMoveDirection _ePrepareForDirection ) bSuccess = m_pCache->absolute( m_nDeletedPosition ); break; - case MOVE_NONE_REFRESH_ONLY: + case MOVE_NONE: + case MOVE_NONE_REFRESH: bSuccess = false; // will be asserted below break; } @@ -1334,7 +1331,7 @@ void ORowSetBase::onDeleteRow( const Any& _rBookmark ) //OSL_ENSURE( m_aBookmark.hasValue(), "ORowSetBase::onDeleteRow: Bookmark isn't valid!" ); if ( compareBookmarks( _rBookmark, m_aBookmark ) == 0 ) { - positionCache( MOVE_NONE_REFRESH_ONLY ); + positionCache( MOVE_NONE ); m_nDeletedPosition = m_pCache->getRow(); } } diff --git a/dbaccess/source/core/api/RowSetBase.hxx b/dbaccess/source/core/api/RowSetBase.hxx index 00bb7cd250dc..9f23bd06199e 100644 --- a/dbaccess/source/core/api/RowSetBase.hxx +++ b/dbaccess/source/core/api/RowSetBase.hxx @@ -155,8 +155,10 @@ namespace dbaccess MOVE_FORWARD, /// denotes a cursor move backwards MOVE_BACKWARD, - /// denotes no cursor move at all, used when the current row is to be refreshed only - MOVE_NONE_REFRESH_ONLY + /// denotes no cursor move at all, but move cache to current row (if it is not there already) + MOVE_NONE, + /// denotes no cursor move at all, but force the cache to move to current row (and refresh the row) + MOVE_NONE_REFRESH }; /** positions the cache in preparation of a cursor move @@ -170,7 +172,7 @@ namespace dbaccess m_aBookmark.</br> If, however, we're currently on a deleted row, this is used to properly position the cache using <member>m_nDeletedPosition</member>.<br/> - In this case, MOVE_NONE_REFRESH_ONLY is not supported. This is because the deleted row + In this case, MOVE_NONE(_REFRESH) is not supported. This is because the deleted row (to which the RowSet currently points to) is not present in the cache. So, you cannot move the cache to this row. */ |