Skip to content

Commit

Permalink
PostgreSQL SessionHandle: const fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
frwilckens committed Nov 4, 2023
1 parent 6eec8ad commit 8740816
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
18 changes: 9 additions & 9 deletions Data/PostgreSQL/include/Poco/Data/PostgreSQL/SessionHandle.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class SessionHandle
void startTransaction();
/// Start transaction

bool isTransaction();
bool isTransaction() const;
/// Returns true iff a transaction is a transaction is in progress, false otherwise.

void commit();
Expand All @@ -115,13 +115,13 @@ class SessionHandle
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);
Expand All @@ -133,10 +133,10 @@ class SessionHandle
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.

Expand Down Expand Up @@ -288,7 +288,7 @@ inline SessionHandle::operator PGconn * ()
}


inline Poco::FastMutex&SessionHandle::mutex()
inline Poco::FastMutex& SessionHandle::mutex()
{
return _sessionMutex;
}
Expand All @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions Data/PostgreSQL/src/SessionHandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,15 +270,15 @@ void SessionHandle::rollback()

void SessionHandle::setAutoCommit(bool aShouldAutoCommit)
{
// There is no PostgreSQL API call to switch autocommit (unchained) mode off.
if (aShouldAutoCommit == _isAutoCommit)
{
return;
}

if (aShouldAutoCommit)
{
Poco::FastMutex::ScopedLock mutexLocker(_sessionMutex);
if (_inTransaction)
if (isTransaction())
commit(); // end any in process transaction
}

Expand Down Expand Up @@ -374,7 +374,7 @@ void SessionHandle::setTransactionIsolation(Poco::UInt32 aTI)
}


Poco::UInt32 SessionHandle::transactionIsolation()
Poco::UInt32 SessionHandle::transactionIsolation() const
{
return _tranactionIsolationLevel;
}
Expand Down
5 changes: 2 additions & 3 deletions Data/PostgreSQL/testsuite/src/SQLExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1991,11 +1991,10 @@ void SQLExecutor::transaction(const std::string& connect)

bool autoCommit = _pSession->getFeature("autoCommit");

/* _pSession->setFeature("autoCommit", false);
assertTrue (_pSession->isTransaction());
_pSession->setFeature("autoCommit", false);
_pSession->setFeature("autoCommit", true);
assertTrue (!_pSession->isTransaction());
*/

_pSession->setTransactionIsolation(Session::TRANSACTION_READ_COMMITTED);

{
Expand Down

0 comments on commit 8740816

Please sign in to comment.