mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-24 17:30:44 +02:00
* fix(Data::AbstracSessionImpl): protect autocommit feature handlers #4261 * chore(CI): re-enable mysql * MySQL SessionImpl: make sure autocommit mode is on when session is openend or reset. * PostgreSQL SessionImpl: reuse autocommit flag of AbstractSessionImpl. * Github workflow: re-activated linux-gcc-make-postgres * Fixed indentation in ci.yml * Fix for DataTest SQLExecutor: use connector * Data::Session: when parser is not used and autocommit mode is off, assume any SQL statement begins a transaction. * PostgreSQL: don't use SQL parser (it currently cannot handle placeholders). * PostgreSQL: added test sessionTransactionNoAutoCommit * PostgreSQL test suite: removed reference to generic SQLExecutor * PostgreSQL: fixes for sessionTransactionNoAutoCommit. * MySQL: added test sessionPoolAndUnicode (from #2801) * Fixed #define in sql-parser * Data generic testsuite: support numbered placeholders * PostgreSQL test suite: added missing include directory to Makefile. * Attempt to fix PostgreSQL Makefiles * PostgreSQL testsuite: added include path to Makefile * PostgreSQL testsuite: added PocoDataTest library to Makefile * DataTest SQLExecutor::formatSQL: don't use string_view * PostgreSQL test suite: delegated most tests to Poco::Data::Test * Makefile: added dependencies on Data-Tests * Weaken assumptions about async in generic transaction tests * Makefile: added dependency for Prometheus samples * Fix deadlock in DataTest SQLExecutor * PostgreSQL tests SQLExecutor: cleanup * feat(Data::AbstractSessionImpl): add autoCommit property and tests #4261 * Brought MySQL backend in line with _autoCommit flag of AbstractSessionImpl. --------- Co-authored-by: Friedrich Wilckens <frwilckens@gmail.com> Co-authored-by: Friedrich Wilckens <friedrich.wilckens@ingramcontent.com>
This commit is contained in:
committed by
GitHub
parent
80cde9e3e6
commit
86084cb7b2
@@ -36,7 +36,6 @@ const std::string SessionHandle::POSTGRESQL_SERIALIZABLE = "SERIALIZABLE";
|
||||
SessionHandle::SessionHandle():
|
||||
_pConnection(0),
|
||||
_inTransaction(false),
|
||||
_isAutoCommit(true),
|
||||
_isAsynchronousCommit(false),
|
||||
_tranactionIsolationLevel(Session::TRANSACTION_READ_COMMITTED)
|
||||
{
|
||||
@@ -157,7 +156,6 @@ void SessionHandle::disconnect()
|
||||
|
||||
_connectionString = std::string();
|
||||
_inTransaction= false;
|
||||
_isAutoCommit = true;
|
||||
_isAsynchronousCommit = false;
|
||||
_tranactionIsolationLevel = Session::TRANSACTION_READ_COMMITTED;
|
||||
}
|
||||
@@ -280,21 +278,13 @@ void SessionHandle::rollback()
|
||||
}
|
||||
|
||||
|
||||
void SessionHandle::setAutoCommit(bool aShouldAutoCommit)
|
||||
void SessionHandle::autoCommit(bool val)
|
||||
{
|
||||
// There is no PostgreSQL API call to switch autocommit (unchained) mode off.
|
||||
if (aShouldAutoCommit == _isAutoCommit)
|
||||
if (isTransaction())
|
||||
{
|
||||
return;
|
||||
throw Poco::InvalidAccessException();
|
||||
}
|
||||
|
||||
if (aShouldAutoCommit)
|
||||
{
|
||||
if (isTransaction())
|
||||
commit(); // end any in process transaction
|
||||
}
|
||||
|
||||
_isAutoCommit = aShouldAutoCommit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -60,6 +60,7 @@ SessionImpl::SessionImpl(const std::string& aConnectionString, std::size_t aLogi
|
||||
Poco::Data::AbstractSessionImpl<SessionImpl>(aConnectionString, aLoginTimeout),
|
||||
_connectorName("postgresql")
|
||||
{
|
||||
setFeature("sqlParse", false); // the parse currently cannot handle the PostgreSQL placeholders $1, $2, etc.
|
||||
setProperty("handle", static_cast<SessionHandle*>(&_sessionHandle));
|
||||
setConnectionTimeout(CONNECTION_TIMEOUT_DEFAULT);
|
||||
open();
|
||||
@@ -134,7 +135,7 @@ void SessionImpl::open(const std::string& aConnectionString)
|
||||
_sessionHandle.connect(createConnectionStringFromOptionsMap(optionsMap));
|
||||
|
||||
addFeature("autoCommit",
|
||||
&SessionImpl::setAutoCommit,
|
||||
&SessionImpl::autoCommit,
|
||||
&SessionImpl::isAutoCommit);
|
||||
|
||||
addFeature("asynchronousCommit",
|
||||
@@ -206,15 +207,18 @@ void SessionImpl::rollback()
|
||||
}
|
||||
|
||||
|
||||
void SessionImpl::setAutoCommit(const std::string&, bool aValue)
|
||||
void SessionImpl::autoCommit(const std::string& s, bool val)
|
||||
{
|
||||
_sessionHandle.setAutoCommit(aValue);
|
||||
if (val != getAutoCommit(s)) {
|
||||
_sessionHandle.autoCommit(val);
|
||||
AbstractSessionImpl::setAutoCommit(s, val);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool SessionImpl::isAutoCommit(const std::string&) const
|
||||
bool SessionImpl::isAutoCommit(const std::string& s) const
|
||||
{
|
||||
return _sessionHandle.isAutoCommit();
|
||||
return AbstractSessionImpl::getAutoCommit(s);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user