Tag: cws_src680_warnings01 User: sb Date: 06/01/25 12:57:30 Modified: /dba/connectivity/source/drivers/mozab/ MResultSet.cxx
Log: RESYNC: (1.22-1.23); FILE MERGED 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.30.4&r2=1.22.30.5 Delta lines: +90 -79 --------------------- --- MResultSet.cxx 22 Dec 2005 12:14:43 -0000 1.22.30.4 +++ MResultSet.cxx 25 Jan 2006 20:57:27 -0000 1.22.30.5 @@ -207,16 +207,22 @@ return ::comphelper::concatSequences(aTypes.getTypes(),OResultSet_BASE::getTypes()); } // ------------------------------------------------------------------------- +void OResultSet::methodEntry() +{ + checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + if ( !m_pTable ) + { + OSL_ENSURE( false, "OResultSet::methodEntry: looks like we're disposed, but how is this possible?" ); + throw DisposedException( ::rtl::OUString(), *this ); + } +} +// ------------------------------------------------------------------------- sal_Int32 SAL_CALL OResultSet::findColumn( const ::rtl::OUString& columnName ) throw(SQLException, RuntimeException) { - - checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + ResultSetEntryGuard aGuard( *this ); // find the first column with the name columnName - - ::osl::MutexGuard aGuard( m_aMutex ); - Reference< XResultSetMetaData > xMeta = getMetaData(); sal_Int32 nLen = xMeta->getColumnCount(); sal_Int32 i = 1; @@ -240,9 +246,7 @@ // ------------------------------------------------------------------------- sal_Bool SAL_CALL OResultSet::getBoolean( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) { - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - + ResultSetEntryGuard aGuard( *this ); m_bWasNull = sal_True; return sal_False; } @@ -250,42 +254,50 @@ sal_Int8 SAL_CALL OResultSet::getByte( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) { + ResultSetEntryGuard aGuard( *this ); return 0; } // ------------------------------------------------------------------------- Sequence< sal_Int8 > SAL_CALL OResultSet::getBytes( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) { + ResultSetEntryGuard aGuard( *this ); return Sequence< sal_Int8 >(); } // ------------------------------------------------------------------------- Date SAL_CALL OResultSet::getDate( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) { + ResultSetEntryGuard aGuard( *this ); return Date(); } // ------------------------------------------------------------------------- double SAL_CALL OResultSet::getDouble( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) { + ResultSetEntryGuard aGuard( *this ); return 0.0; } // ------------------------------------------------------------------------- float SAL_CALL OResultSet::getFloat( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) { + ResultSetEntryGuard aGuard( *this ); return 0; } // ------------------------------------------------------------------------- sal_Int32 SAL_CALL OResultSet::getInt( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) { + ResultSetEntryGuard aGuard( *this ); return 0; } // ------------------------------------------------------------------------- sal_Int32 SAL_CALL OResultSet::getRow( ) throw(SQLException, RuntimeException) { + ResultSetEntryGuard aGuard( *this ); + OSL_TRACE("In/Out: OResultSet::getRow, return = %u", m_nRowPos ); return m_nRowPos; } @@ -293,15 +305,14 @@ sal_Int64 SAL_CALL OResultSet::getLong( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) { + ResultSetEntryGuard aGuard( *this ); return sal_Int64(); } // ------------------------------------------------------------------------- Reference< XResultSetMetaData > SAL_CALL OResultSet::getMetaData( ) throw(SQLException, RuntimeException) { - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - + ResultSetEntryGuard aGuard( *this ); if(!m_xMetaData.is()) m_xMetaData = new OResultSetMetaData( @@ -395,7 +406,7 @@ // ------------------------------------------------------------------------- sal_Bool OResultSet::fetchRow(sal_Int32 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... @@ -452,11 +463,10 @@ ::rtl::OUString SAL_CALL OResultSet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { + ResultSetEntryGuard aGuard( *this ); + OSL_ENSURE(m_xColumns.isValid(), "Need the Columns!!"); OSL_ENSURE(columnIndex <= (sal_Int32)m_xColumns->size(), "Trying to access invalid columns number"); - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - checkIndex( columnIndex ); // If this query was sorted then we should have a valid KeySet, so use it @@ -467,6 +477,7 @@ Time SAL_CALL OResultSet::getTime( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) { + ResultSetEntryGuard aGuard( *this ); return Time(); } // ------------------------------------------------------------------------- @@ -474,14 +485,14 @@ DateTime SAL_CALL OResultSet::getTimestamp( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) { + ResultSetEntryGuard aGuard( *this ); return DateTime(); } // ------------------------------------------------------------------------- sal_Bool SAL_CALL OResultSet::isBeforeFirst( ) throw(SQLException, RuntimeException) { - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + ResultSetEntryGuard aGuard( *this ); // here you have to implement your movements // return true means there is no data @@ -491,8 +502,7 @@ // ------------------------------------------------------------------------- sal_Bool SAL_CALL OResultSet::isAfterLast( ) throw(SQLException, RuntimeException) { - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + ResultSetEntryGuard aGuard( *this ); OSL_TRACE("In/Out: OResultSet::isAfterLast" ); return m_nRowPos > currentRowCount() && m_aQuery.queryComplete(); @@ -500,9 +510,7 @@ // ------------------------------------------------------------------------- sal_Bool SAL_CALL OResultSet::isFirst( ) throw(SQLException, RuntimeException) { - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - + ResultSetEntryGuard aGuard( *this ); OSL_TRACE("In/Out: OResultSet::isFirst" ); return m_nRowPos == 1; @@ -510,9 +518,7 @@ // ------------------------------------------------------------------------- sal_Bool SAL_CALL OResultSet::isLast( ) throw(SQLException, RuntimeException) { - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - + ResultSetEntryGuard aGuard( *this ); OSL_TRACE("In/Out: OResultSet::isLast" ); return m_nRowPos == currentRowCount() && m_aQuery.queryComplete(); @@ -520,8 +526,7 @@ // ------------------------------------------------------------------------- void SAL_CALL OResultSet::beforeFirst( ) throw(SQLException, RuntimeException) { - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + ResultSetEntryGuard aGuard( *this ); // move before the first row so that isBeforeFirst returns false OSL_TRACE("In/Out: OResultSet::beforeFirst" ); @@ -531,9 +536,8 @@ // ------------------------------------------------------------------------- void SAL_CALL OResultSet::afterLast( ) throw(SQLException, RuntimeException) { - ::osl::MutexGuard aGuard( m_aMutex ); + ResultSetEntryGuard aGuard( *this ); OSL_TRACE("In/Out: OResultSet::afterLast" ); - checkDisposed(OResultSet_BASE::rBHelper.bDisposed); if(last()) next(); @@ -542,11 +546,7 @@ void SAL_CALL OResultSet::close( ) throw(SQLException, RuntimeException) { - { - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - - } + ResultSetEntryGuard aGuard( *this ); OSL_TRACE("In/Out: OResultSet::close" ); // dispose(); } @@ -579,15 +579,14 @@ // ------------------------------------------------------------------------- sal_Bool SAL_CALL OResultSet::previous( ) throw(SQLException, RuntimeException) { + ResultSetEntryGuard aGuard( *this ); OSL_TRACE("In/Out: OResultSet::previous" ); return seekRow( PRIOR_POS ); } // ------------------------------------------------------------------------- Reference< XInterface > SAL_CALL OResultSet::getStatement( ) throw(SQLException, RuntimeException) { - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - + ResultSetEntryGuard aGuard( *this ); OSL_TRACE("In/Out: OResultSet::getStatement" ); return m_xStatement; @@ -596,18 +595,21 @@ sal_Bool SAL_CALL OResultSet::rowDeleted( ) throw(SQLException, RuntimeException) { + ResultSetEntryGuard aGuard( *this ); OSL_TRACE("In/Out: OResultSet::rowDeleted, m_RowStates=%u",m_RowStates ); return ((m_RowStates & RowStates_Deleted) == RowStates_Deleted) ; } // ------------------------------------------------------------------------- sal_Bool SAL_CALL OResultSet::rowInserted( ) throw(SQLException, RuntimeException) { + ResultSetEntryGuard aGuard( *this ); OSL_TRACE("In/Out: OResultSet::rowInserted,m_RowStates=%u",m_RowStates ); return ((m_RowStates & RowStates_Inserted) == RowStates_Inserted); } // ------------------------------------------------------------------------- sal_Bool SAL_CALL OResultSet::rowUpdated( ) throw(SQLException, RuntimeException) { + ResultSetEntryGuard aGuard( *this ); OSL_TRACE("In/Out: OResultSet::rowUpdated,m_RowStates=%u",m_RowStates ); return ((m_RowStates & RowStates_Updated) == RowStates_Updated) ; } @@ -621,8 +623,7 @@ sal_Bool SAL_CALL OResultSet::wasNull( ) throw(SQLException, RuntimeException) { - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + ResultSetEntryGuard aGuard( *this ); return m_bWasNull; } @@ -630,8 +631,7 @@ void SAL_CALL OResultSet::cancel( ) throw(RuntimeException) { - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + ResultSetEntryGuard aGuard( *this ); OSL_TRACE("In/Out: OResultSet::cancel" ); } @@ -1211,21 +1211,29 @@ 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; } // ----------------------------------------------------------------------------- void SAL_CALL OResultSet::executeQuery() throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) { - ::osl::MutexGuard aGuard(m_aMutex); + ResultSetEntryGuard aGuard( *this ); OSL_ENSURE( m_pTable, "Need a Table object"); if(!m_pTable) @@ -1534,8 +1542,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; @@ -1556,16 +1563,16 @@ sal_Int32 OResultSet::deletedCount() { - if (!m_pKeySet.isValid()) - m_pKeySet = new OKeySet(); + impl_ensureKeySet(); return m_CurrentRowCount - m_pKeySet->size(); } // ----------------------------------------------------------------------------- sal_Bool OResultSet::seekRow( eRowPosition pos, sal_Int32 nOffset ) { - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + 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(); @@ -1650,8 +1657,7 @@ ::com::sun::star::uno::Any OResultSet::getBookmark( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) { OSL_TRACE("getBookmark, m_nRowPos = %u", m_nRowPos ); - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + ResultSetEntryGuard aGuard( *this ); if ( fetchCurrentRow() == sal_False ) ::dbtools::throwGenericSQLException(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Can't get current row")),NULL); @@ -1660,6 +1666,7 @@ } sal_Bool OResultSet::moveToBookmark( const ::com::sun::star::uno::Any& bookmark ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) { + ResultSetEntryGuard aGuard( *this ); OSL_TRACE("moveToBookmark, bookmark = %u", comphelper::getINT32(bookmark) ); sal_Int32 nCardNum = comphelper::getINT32(bookmark); m_nRowPos = getRowForCardNumber(nCardNum); @@ -1668,6 +1675,7 @@ } sal_Bool OResultSet::moveRelativeToBookmark( const ::com::sun::star::uno::Any& bookmark, sal_Int32 rows ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) { + ResultSetEntryGuard aGuard( *this ); OSL_TRACE("moveRelativeToBookmark, bookmark = %u rows= %u", comphelper::getINT32(bookmark),rows ); sal_Int32 nCardNum = comphelper::getINT32(bookmark); m_nRowPos = getRowForCardNumber(nCardNum); @@ -1675,6 +1683,7 @@ } sal_Int32 OResultSet::compareBookmarks( const ::com::sun::star::uno::Any& lhs, const ::com::sun::star::uno::Any& rhs ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) { + ResultSetEntryGuard aGuard( *this ); OSL_TRACE("compareBookmarks, m_nRowPos = %u", m_nRowPos ); sal_Int32 nFirst=0; sal_Int32 nSecond=0; @@ -1694,18 +1703,20 @@ } sal_Bool OResultSet::hasOrderedBookmarks( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) { + ResultSetEntryGuard aGuard( *this ); OSL_TRACE("hasOrderedBookmarks, m_nRowPos = %u", m_nRowPos ); return sal_True; } sal_Int32 OResultSet::hashBookmark( const ::com::sun::star::uno::Any& bookmark ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) { + ResultSetEntryGuard aGuard( *this ); OSL_TRACE("hashBookmark, m_nRowPos = %u", m_nRowPos ); return comphelper::getINT32(bookmark); } 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; @@ -1731,8 +1742,7 @@ void OResultSet::updateValue(sal_Int32 columnIndex ,const ORowSetValue& x) throw(SQLException, RuntimeException) { OSL_TRACE("updateValue, m_nRowPos = %u", m_nRowPos ); - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + ResultSetEntryGuard aGuard( *this ); if ( fetchCurrentRow() == sal_False ) ::dbtools::throwGenericSQLException(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Can't get current row")),NULL); @@ -1752,8 +1762,7 @@ void SAL_CALL OResultSet::updateNull( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { OSL_TRACE("updateNull, m_nRowPos = %u", m_nRowPos ); - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + ResultSetEntryGuard aGuard( *this ); if ( fetchCurrentRow() == sal_False ) ::dbtools::throwGenericSQLException(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Can't get current row")),NULL); @@ -1835,8 +1844,7 @@ void SAL_CALL OResultSet::updateBinaryStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException) { - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + ResultSetEntryGuard aGuard( *this ); if(!x.is()) ::dbtools::throwGenericSQLException(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Invalid use of null pointer")),*this); @@ -1867,6 +1875,7 @@ // ------------------------------------------------------------------------- void SAL_CALL OResultSet::insertRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) { + ResultSetEntryGuard aGuard( *this ); OSL_TRACE("insertRow in, m_nRowPos = %u", m_nRowPos ); m_RowStates = RowStates_Inserted; updateRow(); @@ -1879,8 +1888,9 @@ void SAL_CALL OResultSet::updateRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) { OSL_TRACE("updateRow in, m_nRowPos = %u", m_nRowPos ); - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + 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); @@ -1908,8 +1918,7 @@ void SAL_CALL OResultSet::deleteRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) { OSL_TRACE("deleteRow, m_nRowPos = %u", m_nRowPos ); - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + ResultSetEntryGuard aGuard( *this ); if (rowDeleted()) throw SQLException(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Row Already deleted")) ,*this ,OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_HY0000) @@ -1933,6 +1942,7 @@ // ------------------------------------------------------------------------- void SAL_CALL OResultSet::cancelRowUpdates( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) { + ResultSetEntryGuard aGuard( *this ); OSL_TRACE("cancelRowUpdates, m_nRowPos = %u", m_nRowPos ); if (fetchRow(getCurrentCardNumber(),sal_True)) //force fetch current row will cause we lose all change to the current row ::dbtools::throwGenericSQLException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Can't cancel row updates")), NULL ); @@ -1941,7 +1951,7 @@ void SAL_CALL OResultSet::moveToInsertRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) { OSL_TRACE("moveToInsertRow in, m_nRowPos = %u", m_nRowPos ); - ::osl::MutexGuard aGuard( m_aMutex ); + ResultSetEntryGuard aGuard( *this ); m_nOldRowPos = m_nRowPos; if (!m_nNewRow) //no new row now, insert one @@ -1969,6 +1979,7 @@ // ------------------------------------------------------------------------- void SAL_CALL OResultSet::moveToCurrentRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) { + ResultSetEntryGuard aGuard( *this ); OSL_TRACE("moveToCurrentRow, m_nRowPos = %u", m_nRowPos ); if (rowInserted()) { --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
