]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Update transaction / connection handling
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 14 May 2020 16:50:11 +0000 (12:50 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 17 May 2020 20:32:22 +0000 (16:32 -0400)
commit0e53221eef50b3274841fbd1eb41e32f5dfc4e69
treee1c13d067b0db5e0aeee8b934dc0f934154ef9f3
parent79de84b25e87bbb7fa94f0dd513b4abc76e05a7e
Update transaction / connection handling

step one, do away with __connection attribute and using
awkward AttributeError logic

step two, move all management of "connection._transaction"
into the transaction objects themselves where it's easier
to follow.

build MarkerTransaction that takes the role of
"do-nothing block"

new connection datamodel is: connection._transaction, always
a root, connection._nested_transaction, always a nested.

nested transactions still chain to each other as this
is still sort of necessary but they consider the root
transaction separately, and the marker transactions
not at all.

introduce new InvalidRequestError subclass
PendingRollbackError.  Apply to connection and session
for all cases where a transaction needs to be rolled
back before continuing.   Within Connection,
both PendingRollbackError as well as ResourceClosedError
are now raised directly without being handled by
handle_dbapi_error();  this removes these two exception
cases from the handle_error event handler as well as
from StatementError wrapping, as these two exceptions are
not statement oriented and are instead programmatic
issues, that the application is failing to handle database
errors properly.

Revise savepoints so that when a release fails, they set
themselves as inactive so that their rollback() method
does not throw another exception.

Give savepoints another go on MySQL, can't get release working
however get support for basic round trip going

Fixes: #5327
Change-Id: Ia3cbbf56d4882fcc7980f90519412f1711fae74d
13 files changed:
doc/build/errors.rst
lib/sqlalchemy/engine/base.py
lib/sqlalchemy/engine/cursor.py
lib/sqlalchemy/engine/events.py
lib/sqlalchemy/exc.py
lib/sqlalchemy/future/engine.py
lib/sqlalchemy/orm/session.py
lib/sqlalchemy/testing/assertions.py
lib/sqlalchemy/testing/plugin/plugin_base.py
test/engine/test_reconnect.py
test/engine/test_transaction.py
test/orm/test_transaction.py
test/requirements.py