Tag: cws_src680_dba202a
User: fs      
Date: 05/11/24 06:57:35

Modified:
 /dba/connectivity/source/drivers/mozab/
  MResultSet.cxx, MResultSet.hxx

Log:
 now a proper fix for 126615 - invalid m_pKeySet is in fact allowed in some 
situations (in opposite to what the previous fix assumed)

File Changes:

Directory: /dba/connectivity/source/drivers/mozab/
==================================================

File [changed]: MResultSet.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/mozab/MResultSet.cxx?r1=1.22.36.2&r2=1.22.36.3
Delta lines:  +31 -24
---------------------
--- MResultSet.cxx      23 Nov 2005 15:54:17 -0000      1.22.36.2
+++ MResultSet.cxx      24 Nov 2005 14:57:32 -0000      1.22.36.3
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: MResultSet.cxx,v $
  *
- *  $Revision: 1.22.36.2 $
+ *  $Revision: 1.22.36.3 $
  *
- *  last change: $Author: fs $ $Date: 2005/11/23 15:54:17 $
+ *  last change: $Author: fs $ $Date: 2005/11/24 14:57:32 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -206,15 +206,12 @@
        return 
::comphelper::concatSequences(aTypes.getTypes(),OResultSet_BASE::getTypes());
 }
 // -------------------------------------------------------------------------
-void OResultSet::checkDisposed()
+void OResultSet::methodEntry()
 {
-    ::checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
-    if ( !m_pKeySet.isValid() || !m_pTable )
+    checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+    if ( !m_pTable )
     {
-        OSL_ENSURE( false, "OResultSet::checkDisposed: looks like we're 
disposed, but how is this possible?" );
-            // if this assertion fires, we might have an explanation for a 
number of crash reports,
-            // which tell us that it *is* possible to have a m_pKeySet which 
is NULL, though we're not
-            // yet disposed
+        OSL_ENSURE( false, "OResultSet::methodEntry: looks like we're 
disposed, but how is this possible?" );
         throw DisposedException( ::rtl::OUString(), *this );
     }
 }
@@ -408,7 +405,7 @@
 // -------------------------------------------------------------------------
 sal_Bool OResultSet::fetchRow(sal_uInt32 cardNumber,sal_Bool bForceReload) 
throw(SQLException, RuntimeException)
 {
-       OSL_TRACE("fetchCurrentRow, cardNumber = %u", cardNumber );
+       OSL_TRACE("fetchRow, cardNumber = %u", cardNumber );
        if (!bForceReload)
        {
            // Check whether we've already fetched the row...
@@ -1212,14 +1209,22 @@
 sal_Int32 OResultSet::getRowForCardNumber(sal_Int32 nCardNum)
 {
     OSL_TRACE("In/Out: OResultSet::getRowForCardNumber, nCardNum = %u", 
nCardNum );
+
+    if ( m_pKeySet.isValid() )
+    {
     sal_Int32  nPos;
     for(nPos=0;nPos < (sal_Int32)m_pKeySet->size();nPos++)
     {
        if (nCardNum == (*m_pKeySet)[nPos])
-               break;
-    }
+            {
     OSL_TRACE("In/Out: OResultSet::getRowForCardNumber, return = %u", nPos+1 );
     return nPos+1;
+            }
+        }
+    }
+
+    ::dbtools::throwSQLException( "Invalid bookmark value", "HY111", *this );
+    return 0;
 }
 
 // 
-----------------------------------------------------------------------------
@@ -1535,8 +1540,7 @@
 }
 sal_Bool OResultSet::fillKeySet(sal_Int32 nMaxCardNumber)
 {
-       if (!m_pKeySet.isValid())
-               m_pKeySet = new OKeySet();
+       impl_ensureKeySet();
        if (m_CurrentRowCount < nMaxCardNumber)
        {
                 sal_Int32      nKeyValue;
@@ -1557,8 +1561,7 @@
 
 sal_Int32 OResultSet::deletedCount()
 {
-       if (!m_pKeySet.isValid())
-               m_pKeySet = new OKeySet();
+    impl_ensureKeySet();
        return m_CurrentRowCount - m_pKeySet->size();
        
 }
@@ -1566,6 +1569,8 @@
 sal_Bool OResultSet::seekRow( eRowPosition pos, sal_Int32 nOffset )
 {
     ResultSetEntryGuard aGuard( *this );
+    if ( !m_pKeySet.isValid() )
+        ::dbtools::throwGenericSQLException( ::rtl::OUString( 
RTL_CONSTASCII_USTRINGPARAM( "Illegal cursor movement" ) ), *this );
 
     sal_Int32  nNumberOfRecords = m_aQuery.getRealRowCount();
     sal_Int32  nRetrivedRows = currentRowCount();
@@ -1709,7 +1714,7 @@
 
 sal_Int32 OResultSet::getCurrentCardNumber()
 {
-       if (m_nRowPos == 0)
+       if ( ( m_nRowPos == 0 ) || !m_pKeySet.isValid() )
                return 0;
        if (m_pKeySet->size() < m_nRowPos)
                return 0;
@@ -1882,6 +1887,8 @@
 {
        OSL_TRACE("updateRow in, m_nRowPos = %u", m_nRowPos );
     ResultSetEntryGuard aGuard( *this );
+    impl_ensureKeySet();
+
     if (!m_nRowPos || m_pKeySet->size() < m_nRowPos )
        ::dbtools::throwGenericSQLException(::rtl::OUString( 
RTL_CONSTASCII_USTRINGPARAM("Call update on invalid row")),NULL);
 
@@ -1947,7 +1954,7 @@
        
        if (!m_nNewRow) //no new row now, insert one
        {
-        ::checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+        checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
                checkPendingUpdate();
                if (rowUpdated())
                {

File [changed]: MResultSet.hxx
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/mozab/MResultSet.hxx?r1=1.9.36.1&r2=1.9.36.2
Delta lines:  +11 -4
--------------------
--- MResultSet.hxx      23 Nov 2005 15:43:31 -0000      1.9.36.1
+++ MResultSet.hxx      24 Nov 2005 14:57:32 -0000      1.9.36.2
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: MResultSet.hxx,v $
  *
- *  $Revision: 1.9.36.1 $
+ *  $Revision: 1.9.36.2 $
  *
- *  last change: $Author: fs $ $Date: 2005/11/23 15:43:31 $
+ *  last change: $Author: fs $ $Date: 2005/11/24 14:57:32 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -371,7 +371,14 @@
                 ::std::vector<sal_Int32>& _rColMapping);
 
             ::osl::Mutex&   getMutex() { return m_aMutex; }
-            void            checkDisposed();
+            void            methodEntry();
+
+            private:
+                inline void impl_ensureKeySet()
+                {
+                       if ( !m_pKeySet.isValid() )
+                               m_pKeySet = new OKeySet();
+                }
                };
 
         inline sal_Int32 OResultSet::mapColumn(sal_Int32 column)
@@ -392,7 +399,7 @@
         public:
             ResultSetEntryGuard( OResultSet& _rRS ) : ::osl::MutexGuard( 
_rRS.getMutex() )
             {
-                _rRS.checkDisposed();
+                _rRS.methodEntry();
             }
         };
 




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to