Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Poco::Data::PostgreSQL::SessionHandle::setAutoCommit(bool) should not call commit() or startTransaction() #4244

Closed
frwilckens opened this issue Nov 2, 2023 · 1 comment · Fixed by #4257
Assignees
Labels

Comments

@frwilckens
Copy link
Member

setAutoCommit currently calls commit() when autocommit is set to true and calls startTransaction() otherwise. This contradicts the new code (introduced in bd06526) in Data::Session:

void Session::begin() { if (isAutocommit()) { setFeature("autoCommit", false); _wasAutoCommit = true; } return _pImpl->begin(); }

For the PostgreSQL backend, setFeature("autoCommit", false) calls setAutoCommit(false) which in turn calls startTransaction(). Hence a transaction is already underway when Session()::begin() calls _pImpl->begin(), which raises an exception.

Since starting a transaction in Poco::Data::Session now changes the autocommit mode , setting the autocommit mode should not in turn start a transaction. The PostgreSQL test program also needs to be changed. It asserts that a transaction is under way after setting the autocommit mode to false:

_pSession->setFeature("autoCommit", false); assertTrue (_pSession->isTransaction());

@frwilckens frwilckens self-assigned this Nov 3, 2023
@aleks-f aleks-f added this to the Release 1.13.0 milestone Nov 3, 2023
@frwilckens
Copy link
Member Author

I removed the call to startTransaction() but left the call to commit() in case a transaction is under way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants