summaryrefslogtreecommitdiff
path: root/dbaccess/source/core/api/RowSetCache.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'dbaccess/source/core/api/RowSetCache.cxx')
-rw-r--r--dbaccess/source/core/api/RowSetCache.cxx136
1 files changed, 68 insertions, 68 deletions
diff --git a/dbaccess/source/core/api/RowSetCache.cxx b/dbaccess/source/core/api/RowSetCache.cxx
index 3710a0e0c108..6ff4fdaa584c 100644
--- a/dbaccess/source/core/api/RowSetCache.cxx
+++ b/dbaccess/source/core/api/RowSetCache.cxx
@@ -2,7 +2,7 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
@@ -86,8 +86,8 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs,
const Reference< XSingleSelectQueryAnalyzer >& _xAnalyzer,
const ::comphelper::ComponentContext& _rContext,
const ::rtl::OUString& _rUpdateTableName,
- sal_Bool& _bModified,
- sal_Bool& _bNew,
+ sal_Bool& _bModified,
+ sal_Bool& _bNew,
const ORowSetValueVector& _aParameterValueForCache,
const ::rtl::OUString& i_sRowSetFilter)
:m_xSet(_xRs)
@@ -170,7 +170,7 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs,
OSL_ENSURE(xTabSup.is(),"ORowSet::execute composer isn't a tablesupplier!");
Reference<XNameAccess> xTables = xTabSup->getTables();
Sequence< ::rtl::OUString> aTableNames = xTables->getElementNames();
- if ( aTableNames.getLength() > 1 && !_rUpdateTableName.getLength() && bNeedKeySet )
+ if ( aTableNames.getLength() > 1 && !_rUpdateTableName.getLength() && bNeedKeySet )
{// here we have a join or union and nobody told us which table to update, so we update them all
m_nPrivileges = Privilege::SELECT|Privilege::DELETE|Privilege::INSERT|Privilege::UPDATE;
OptimisticSet* pCursor = new OptimisticSet(m_aContext,xConnection,_xAnalyzer,_aParameterValueForCache);
@@ -279,8 +279,8 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs,
Reference<XDatabaseMetaData> xMeta = xConnection->getMetaData();
SelectColumnsMetaData aColumnNames(xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers() ? true : false);
Reference<XColumnsSupplier> xColSup(_xAnalyzer,UNO_QUERY);
- Reference<XNameAccess> xSelColumns = xColSup->getColumns();
- Reference<XNameAccess> xColumns = m_aUpdateTable->getColumns();
+ Reference<XNameAccess> xSelColumns = xColSup->getColumns();
+ Reference<XNameAccess> xColumns = m_aUpdateTable->getColumns();
::dbaccess::getColumnPositions(xSelColumns,xColumns->getElementNames(),aUpdateTableName,aColumnNames);
// check privileges
@@ -288,8 +288,8 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs,
sal_Bool bNoInsert = sal_False;
Sequence< ::rtl::OUString> aNames(xColumns->getElementNames());
- const ::rtl::OUString* pIter = aNames.getConstArray();
- const ::rtl::OUString* pEnd = pIter + aNames.getLength();
+ const ::rtl::OUString* pIter = aNames.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + aNames.getLength();
for(;pIter != pEnd;++pIter)
{
Reference<XPropertySet> xColumn(xColumns->getByName(*pIter),UNO_QUERY);
@@ -362,9 +362,9 @@ ORowSetCache::~ORowSetCache()
m_pInsertMatrix->clear();
delete m_pInsertMatrix;
}
- m_xSet = WeakReference< XResultSet>();
- m_xMetaData = NULL;
- m_aUpdateTable = NULL;
+ m_xSet = WeakReference< XResultSet>();
+ m_xMetaData = NULL;
+ m_aUpdateTable = NULL;
DBG_DTOR(ORowSetCache,NULL);
}
@@ -383,7 +383,7 @@ void ORowSetCache::setMaxRowSize(sal_Int32 _nSize)
m_aMatrixEnd = m_pMatrix->end();
m_pInsertMatrix = new ORowSetMatrix(1); // a little bit overkill but ??? :-)
- m_aInsertRow = m_pInsertMatrix->end();
+ m_aInsertRow = m_pInsertMatrix->end();
}
else
{
@@ -416,7 +416,7 @@ void ORowSetCache::setMaxRowSize(sal_Int32 _nSize)
// now adjust their positions because a resize invalid all iterators
::std::vector<sal_Int32>::const_iterator aIter = aPositions.begin();
::std::map<sal_Int32,sal_Bool>::const_iterator aPosChangeIter = aCacheIterToChange.begin();
- for( aCacheIter = m_aCacheIterators.begin();
+ for( aCacheIter = m_aCacheIterators.begin();
aPosChangeIter != aCacheIterToChange.end();
++aPosChangeIter,++aCacheIter)
{
@@ -480,7 +480,7 @@ sal_Bool ORowSetCache::moveToBookmark( const Any& bookmark )
if ( m_pCacheSet->moveToBookmark(bookmark) )
{
m_bBeforeFirst = sal_False;
- m_nPosition = m_pCacheSet->getRow();
+ m_nPosition = m_pCacheSet->getRow();
checkPositionFlags();
@@ -512,7 +512,7 @@ sal_Bool ORowSetCache::moveRelativeToBookmark( const Any& bookmark, sal_Int32 ro
{
m_nPosition = m_pCacheSet->getRow() + rows;
absolute(m_nPosition);
- // for(sal_Int32 i=0;i<rows && m_aMatrixIter != m_pMatrix->end();++i,++m_aMatrixIter) ;
+ // for(sal_Int32 i=0;i<rows && m_aMatrixIter != m_pMatrix->end();++i,++m_aMatrixIter) ;
bRet = m_aMatrixIter != m_pMatrix->end() && (*m_aMatrixIter).is();
}
@@ -592,7 +592,7 @@ void ORowSetCache::updateCharacterStream( sal_Int32 columnIndex, const Reference
void ORowSetCache::updateObject( sal_Int32 columnIndex, const Any& x
,ORowSetValueVector::Vector& io_aRow
- ,::std::vector<sal_Int32>& o_ChangedColumns
+ ,::std::vector<sal_Int32>& o_ChangedColumns
)
{
checkUpdateConditions(columnIndex);
@@ -649,7 +649,7 @@ sal_Bool ORowSetCache::next( )
sal_Bool ORowSetCache::isBeforeFirst( )
{
- // return !m_nPosition;
+ // return !m_nPosition;
return m_bBeforeFirst;
}
@@ -668,7 +668,7 @@ sal_Bool ORowSetCache::isFirst( )
sal_Bool ORowSetCache::isLast( )
{
- // return m_bRowCountFinal ? (m_nPosition==m_nRowCount) : m_pCacheSet->isLast();
+ // return m_bRowCountFinal ? (m_nPosition==m_nRowCount) : m_pCacheSet->isLast();
return m_nPosition == m_nRowCount;
}
@@ -679,9 +679,9 @@ sal_Bool ORowSetCache::beforeFirst( )
if(!m_bBeforeFirst)
{
- m_bAfterLast = sal_False;
- m_nPosition = 0;
- m_bBeforeFirst = sal_True;
+ m_bAfterLast = sal_False;
+ m_nPosition = 0;
+ m_bBeforeFirst = sal_True;
m_pCacheSet->beforeFirst();
moveWindow();
m_aMatrixIter = m_pMatrix->end();
@@ -729,7 +729,7 @@ sal_Bool ORowSetCache::fillMatrix(sal_Int32& _nNewStartPos,sal_Int32 _nNewEndPos
m_pCacheSet->fillValueRow(*aIter,i);
}
else
- { // there are no more rows found so we can fetch some before start
+ { // there are no more rows found so we can fetch some before start
if(!m_bRowCountFinal)
{
@@ -764,7 +764,7 @@ sal_Bool ORowSetCache::fillMatrix(sal_Int32& _nNewStartPos,sal_Int32 _nNewEndPos
}
bCheck = m_pCacheSet->next();
}
- // m_nStartPos = _nNewStartPos;
+ // m_nStartPos = _nNewStartPos;
// we have to read one row forward to enshure that we know when we are on last row
// but only when we don't know it already
if(!m_bRowCountFinal)
@@ -788,17 +788,17 @@ sal_Bool ORowSetCache::moveWindow()
sal_Bool bRet = sal_True;
sal_Int32 nDiff = (sal_Int32)(m_nFetchSize*0.5 -0.5);
- sal_Int32 nNewStartPos = (m_nPosition - nDiff);
- // sal_Int32 nNewEndPos = (m_nPosition+m_nFetchSize*0.5);
- sal_Int32 nNewEndPos = nNewStartPos + m_nFetchSize;
+ sal_Int32 nNewStartPos = (m_nPosition - nDiff);
+ // sal_Int32 nNewEndPos = (m_nPosition+m_nFetchSize*0.5);
+ sal_Int32 nNewEndPos = nNewStartPos + m_nFetchSize;
if ( m_nPosition <= m_nStartPos )
- { // the window is behind the new start pos
+ { // the window is behind the new start pos
if(!m_nStartPos)
return sal_False;
// the new position should be the nPos - nFetchSize/2
if ( nNewEndPos > m_nStartPos )
- { // but the two regions are overlapping
+ { // but the two regions are overlapping
// fill the rows behind the new end
ORowSetMatrix::iterator aEnd; // the iterator we need for rotate
@@ -808,7 +808,7 @@ sal_Bool ORowSetCache::moveWindow()
if ( nNewStartPos < 1 )
{
bCheck = m_pCacheSet->first();
- // aEnd = m_pMatrix->begin() + (sal_Int32)(m_nFetchSize*0.5);
+ // aEnd = m_pMatrix->begin() + (sal_Int32)(m_nFetchSize*0.5);
OSL_ENSURE((nNewEndPos - m_nStartPos - nNewStartPos) < (sal_Int32)m_pMatrix->size(),"Position is behind end()!");
aEnd = m_pMatrix->begin() + (nNewEndPos - m_nStartPos - nNewStartPos);
aIter = aEnd;
@@ -830,7 +830,7 @@ sal_Bool ORowSetCache::moveWindow()
::std::rotate(m_pMatrix->begin(),aEnd,m_pMatrix->end());
// now correct the iterator in our iterator vector
- // rotateCacheIterator(aEnd-m_pMatrix->begin()); //can't be used because they decrement and here we need to increment
+ // rotateCacheIterator(aEnd-m_pMatrix->begin()); //can't be used because they decrement and here we need to increment
ptrdiff_t nNewDist = aEnd - m_pMatrix->begin();
ptrdiff_t nOffSet = m_pMatrix->end() - aEnd;
ORowSetCacheMap::iterator aCacheIter = m_aCacheIterators.begin();
@@ -899,10 +899,10 @@ sal_Bool ORowSetCache::moveWindow()
}
}
else if(m_nPosition > m_nStartPos)
- { // the new start pos is above the startpos of the window
+ { // the new start pos is above the startpos of the window
if(m_nPosition <= (m_nStartPos+m_nFetchSize))
- { // position in window
+ { // position in window
OSL_ENSURE((m_nPosition - m_nStartPos -1) < (sal_Int32)m_pMatrix->size(),"Position is behind end()!");
m_aMatrixIter = calcPosition();
if(!m_aMatrixIter->is())
@@ -933,7 +933,7 @@ sal_Bool ORowSetCache::moveWindow()
}
}
else if(nNewStartPos < (m_nStartPos+m_nFetchSize))
- { // position behind window but the region is overlapping
+ { // position behind window but the region is overlapping
// the rows from begin() to (begin + nNewStartPos - m_nStartPos) can be refilled with the new rows
// the rows behind this can be reused
ORowSetMatrix::iterator aIter = m_pMatrix->begin();
@@ -944,9 +944,9 @@ sal_Bool ORowSetCache::moveWindow()
sal_Bool bCheck = m_pCacheSet->absolute(nPos);
bCheck = fill(aIter,aEnd,nPos,bCheck); // refill the region wew don't need anymore
-// // we know that this is the current maximal rowcount here
-// if ( !m_bRowCountFinal && bCheck )
-// m_nRowCount = std::max(nPos,m_nRowCount);
+// // we know that this is the current maximal rowcount here
+// if ( !m_bRowCountFinal && bCheck )
+// m_nRowCount = std::max(nPos,m_nRowCount);
// we have to read one row forward to enshure that we know when we are on last row
// but only when we don't know it already
sal_Bool bOk = sal_True;
@@ -954,7 +954,7 @@ sal_Bool ORowSetCache::moveWindow()
bOk = m_pCacheSet->next();
// bind end to front
if(bCheck)
- { // rotate the end to the front
+ { // rotate the end to the front
::std::rotate(m_pMatrix->begin(),aIter,m_pMatrix->end());
// now correct the iterator in our iterator vector
rotateCacheIterator( (sal_Int16)( aIter - m_pMatrix->begin() ) );
@@ -963,30 +963,30 @@ sal_Bool ORowSetCache::moveWindow()
if(!bOk)
{
m_pCacheSet->previous(); // because we stand after the last row
- m_nRowCount = nPos; // here we have the row count
+ m_nRowCount = nPos; // here we have the row count
m_bRowCountFinal = sal_True;
}
else if(!m_bRowCountFinal)
m_nRowCount = std::max(++nPos,m_nRowCount);
}
else
- { // the end was reached before end() so we can set the start before nNewStartPos
+ { // the end was reached before end() so we can set the start before nNewStartPos
m_nStartPos += (aIter - m_pMatrix->begin());
- // m_nStartPos = (aIter - m_pMatrix->begin());
+ // m_nStartPos = (aIter - m_pMatrix->begin());
::std::rotate(m_pMatrix->begin(),aIter,m_pMatrix->end());
// now correct the iterator in our iterator vector
rotateCacheIterator( (sal_Int16)( aIter - m_pMatrix->begin() ) );
if ( !m_bRowCountFinal )
{
- m_pCacheSet->previous(); // because we stand after the last row
- m_nRowCount = std::max(m_nRowCount,--nPos); // here we have the row count
+ m_pCacheSet->previous(); // because we stand after the last row
+ m_nRowCount = std::max(m_nRowCount,--nPos); // here we have the row count
OSL_ENSURE(nPos == m_pCacheSet->getRow(),"nPos isn't valid!");
m_bRowCountFinal = sal_True;
}
// TODO check
- // m_nStartPos = (nNewStartPos+m_nRowCount) - m_nFetchSize ;
+ // m_nStartPos = (nNewStartPos+m_nRowCount) - m_nFetchSize ;
if(m_nStartPos < 0)
m_nStartPos = 0;
}
@@ -995,8 +995,8 @@ sal_Bool ORowSetCache::moveWindow()
{
aIter = m_pMatrix->begin();
- nPos = m_nStartPos;
- bCheck = m_pCacheSet->absolute(m_nStartPos);
+ nPos = m_nStartPos;
+ bCheck = m_pCacheSet->absolute(m_nStartPos);
for(; !aIter->is() && bCheck;++aIter)
{
OSL_ENSURE(aIter != m_pMatrix->end(),"Invalid iterator");
@@ -1029,10 +1029,10 @@ sal_Bool ORowSetCache::first( )
sal_Bool bRet = m_pCacheSet->first();
if(bRet)
{
- m_bBeforeFirst = m_bAfterLast = sal_False;
- m_nPosition = 1;
+ m_bBeforeFirst = m_bAfterLast = sal_False;
+ m_nPosition = 1;
moveWindow();
- m_aMatrixIter = m_pMatrix->begin();
+ m_aMatrixIter = m_pMatrix->begin();
}
else
{
@@ -1105,8 +1105,8 @@ sal_Bool ORowSetCache::absolute( sal_Int32 row )
}
else
{
- m_bBeforeFirst = sal_False;
- m_bAfterLast = m_nPosition > m_nRowCount;
+ m_bBeforeFirst = sal_False;
+ m_bAfterLast = m_nPosition > m_nRowCount;
moveWindow();
OSL_ENSURE(((m_nPosition - m_nStartPos) - 1) < (sal_Int32)m_pMatrix->size(),"Position is behind end()!");
m_aMatrixIter = calcPosition();
@@ -1119,7 +1119,7 @@ sal_Bool ORowSetCache::absolute( sal_Int32 row )
{
m_nPosition = row;
// the position flags
- m_bBeforeFirst = sal_False;
+ m_bBeforeFirst = sal_False;
checkPositionFlags();
if(!m_bAfterLast)
@@ -1260,13 +1260,13 @@ void ORowSetCache::resetInsertRow(sal_Bool _bClearInsertRow)
{
if ( _bClearInsertRow )
clearInsertRow();
- m_bNew = sal_False;
+ m_bNew = sal_False;
m_bModified = sal_False;
}
void ORowSetCache::cancelRowModification()
{
- // clear the insertrow references -> implies that the current row of the rowset changes as well
+ // 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();
for(;aCacheIter != aCacheEnd;++aCacheIter)
@@ -1290,7 +1290,7 @@ void ORowSetCache::updateRow( ORowSetMatrix::iterator& _rUpdateRow,::std::vector
m_pCacheSet->updateRow(*_rUpdateRow,*m_aMatrixIter,m_aUpdateTable);
// refetch the whole row
(*m_aMatrixIter) = NULL;
-
+
if ( moveToBookmark(aBookmark) )
{
// update the cached values
@@ -1313,7 +1313,7 @@ bool ORowSetCache::deleteRow( )
if(isAfterLast() || isBeforeFirst())
throw SQLException(DBACORE_RESSTRING(RID_STR_NO_DELETEROW),NULL,SQLSTATE_GENERAL,1000,Any() );
- // m_pCacheSet->absolute(m_nPosition);
+ // m_pCacheSet->absolute(m_nPosition);
m_pCacheSet->deleteRow(*m_aMatrixIter,m_aUpdateTable);
if ( !m_pCacheSet->rowDeleted() )
return false;
@@ -1321,13 +1321,13 @@ bool ORowSetCache::deleteRow( )
--m_nRowCount;
OSL_ENSURE(((m_nPosition - m_nStartPos) - 1) < (sal_Int32)m_pMatrix->size(),"Position is behind end()!");
ORowSetMatrix::iterator aPos = calcPosition();
- (*aPos) = NULL;
+ (*aPos) = NULL;
ORowSetMatrix::iterator aEnd = m_pMatrix->end();
for(++aPos;aPos != aEnd && aPos->is();++aPos)
{
*(aPos-1) = *aPos;
- (*aPos) = NULL;
+ (*aPos) = NULL;
}
m_aMatrixIter = m_pMatrix->end();
@@ -1355,8 +1355,8 @@ void ORowSetCache::cancelRowUpdates( )
void ORowSetCache::moveToInsertRow( )
{
- m_bNew = sal_True;
- m_bUpdated = m_bAfterLast = sal_False;
+ m_bNew = sal_True;
+ m_bUpdated = m_bAfterLast = sal_False;
m_aInsertRow = m_pInsertMatrix->begin();
if(!m_aInsertRow->is())
@@ -1445,7 +1445,7 @@ void ORowSetCache::checkPositionFlags()
{
if(m_bRowCountFinal)
{
- m_bAfterLast = m_nPosition > m_nRowCount;
+ m_bAfterLast = m_nPosition > m_nRowCount;
if(m_bAfterLast)
m_nPosition = 0;//m_nRowCount;
}
@@ -1460,13 +1460,13 @@ void ORowSetCache::checkUpdateConditions(sal_Int32 columnIndex)
sal_Bool ORowSetCache::checkInnerJoin(const ::connectivity::OSQLParseNode *pNode,const Reference< XConnection>& _xConnection,const ::rtl::OUString& _sUpdateTableName)
{
sal_Bool bOk = sal_False;
- if (pNode->count() == 3 && // Ausdruck is geklammert
+ if (pNode->count() == 3 && // Ausdruck is geklammert
SQL_ISPUNCTUATION(pNode->getChild(0),"(") &&
SQL_ISPUNCTUATION(pNode->getChild(2),")"))
{
bOk = checkInnerJoin(pNode->getChild(1),_xConnection,_sUpdateTableName);
}
- else if ((SQL_ISRULE(pNode,search_condition) || SQL_ISRULE(pNode,boolean_term)) && // AND/OR-Verknuepfung:
+ else if ((SQL_ISRULE(pNode,search_condition) || SQL_ISRULE(pNode,boolean_term)) && // AND/OR-Verknuepfung:
pNode->count() == 3)
{
// nur AND Verknüpfung zulassen
@@ -1515,15 +1515,15 @@ sal_Bool ORowSetCache::checkJoin(const Reference< XConnection>& _xConnection,
OSQLParseNode* pJoin = pTableRefCommalist->getByRule(::connectivity::OSQLParseNode::qualified_join);
if(pJoin)
{ // we are only intereseted in qualified joins like RIGHT or LEFT
- OSQLParseNode* pJoinType = pJoin->getChild(1);
- OSQLParseNode* pOuterType = NULL;
+ OSQLParseNode* pJoinType = pJoin->getChild(1);
+ OSQLParseNode* pOuterType = NULL;
if(SQL_ISRULE(pJoinType,join_type) && pJoinType->count() == 2)
pOuterType = pJoinType->getChild(0);
else if(SQL_ISRULE(pJoinType,outer_join_type))
pOuterType = pJoinType;
- sal_Bool bCheck = sal_False;
- sal_Bool bLeftSide = sal_False;
+ sal_Bool bCheck = sal_False;
+ sal_Bool bLeftSide = sal_False;
if(pOuterType)
{ // found outer join
bLeftSide = SQL_ISTOKEN(pOuterType->getChild(0),LEFT);
@@ -1572,7 +1572,7 @@ void ORowSetCache::clearInsertRow()
}
}
-ORowSetMatrix::iterator ORowSetCache::calcPosition() const
+ORowSetMatrix::iterator ORowSetCache::calcPosition() const
{
sal_Int32 nValue = (m_nPosition - m_nStartPos) - 1;
CHECK_MATRIX_POS(nValue);
@@ -1666,7 +1666,7 @@ void ORowSetCache::impl_updateRowFromCache_throw(ORowSetValueVector::Vector& io_
break;
}
}
-
+
if ( aIter == m_pMatrix->end() )
{
m_pCacheSet->fillMissingValues(io_aRow);