diff --git a/dbaccess/source/core/api/RowSet.cxx b/dbaccess/source/core/api/RowSet.cxx index 74d3e793ecdd..bbf65484d93d 100644 --- a/dbaccess/source/core/api/RowSet.cxx +++ b/dbaccess/source/core/api/RowSet.cxx @@ -148,6 +148,7 @@ ORowSet::ORowSet( const Reference< css::uno::XComponentContext >& _rxContext ) ,m_nPrivileges(0) ,m_nLastKnownRowCount(0) ,m_nInAppend(0) + ,m_bInsertingRow(false) ,m_bLastKnownRowCountFinal(false) ,m_bUseEscapeProcessing(true) ,m_bApplyFilter(false) @@ -861,9 +862,33 @@ void SAL_CALL ORowSet::updateNumericObject( sal_Int32 columnIndex, const Any& x, aNotify.firePropertyChange(); } -// XResultSetUpdate -void SAL_CALL ORowSet::insertRow( ) throw(SQLException, RuntimeException, std::exception) +namespace { + class ProtectFlag + { + bool& m_rInsertingRow; + public: + ProtectFlag(bool& rInsertingRow) + : m_rInsertingRow(rInsertingRow) + { + if (m_rInsertingRow) + { + throw std::runtime_error("recursion in insertRow"); + } + m_rInsertingRow = true; + } + ~ProtectFlag() + { + m_rInsertingRow = false; + } + }; +} + +// XResultSetUpdate +void SAL_CALL ORowSet::insertRow() throw(SQLException, RuntimeException, std::exception) +{ + ProtectFlag aFlagControl(m_bInsertingRow); + ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed); // insertRow is not allowed when // standing not on the insert row nor diff --git a/dbaccess/source/core/api/RowSet.hxx b/dbaccess/source/core/api/RowSet.hxx index e06bcb62a089..058b85dfb6f1 100644 --- a/dbaccess/source/core/api/RowSet.hxx +++ b/dbaccess/source/core/api/RowSet.hxx @@ -124,6 +124,7 @@ namespace dbaccess sal_Int32 m_nPrivileges; sal_Int32 m_nLastKnownRowCount; oslInterlockedCount m_nInAppend; + bool m_bInsertingRow; bool m_bLastKnownRowCountFinal; bool m_bUseEscapeProcessing ; bool m_bApplyFilter ;