mirror of
https://github.com/pocoproject/poco.git
synced 2024-12-13 10:32:57 +01:00
Merge pull request #4257 from pocoproject/4244-postgres-setAutoCommit-should-not-call-startTransaction
4244 postgres set auto commit should not call start transaction
This commit is contained in:
commit
5fa1779f22
@ -106,7 +106,7 @@ public:
|
||||
void startTransaction();
|
||||
/// Start transaction
|
||||
|
||||
bool isTransaction();
|
||||
bool isTransaction() const;
|
||||
/// Returns true iff a transaction is a transaction is in progress, false otherwise.
|
||||
|
||||
void commit();
|
||||
@ -115,13 +115,13 @@ public:
|
||||
void rollback();
|
||||
/// Rollback trabsaction
|
||||
|
||||
bool isAutoCommit();
|
||||
bool isAutoCommit() const;
|
||||
/// is the connection in auto commit mode?
|
||||
|
||||
void setAutoCommit(bool aShouldAutoCommit = true);
|
||||
/// is the connection in auto commit mode?
|
||||
|
||||
bool isAsynchronousCommit();
|
||||
bool isAsynchronousCommit() const;
|
||||
/// is the connection in Asynchronous commit mode?
|
||||
|
||||
void setAsynchronousCommit(bool aShouldAsynchronousCommit = true);
|
||||
@ -133,10 +133,10 @@ public:
|
||||
void setTransactionIsolation(Poco::UInt32 aTI);
|
||||
/// Sets the transaction isolation level.
|
||||
|
||||
Poco::UInt32 transactionIsolation();
|
||||
Poco::UInt32 transactionIsolation() const;
|
||||
/// Returns the transaction isolation level.
|
||||
|
||||
bool hasTransactionIsolation(Poco::UInt32 aTI);
|
||||
static bool hasTransactionIsolation(Poco::UInt32 aTI);
|
||||
/// Returns true iff the transaction isolation level corresponding
|
||||
/// to the supplied bitmask is supported.
|
||||
|
||||
@ -288,7 +288,7 @@ inline SessionHandle::operator PGconn * ()
|
||||
}
|
||||
|
||||
|
||||
inline Poco::FastMutex&SessionHandle::mutex()
|
||||
inline Poco::FastMutex& SessionHandle::mutex()
|
||||
{
|
||||
return _sessionMutex;
|
||||
}
|
||||
@ -300,19 +300,19 @@ inline std::string SessionHandle::connectionString() const
|
||||
}
|
||||
|
||||
|
||||
inline bool SessionHandle::isTransaction()
|
||||
inline bool SessionHandle::isTransaction() const
|
||||
{
|
||||
return _inTransaction;
|
||||
}
|
||||
|
||||
|
||||
inline bool SessionHandle::isAutoCommit()
|
||||
inline bool SessionHandle::isAutoCommit() const
|
||||
{
|
||||
return _isAutoCommit;
|
||||
}
|
||||
|
||||
|
||||
inline bool SessionHandle::isAsynchronousCommit()
|
||||
inline bool SessionHandle::isAsynchronousCommit() const
|
||||
{
|
||||
return _isAsynchronousCommit;
|
||||
}
|
||||
|
@ -282,6 +282,7 @@ void SessionHandle::rollback()
|
||||
|
||||
void SessionHandle::setAutoCommit(bool aShouldAutoCommit)
|
||||
{
|
||||
// There is no PostgreSQL API call to switch autocommit (unchained) mode off.
|
||||
if (aShouldAutoCommit == _isAutoCommit)
|
||||
{
|
||||
return;
|
||||
@ -289,11 +290,8 @@ void SessionHandle::setAutoCommit(bool aShouldAutoCommit)
|
||||
|
||||
if (aShouldAutoCommit)
|
||||
{
|
||||
commit(); // end any in process transaction
|
||||
}
|
||||
else
|
||||
{
|
||||
startTransaction(); // start a new transaction
|
||||
if (isTransaction())
|
||||
commit(); // end any in process transaction
|
||||
}
|
||||
|
||||
_isAutoCommit = aShouldAutoCommit;
|
||||
@ -388,7 +386,7 @@ void SessionHandle::setTransactionIsolation(Poco::UInt32 aTI)
|
||||
}
|
||||
|
||||
|
||||
Poco::UInt32 SessionHandle::transactionIsolation()
|
||||
Poco::UInt32 SessionHandle::transactionIsolation() const
|
||||
{
|
||||
return _tranactionIsolationLevel;
|
||||
}
|
||||
|
@ -1897,11 +1897,7 @@ void SQLExecutor::sessionTransaction(const std::string& connect)
|
||||
|
||||
bool autoCommit = _pSession->getFeature("autoCommit");
|
||||
|
||||
// Next four lines inverted as autoCommit set to true is the normal mode
|
||||
// autocommit set to false is the same as issuing a "begin" statement
|
||||
_pSession->setFeature("autoCommit", false);
|
||||
assertTrue (_pSession->isTransaction());
|
||||
|
||||
// autoCommit set to true is the normal mode
|
||||
_pSession->setFeature("autoCommit", true);
|
||||
assertTrue (!_pSession->isTransaction());
|
||||
|
||||
@ -1996,7 +1992,6 @@ void SQLExecutor::transaction(const std::string& connect)
|
||||
bool autoCommit = _pSession->getFeature("autoCommit");
|
||||
|
||||
_pSession->setFeature("autoCommit", false);
|
||||
assertTrue (_pSession->isTransaction());
|
||||
_pSession->setFeature("autoCommit", true);
|
||||
assertTrue (!_pSession->isTransaction());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user