Kaydet (Commit) 87bd0c8c authored tarafından Andrzej J.R. Hunt's avatar Andrzej J.R. Hunt

Reintroduce Statement specific mutexes. (firebird-sdbc)

This replaces the erronous Connection wide mutex. Libfbembed
is multithreaded hence we don't need a connection wide mutex.

Change-Id: Ifae79cdefecfe6597a535e36bda318563092bf6c
üst 24266895
...@@ -167,7 +167,6 @@ namespace connectivity ...@@ -167,7 +167,6 @@ namespace connectivity
::rtl::OUString getConnectionURL() const {return m_sConnectionURL;} ::rtl::OUString getConnectionURL() const {return m_sConnectionURL;}
sal_Bool isEmbedded() const {return m_bIsEmbedded;} sal_Bool isEmbedded() const {return m_bIsEmbedded;}
::rtl::OUString getUserName() const {return m_sUser;} ::rtl::OUString getUserName() const {return m_sUser;}
::osl::Mutex& getMutex() {return m_aMutex;}
isc_db_handle& getDBHandle() {return m_aDBHandle;} isc_db_handle& getDBHandle() {return m_aDBHandle;}
isc_tr_handle& getTransaction() isc_tr_handle& getTransaction()
throw(::com::sun::star::sdbc::SQLException); throw(::com::sun::star::sdbc::SQLException);
......
...@@ -66,7 +66,7 @@ OPreparedStatement::OPreparedStatement( Connection* _pConnection, ...@@ -66,7 +66,7 @@ OPreparedStatement::OPreparedStatement( Connection* _pConnection,
void OPreparedStatement::ensurePrepared() void OPreparedStatement::ensurePrepared()
throw (SQLException, RuntimeException) throw (SQLException, RuntimeException)
{ {
MutexGuard aGuard(m_pConnection->getMutex()); MutexGuard aGuard(m_aMutex);
checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed); checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed);
if (m_aStatementHandle) if (m_aStatementHandle)
...@@ -147,7 +147,7 @@ uno::Sequence< Type > SAL_CALL OPreparedStatement::getTypes() ...@@ -147,7 +147,7 @@ uno::Sequence< Type > SAL_CALL OPreparedStatement::getTypes()
Reference< XResultSetMetaData > SAL_CALL OPreparedStatement::getMetaData() Reference< XResultSetMetaData > SAL_CALL OPreparedStatement::getMetaData()
throw(SQLException, RuntimeException) throw(SQLException, RuntimeException)
{ {
::osl::MutexGuard aGuard( m_pConnection->getMutex() ); ::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed); checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed);
ensurePrepared(); ensurePrepared();
...@@ -159,7 +159,7 @@ Reference< XResultSetMetaData > SAL_CALL OPreparedStatement::getMetaData() ...@@ -159,7 +159,7 @@ Reference< XResultSetMetaData > SAL_CALL OPreparedStatement::getMetaData()
void SAL_CALL OPreparedStatement::close() throw(SQLException, RuntimeException) void SAL_CALL OPreparedStatement::close() throw(SQLException, RuntimeException)
{ {
MutexGuard aGuard( m_pConnection->getMutex() ); MutexGuard aGuard( m_aMutex );
checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed); checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed);
OStatementCommonBase::close(); OStatementCommonBase::close();
...@@ -189,7 +189,7 @@ void SAL_CALL OPreparedStatement::setString(sal_Int32 nParameterIndex, ...@@ -189,7 +189,7 @@ void SAL_CALL OPreparedStatement::setString(sal_Int32 nParameterIndex,
SAL_INFO("connectivity.firebird", SAL_INFO("connectivity.firebird",
"setString(" << nParameterIndex << " , " << x << ")"); "setString(" << nParameterIndex << " , " << x << ")");
MutexGuard aGuard( m_pConnection->getMutex() ); MutexGuard aGuard( m_aMutex );
checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed); checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed);
ensurePrepared(); ensurePrepared();
...@@ -234,7 +234,7 @@ void SAL_CALL OPreparedStatement::setString(sal_Int32 nParameterIndex, ...@@ -234,7 +234,7 @@ void SAL_CALL OPreparedStatement::setString(sal_Int32 nParameterIndex,
Reference< XConnection > SAL_CALL OPreparedStatement::getConnection() Reference< XConnection > SAL_CALL OPreparedStatement::getConnection()
throw(SQLException, RuntimeException) throw(SQLException, RuntimeException)
{ {
MutexGuard aGuard( m_pConnection->getMutex() ); MutexGuard aGuard( m_aMutex );
checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed); checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed);
return Reference< XConnection >(m_pConnection); return Reference< XConnection >(m_pConnection);
...@@ -246,7 +246,7 @@ sal_Bool SAL_CALL OPreparedStatement::execute() ...@@ -246,7 +246,7 @@ sal_Bool SAL_CALL OPreparedStatement::execute()
SAL_INFO("connectivity.firebird", "executeQuery(). " SAL_INFO("connectivity.firebird", "executeQuery(). "
"Got called with sql: " << m_sSqlStatement); "Got called with sql: " << m_sSqlStatement);
MutexGuard aGuard( m_pConnection->getMutex() ); MutexGuard aGuard( m_aMutex );
checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed); checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed);
ensurePrepared(); ensurePrepared();
...@@ -281,6 +281,7 @@ sal_Bool SAL_CALL OPreparedStatement::execute() ...@@ -281,6 +281,7 @@ sal_Bool SAL_CALL OPreparedStatement::execute()
} }
m_xResultSet = new OResultSet(m_pConnection, m_xResultSet = new OResultSet(m_pConnection,
m_aMutex,
uno::Reference< XInterface >(*this), uno::Reference< XInterface >(*this),
m_aStatementHandle, m_aStatementHandle,
m_pOutSqlda); m_pOutSqlda);
...@@ -312,7 +313,7 @@ Reference< XResultSet > SAL_CALL OPreparedStatement::executeQuery() ...@@ -312,7 +313,7 @@ Reference< XResultSet > SAL_CALL OPreparedStatement::executeQuery()
void SAL_CALL OPreparedStatement::setNull(sal_Int32 nIndex, sal_Int32 /*nSqlType*/) void SAL_CALL OPreparedStatement::setNull(sal_Int32 nIndex, sal_Int32 /*nSqlType*/)
throw(SQLException, RuntimeException) throw(SQLException, RuntimeException)
{ {
MutexGuard aGuard( m_pConnection->getMutex() ); MutexGuard aGuard( m_aMutex );
checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed); checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed);
setParameterNull(nIndex, true); setParameterNull(nIndex, true);
...@@ -323,7 +324,7 @@ void SAL_CALL OPreparedStatement::setBoolean(sal_Int32 nIndex, sal_Bool x) ...@@ -323,7 +324,7 @@ void SAL_CALL OPreparedStatement::setBoolean(sal_Int32 nIndex, sal_Bool x)
{ {
(void) nIndex; (void) nIndex;
(void) x; (void) x;
MutexGuard aGuard(m_pConnection->getMutex()); MutexGuard aGuard(m_aMutex);
checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed); checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed);
// TODO: decide how to deal with bools. Probably just as a byte, although // TODO: decide how to deal with bools. Probably just as a byte, although
...@@ -334,7 +335,7 @@ template <typename T> ...@@ -334,7 +335,7 @@ template <typename T>
void OPreparedStatement::setValue(sal_Int32 nIndex, T& nValue, ISC_SHORT nType) void OPreparedStatement::setValue(sal_Int32 nIndex, T& nValue, ISC_SHORT nType)
throw(SQLException, RuntimeException) throw(SQLException, RuntimeException)
{ {
MutexGuard aGuard( m_pConnection->getMutex() ); MutexGuard aGuard( m_aMutex );
checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed); checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed);
ensurePrepared(); ensurePrepared();
...@@ -437,7 +438,7 @@ void SAL_CALL OPreparedStatement::setClob( sal_Int32 parameterIndex, const Refer ...@@ -437,7 +438,7 @@ void SAL_CALL OPreparedStatement::setClob( sal_Int32 parameterIndex, const Refer
{ {
(void) parameterIndex; (void) parameterIndex;
(void) x; (void) x;
::osl::MutexGuard aGuard( m_pConnection->getMutex() ); ::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed); checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed);
} }
...@@ -447,7 +448,7 @@ void SAL_CALL OPreparedStatement::setBlob( sal_Int32 parameterIndex, const Refer ...@@ -447,7 +448,7 @@ void SAL_CALL OPreparedStatement::setBlob( sal_Int32 parameterIndex, const Refer
{ {
(void) parameterIndex; (void) parameterIndex;
(void) x; (void) x;
::osl::MutexGuard aGuard( m_pConnection->getMutex() ); ::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed); checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed);
} }
...@@ -457,7 +458,7 @@ void SAL_CALL OPreparedStatement::setArray( sal_Int32 parameterIndex, const Refe ...@@ -457,7 +458,7 @@ void SAL_CALL OPreparedStatement::setArray( sal_Int32 parameterIndex, const Refe
{ {
(void) parameterIndex; (void) parameterIndex;
(void) x; (void) x;
::osl::MutexGuard aGuard( m_pConnection->getMutex() ); ::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed); checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed);
} }
...@@ -467,7 +468,7 @@ void SAL_CALL OPreparedStatement::setRef( sal_Int32 parameterIndex, const Refere ...@@ -467,7 +468,7 @@ void SAL_CALL OPreparedStatement::setRef( sal_Int32 parameterIndex, const Refere
{ {
(void) parameterIndex; (void) parameterIndex;
(void) x; (void) x;
::osl::MutexGuard aGuard( m_pConnection->getMutex() ); ::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed); checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed);
} }
...@@ -480,7 +481,7 @@ void SAL_CALL OPreparedStatement::setObjectWithInfo( sal_Int32 parameterIndex, c ...@@ -480,7 +481,7 @@ void SAL_CALL OPreparedStatement::setObjectWithInfo( sal_Int32 parameterIndex, c
(void) sqlType; (void) sqlType;
(void) scale; (void) scale;
checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed); checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed);
::osl::MutexGuard aGuard( m_pConnection->getMutex() ); ::osl::MutexGuard aGuard( m_aMutex );
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
...@@ -490,7 +491,7 @@ void SAL_CALL OPreparedStatement::setObjectNull( sal_Int32 parameterIndex, sal_I ...@@ -490,7 +491,7 @@ void SAL_CALL OPreparedStatement::setObjectNull( sal_Int32 parameterIndex, sal_I
(void) parameterIndex; (void) parameterIndex;
(void) sqlType; (void) sqlType;
(void) typeName; (void) typeName;
::osl::MutexGuard aGuard( m_pConnection->getMutex() ); ::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed); checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed);
} }
...@@ -500,7 +501,7 @@ void SAL_CALL OPreparedStatement::setObject( sal_Int32 parameterIndex, const Any ...@@ -500,7 +501,7 @@ void SAL_CALL OPreparedStatement::setObject( sal_Int32 parameterIndex, const Any
{ {
(void) parameterIndex; (void) parameterIndex;
(void) x; (void) x;
::osl::MutexGuard aGuard( m_pConnection->getMutex() ); ::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed); checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed);
} }
...@@ -510,7 +511,7 @@ void SAL_CALL OPreparedStatement::setBytes( sal_Int32 parameterIndex, const Sequ ...@@ -510,7 +511,7 @@ void SAL_CALL OPreparedStatement::setBytes( sal_Int32 parameterIndex, const Sequ
{ {
(void) parameterIndex; (void) parameterIndex;
(void) x; (void) x;
::osl::MutexGuard aGuard( m_pConnection->getMutex() ); ::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed); checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed);
} }
...@@ -522,7 +523,7 @@ void SAL_CALL OPreparedStatement::setCharacterStream( sal_Int32 parameterIndex, ...@@ -522,7 +523,7 @@ void SAL_CALL OPreparedStatement::setCharacterStream( sal_Int32 parameterIndex,
(void) parameterIndex; (void) parameterIndex;
(void) x; (void) x;
(void) length; (void) length;
::osl::MutexGuard aGuard( m_pConnection->getMutex() ); ::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed); checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed);
} }
...@@ -533,7 +534,7 @@ void SAL_CALL OPreparedStatement::setBinaryStream( sal_Int32 parameterIndex, con ...@@ -533,7 +534,7 @@ void SAL_CALL OPreparedStatement::setBinaryStream( sal_Int32 parameterIndex, con
(void) parameterIndex; (void) parameterIndex;
(void) x; (void) x;
(void) length; (void) length;
::osl::MutexGuard aGuard( m_pConnection->getMutex() ); ::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed); checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed);
} }
......
...@@ -75,6 +75,7 @@ namespace connectivity ...@@ -75,6 +75,7 @@ namespace connectivity
protected: protected:
Connection* m_pConnection; Connection* m_pConnection;
::osl::Mutex& m_rMutex;
const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& m_xStatement; const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& m_xStatement;
::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData> m_xMetaData; ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData> m_xMetaData;
...@@ -114,6 +115,7 @@ namespace connectivity ...@@ -114,6 +115,7 @@ namespace connectivity
DECLARE_SERVICE_INFO(); DECLARE_SERVICE_INFO();
OResultSet(Connection* pConnection, OResultSet(Connection* pConnection,
::osl::Mutex& rMutex,
const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xStatement, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xStatement,
isc_stmt_handle& aStatementHandle, isc_stmt_handle& aStatementHandle,
XSQLDA* aSqlda); XSQLDA* aSqlda);
......
...@@ -80,7 +80,7 @@ void SAL_CALL OStatement::release() throw() ...@@ -80,7 +80,7 @@ void SAL_CALL OStatement::release() throw()
void OStatement::disposeResultSet() void OStatement::disposeResultSet()
{ {
MutexGuard aGuard(m_pConnection->getMutex()); MutexGuard aGuard(m_aMutex);
checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed); checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed);
OStatementCommonBase::disposeResultSet(); OStatementCommonBase::disposeResultSet();
...@@ -105,7 +105,7 @@ sal_Int32 SAL_CALL OStatement::executeUpdate(const OUString& sql) ...@@ -105,7 +105,7 @@ sal_Int32 SAL_CALL OStatement::executeUpdate(const OUString& sql)
uno::Reference< XResultSet > SAL_CALL OStatement::executeQuery(const OUString& sql) uno::Reference< XResultSet > SAL_CALL OStatement::executeQuery(const OUString& sql)
throw(SQLException, RuntimeException) throw(SQLException, RuntimeException)
{ {
MutexGuard aGuard(m_pConnection->getMutex()); MutexGuard aGuard(m_aMutex);
checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed); checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed);
SAL_INFO("connectivity.firebird", "executeQuery(" << sql << ")"); SAL_INFO("connectivity.firebird", "executeQuery(" << sql << ")");
...@@ -126,6 +126,7 @@ uno::Reference< XResultSet > SAL_CALL OStatement::executeQuery(const OUString& s ...@@ -126,6 +126,7 @@ uno::Reference< XResultSet > SAL_CALL OStatement::executeQuery(const OUString& s
SAL_WARN("connectivity.firebird", "isc_dsql_execute failed"); SAL_WARN("connectivity.firebird", "isc_dsql_execute failed");
m_xResultSet = new OResultSet(m_pConnection, m_xResultSet = new OResultSet(m_pConnection,
m_aMutex,
uno::Reference< XInterface >(*this), uno::Reference< XInterface >(*this),
m_aStatementHandle, m_aStatementHandle,
m_pSqlda); m_pSqlda);
...@@ -151,7 +152,7 @@ sal_Bool SAL_CALL OStatement::execute(const OUString& sql) ...@@ -151,7 +152,7 @@ sal_Bool SAL_CALL OStatement::execute(const OUString& sql)
uno::Reference< XConnection > SAL_CALL OStatement::getConnection() uno::Reference< XConnection > SAL_CALL OStatement::getConnection()
throw(SQLException, RuntimeException) throw(SQLException, RuntimeException)
{ {
MutexGuard aGuard(m_pConnection->getMutex()); MutexGuard aGuard(m_aMutex);
checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed); checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed);
return (uno::Reference< XConnection >)m_pConnection; return (uno::Reference< XConnection >)m_pConnection;
......
...@@ -45,7 +45,7 @@ using namespace ::rtl; ...@@ -45,7 +45,7 @@ using namespace ::rtl;
using namespace ::std; using namespace ::std;
OStatementCommonBase::OStatementCommonBase(Connection* _pConnection) OStatementCommonBase::OStatementCommonBase(Connection* _pConnection)
: OStatementCommonBase_Base(_pConnection->getMutex()), : OStatementCommonBase_Base(m_aMutex),
OPropertySetHelper(OStatementCommonBase_Base::rBHelper), OPropertySetHelper(OStatementCommonBase_Base::rBHelper),
m_pConnection(_pConnection), m_pConnection(_pConnection),
m_aStatementHandle( 0 ), m_aStatementHandle( 0 ),
...@@ -102,7 +102,7 @@ Sequence< Type > SAL_CALL OStatementCommonBase::getTypes( ) throw(RuntimeExcept ...@@ -102,7 +102,7 @@ Sequence< Type > SAL_CALL OStatementCommonBase::getTypes( ) throw(RuntimeExcept
void SAL_CALL OStatementCommonBase::cancel( ) throw(RuntimeException) void SAL_CALL OStatementCommonBase::cancel( ) throw(RuntimeException)
{ {
MutexGuard aGuard(m_pConnection->getMutex()); MutexGuard aGuard(m_aMutex);
checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed); checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed);
// cancel the current sql statement // cancel the current sql statement
} }
...@@ -113,7 +113,7 @@ void SAL_CALL OStatementCommonBase::close() ...@@ -113,7 +113,7 @@ void SAL_CALL OStatementCommonBase::close()
SAL_INFO("connectivity.firebird", "close"); SAL_INFO("connectivity.firebird", "close");
{ {
MutexGuard aGuard(m_pConnection->getMutex()); MutexGuard aGuard(m_aMutex);
checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed); checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed);
disposeResultSet(); disposeResultSet();
freeStatementHandle(); freeStatementHandle();
...@@ -127,7 +127,7 @@ void OStatementCommonBase::prepareAndDescribeStatement(const OUString& sql, ...@@ -127,7 +127,7 @@ void OStatementCommonBase::prepareAndDescribeStatement(const OUString& sql,
XSQLDA* pInSqlda) XSQLDA* pInSqlda)
throw (SQLException) throw (SQLException)
{ {
MutexGuard aGuard(m_pConnection->getMutex()); MutexGuard aGuard(m_aMutex);
freeStatementHandle(); freeStatementHandle();
...@@ -214,7 +214,7 @@ uno::Reference< XResultSet > SAL_CALL OStatementCommonBase::getResultSet() throw ...@@ -214,7 +214,7 @@ uno::Reference< XResultSet > SAL_CALL OStatementCommonBase::getResultSet() throw
{ {
// TODO: verify we really can't support this // TODO: verify we really can't support this
// return uno::Reference< XResultSet >(); // return uno::Reference< XResultSet >();
MutexGuard aGuard(m_pConnection->getMutex()); MutexGuard aGuard(m_aMutex);
checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed); checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed);
return m_xResultSet; return m_xResultSet;
......
...@@ -53,6 +53,8 @@ namespace connectivity ...@@ -53,6 +53,8 @@ namespace connectivity
{ {
protected: protected:
::osl::Mutex m_aMutex;
::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet> m_xResultSet; // The last ResultSet created ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet> m_xResultSet; // The last ResultSet created
// for this Statement // for this Statement
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment