summaryrefslogtreecommitdiff
path: root/dbaccess
diff options
context:
space:
mode:
authorOcke Janssen [oj] <Ocke.Janssen@oracle.com>2011-01-06 12:32:17 +0100
committerOcke Janssen [oj] <Ocke.Janssen@oracle.com>2011-01-06 12:32:17 +0100
commit54b40663d23e6a56ce1dabb05a385d895958de34 (patch)
tree4d5a697c8b624d15805fe98d1dfdcf0f910873f1 /dbaccess
parentb68968b86cc749515b42a80884491793cd21d033 (diff)
dba34c: #i113405# remove row from rowset when it can not be accessed anymore and adjust rowcount
Diffstat (limited to 'dbaccess')
-rw-r--r--dbaccess/source/core/api/KeySet.cxx23
-rw-r--r--dbaccess/source/core/api/KeySet.hxx4
-rw-r--r--dbaccess/source/core/api/OptimisticSet.cxx5
-rw-r--r--dbaccess/source/core/api/OptimisticSet.hxx3
-rw-r--r--dbaccess/source/core/api/RowSetCache.cxx8
5 files changed, 27 insertions, 16 deletions
diff --git a/dbaccess/source/core/api/KeySet.cxx b/dbaccess/source/core/api/KeySet.cxx
index 932314b72fbe..21dc7d8443e6 100644
--- a/dbaccess/source/core/api/KeySet.cxx
+++ b/dbaccess/source/core/api/KeySet.cxx
@@ -154,7 +154,8 @@ OKeySet::OKeySet(const connectivity::OSQLTable& _xTable,
const ::rtl::OUString& _rUpdateTableName, // this can be the alias or the full qualified name
const Reference< XSingleSelectQueryAnalyzer >& _xComposer,
const ORowSetValueVector& _aParameterValueForCache,
- sal_Int32 i_nMaxRows)
+ sal_Int32 i_nMaxRows,
+ sal_Int32& o_nRowCount)
:OCacheSet(i_nMaxRows)
,m_aParameterValueForCache(_aParameterValueForCache)
,m_pKeyColumnNames(NULL)
@@ -165,6 +166,7 @@ OKeySet::OKeySet(const connectivity::OSQLTable& _xTable,
,m_xTableKeys(_xTableKeys)
,m_xComposer(_xComposer)
,m_sUpdateTableName(_rUpdateTableName)
+ ,m_rRowCount(o_nRowCount)
,m_bRowCountFinal(sal_False)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::OKeySet" );
@@ -1239,8 +1241,8 @@ sal_Bool SAL_CALL OKeySet::first( ) throw(SQLException, RuntimeException)
++m_aKeyIter;
if(m_aKeyIter == m_aKeyMap.end() && !fetchRow())
m_aKeyIter = m_aKeyMap.end();
-
- refreshRow();
+ else
+ refreshRow();
return m_aKeyIter != m_aKeyMap.end() && m_aKeyIter != m_aKeyMap.begin();
}
// -----------------------------------------------------------------------------
@@ -1403,9 +1405,18 @@ void SAL_CALL OKeySet::refreshRow() throw(SQLException, RuntimeException)
OSL_ENSURE(m_xSet.is(),"No resultset form statement!");
sal_Bool bOK = m_xSet->next();
if ( !bOK )
- m_aKeyIter = m_aKeyMap.end();
- m_xRow.set(m_xSet,UNO_QUERY);
- OSL_ENSURE(m_xRow.is(),"No row form statement!");
+ {
+ OKeySetMatrix::iterator aTemp = m_aKeyIter;
+ ++m_aKeyIter;
+ m_aKeyMap.erase(aTemp);
+ --m_rRowCount;
+ refreshRow();
+ }
+ else
+ {
+ m_xRow.set(m_xSet,UNO_QUERY);
+ OSL_ENSURE(m_xRow.is(),"No row form statement!");
+ }
}
// -----------------------------------------------------------------------------
sal_Bool OKeySet::fetchRow()
diff --git a/dbaccess/source/core/api/KeySet.hxx b/dbaccess/source/core/api/KeySet.hxx
index c002288bd9de..2f9d1b002cb1 100644
--- a/dbaccess/source/core/api/KeySet.hxx
+++ b/dbaccess/source/core/api/KeySet.hxx
@@ -113,6 +113,7 @@ namespace dbaccess
::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryAnalyzer > m_xComposer;
::rtl::OUString m_sUpdateTableName;
::std::vector< ::rtl::OUString > m_aFilterColumns;
+ sal_Int32& m_rRowCount;
sal_Bool m_bRowCountFinal;
@@ -160,7 +161,8 @@ namespace dbaccess
const ::rtl::OUString& _rUpdateTableName,
const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryAnalyzer >& _xComposer,
const ORowSetValueVector& _aParameterValueForCache,
- sal_Int32 i_nMaxRows);
+ sal_Int32 i_nMaxRows,
+ sal_Int32& o_nRowCount);
// late ctor which can throw exceptions
virtual void construct(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _xDriverSet,const ::rtl::OUString& i_sRowSetFilter);
diff --git a/dbaccess/source/core/api/OptimisticSet.cxx b/dbaccess/source/core/api/OptimisticSet.cxx
index d984ca2c78c6..2637a4f6bea6 100644
--- a/dbaccess/source/core/api/OptimisticSet.cxx
+++ b/dbaccess/source/core/api/OptimisticSet.cxx
@@ -103,8 +103,9 @@ OptimisticSet::OptimisticSet(const ::comphelper::ComponentContext& _rContext,
const Reference< XConnection>& i_xConnection,
const Reference< XSingleSelectQueryAnalyzer >& _xComposer,
const ORowSetValueVector& _aParameterValueForCache,
- sal_Int32 i_nMaxRows)
- :OKeySet(NULL,NULL,::rtl::OUString(),_xComposer,_aParameterValueForCache,i_nMaxRows)
+ sal_Int32 i_nMaxRows,
+ sal_Int32& o_nRowCount)
+ :OKeySet(NULL,NULL,::rtl::OUString(),_xComposer,_aParameterValueForCache,i_nMaxRows,o_nRowCount)
,m_aSqlParser( _rContext.getLegacyServiceFactory() )
,m_aSqlIterator( i_xConnection, Reference<XTablesSupplier>(_xComposer,UNO_QUERY)->getTables(), m_aSqlParser, NULL )
,m_bResultSetChanged(false)
diff --git a/dbaccess/source/core/api/OptimisticSet.hxx b/dbaccess/source/core/api/OptimisticSet.hxx
index da73eaeee8c5..f3b75e08ed5b 100644
--- a/dbaccess/source/core/api/OptimisticSet.hxx
+++ b/dbaccess/source/core/api/OptimisticSet.hxx
@@ -80,7 +80,8 @@ namespace dbaccess
const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& i_xConnection,
const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryAnalyzer >& _xComposer,
const ORowSetValueVector& _aParameterValueForCache,
- sal_Int32 i_nMaxRows);
+ sal_Int32 i_nMaxRows,
+ sal_Int32& o_nRowCount);
// late ctor which can throw exceptions
virtual void construct(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _xDriverSet,const ::rtl::OUString& i_sRowSetFilter);
diff --git a/dbaccess/source/core/api/RowSetCache.cxx b/dbaccess/source/core/api/RowSetCache.cxx
index 1380c436ff0e..789fbadb794b 100644
--- a/dbaccess/source/core/api/RowSetCache.cxx
+++ b/dbaccess/source/core/api/RowSetCache.cxx
@@ -176,7 +176,7 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs,
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,i_nMaxRows);
+ OptimisticSet* pCursor = new OptimisticSet(m_aContext,xConnection,_xAnalyzer,_aParameterValueForCache,i_nMaxRows,m_nRowCount);
m_pCacheSet = pCursor;
m_xCacheSet = m_pCacheSet;
try
@@ -309,7 +309,7 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs,
}
}
- OKeySet* pKeySet = new OKeySet(m_aUpdateTable,xUpdateTableKeys,aUpdateTableName ,_xAnalyzer,_aParameterValueForCache,i_nMaxRows);
+ OKeySet* pKeySet = new OKeySet(m_aUpdateTable,xUpdateTableKeys,aUpdateTableName ,_xAnalyzer,_aParameterValueForCache,i_nMaxRows,m_nRowCount);
try
{
m_pCacheSet = pKeySet;
@@ -825,7 +825,6 @@ sal_Bool ORowSetCache::moveWindow()
if ( nNewStartPos < 1 )
{
bCheck = m_pCacheSet->first();
- // 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;
@@ -958,9 +957,6 @@ 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 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;