User: rt Date: 05/03/30 03:51:24 Modified: /dba/connectivity/source/drivers/hsqldb/ HDriver.cxx
Log: INTEGRATION: CWS dba28 (1.7.12); FILE MERGED 2005/03/30 11:19:03 fs 1.7.12.3: RESYNC: (1.7-1.9); FILE MERGED 2005/03/23 14:55:39 fs 1.7.12.2: #i45314# proper SHUTDOWN of the DB when the last connection dies 2005/03/21 12:53:32 fs 1.7.12.1: copying the changes from CWS dba26 herein, since they're needed to fix i45314 File Changes: Directory: /dba/connectivity/source/drivers/hsqldb/ =================================================== File [changed]: HDriver.cxx Url: http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/hsqldb/HDriver.cxx?r1=1.9&r2=1.10 Delta lines: +29 -17 --------------------- --- HDriver.cxx 23 Mar 2005 14:55:02 -0000 1.9 +++ HDriver.cxx 30 Mar 2005 11:51:22 -0000 1.10 @@ -453,12 +453,12 @@ Reference<XStatement> xStmt = _xConnection->createStatement(); if ( xStmt.is() ) { - Reference<XResultSet> xRes(xStmt->executeQuery(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" SELECT COUNT(*) FROM SYSTEM_SESSIONS WHERE USER_NAME ='SA'"))),UNO_QUERY); + Reference<XResultSet> xRes(xStmt->executeQuery(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SELECT COUNT(*) FROM SYSTEM_SESSIONS WHERE USER_NAME ='SA'"))),UNO_QUERY); Reference<XRow> xRow(xRes,UNO_QUERY); if ( xRow.is() && xRes->next() ) bLastOne = xRow->getInt(1) == 1; if ( bLastOne ) - xStmt->execute(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("shutdown"))); + xStmt->execute(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SHUTDOWN"))); } } } @@ -478,6 +478,8 @@ { ::osl::MutexGuard aGuard(m_aMutex); Reference<XConnection> xCon(Source.Source,UNO_QUERY); + if ( xCon.is() ) + { TWeakPairVector::iterator i = m_aConnections.begin(); for (; m_aConnections.end() != i; ++i) { @@ -487,13 +489,14 @@ break; } } - if ( !xCon.is() ) + } + else { Reference< XStorage> xStorage(Source.Source,UNO_QUERY); if ( xStorage.is() ) { ::rtl::OUString sKey = StorageContainer::getRegisteredKey(xStorage); - i = ::std::find_if(m_aConnections.begin(),m_aConnections.end(),::std::compose1( + TWeakPairVector::iterator i = ::std::find_if(m_aConnections.begin(),m_aConnections.end(),::std::compose1( ::std::bind2nd(::std::equal_to< ::rtl::OUString >(),sKey) ,::std::compose1(::std::select1st<TWeakConnectionPair>(),::std::select2nd< TWeakPair >()))); if ( i != m_aConnections.end() ) @@ -530,6 +533,7 @@ TWeakPairVector::iterator i = ::std::find_if(m_aConnections.begin(),m_aConnections.end(),::std::compose1( ::std::bind2nd(::std::equal_to< ::rtl::OUString >(),sKey) ,::std::compose1(::std::select1st<TWeakConnectionPair>(),::std::select2nd< TWeakPair >()))); + OSL_ENSURE( i != m_aConnections.end(), "ODriverDelegator::preCommit: they're committing a storage which I do not know!" ); if ( i != m_aConnections.end() ) { try @@ -538,14 +542,22 @@ if ( xConnection.is() ) { Reference< XStatement> xStmt = xConnection->createStatement(); + OSL_ENSURE( xStmt.is(), "ODriverDelegator::preCommit: no statement!" ); if ( xStmt.is() ) - { - xStmt->execute(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SET WRITE_DELAY 2"))); - } + xStmt->execute( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SET WRITE_DELAY 0" ) ) ); + + sal_Bool bPreviousAutoCommit = xConnection->getAutoCommit(); + xConnection->setAutoCommit( sal_False ); + xConnection->commit(); + xConnection->setAutoCommit( bPreviousAutoCommit ); + + if ( xStmt.is() ) + xStmt->execute( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SET WRITE_DELAY 60" ) ) ); } } catch(Exception&) { + OSL_ENSURE( false, "ODriverDelegator::preCommit: caught an exception!" ); } } } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
