diff options
| author | mike bayer <mike_mp@zzzcomputing.com> | 2020-12-09 18:10:53 +0000 |
|---|---|---|
| committer | Gerrit Code Review <gerrit@bbpush.zzzcomputing.com> | 2020-12-09 18:10:53 +0000 |
| commit | a15aeba4fb22503c1eb235fdc2e7a574136ca7dc (patch) | |
| tree | 8202e93b847c9e98dfd53661f4d56be62b51ceee /lib/sqlalchemy/dialects/oracle/base.py | |
| parent | f508b867f119fa75e8bec76e22b11641a1ee77db (diff) | |
| parent | 7528c2465b3e56ed094f155bff2a3ab8c89cc84f (diff) | |
| download | sqlalchemy-a15aeba4fb22503c1eb235fdc2e7a574136ca7dc.tar.gz | |
Merge "Implement Oracle SERIALIZABLE + real read of isolation level"
Diffstat (limited to 'lib/sqlalchemy/dialects/oracle/base.py')
| -rw-r--r-- | lib/sqlalchemy/dialects/oracle/base.py | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/lib/sqlalchemy/dialects/oracle/base.py b/lib/sqlalchemy/dialects/oracle/base.py index 371a6702e..4e195d9ce 100644 --- a/lib/sqlalchemy/dialects/oracle/base.py +++ b/lib/sqlalchemy/dialects/oracle/base.py @@ -79,18 +79,14 @@ This step is also required when using table reflection, i.e. autoload=True:: in a :class:`_schema.Column` to specify the option of an autoincrementing column. +.. _oracle_isolation_level: + Transaction Isolation Level / Autocommit ---------------------------------------- -The Oracle database supports "READ COMMITTED" and "SERIALIZABLE" modes -of isolation, however the SQLAlchemy Oracle dialect currently only has -explicit support for "READ COMMITTED". It is possible to emit a -"SET TRANSACTION" statement on a connection in order to use SERIALIZABLE -isolation, however the SQLAlchemy dialect will remain unaware of this setting, -such as if the :meth:`_engine.Connection.get_isolation_level` method is used; -this method is hardcoded to return "READ COMMITTED" right now. - -The AUTOCOMMIT isolation level is also supported by the cx_Oracle dialect. +The Oracle database supports "READ COMMITTED" and "SERIALIZABLE" modes of +isolation. The AUTOCOMMIT isolation level is also supported by the cx_Oracle +dialect. To set using per-connection execution options:: @@ -99,15 +95,27 @@ To set using per-connection execution options:: isolation_level="AUTOCOMMIT" ) +For ``READ COMMITTED`` and ``SERIALIZABLE``, the Oracle dialect sets the +level at the session level using ``ALTER SESSION``, which is reverted back +to its default setting when the connection is returned to the connection +pool. + Valid values for ``isolation_level`` include: * ``READ COMMITTED`` * ``AUTOCOMMIT`` +* ``SERIALIZABLE`` +.. note:: The implementation :meth:`_engine.Connection.get_isolation_level` + implemented by the Oracle dialect necessarily forces the start of + a transaction using the Oracle LOCAL_TRANSACTION_ID function; otherwise + no level is normally readable. .. versionadded:: 1.3.16 added support for AUTOCOMMIT to the cx_oracle dialect - as well as the notion of a default isolation level, currently hardcoded - to "READ COMMITTED". + as well as the notion of a default isolation level + +.. versionadded:: 1.3.21 Added support for SERIALIZABLE as well as live + reading of the isolation level. .. seealso:: @@ -1549,19 +1557,13 @@ class OracleDialect(default.DefaultDialect): connection, additional_tests ) - _isolation_lookup = ["READ COMMITTED"] + _isolation_lookup = ["READ COMMITTED", "SERIALIZABLE"] def get_isolation_level(self, connection): - return "READ COMMITTED" + raise NotImplementedError("implemented by cx_Oracle dialect") def set_isolation_level(self, connection, level): - # prior to adding AUTOCOMMIT support for cx_Oracle, the Oracle dialect - # had no notion of setting the isolation level. As Oracle - # does not have a straightforward way of getting the isolation level - # if a server-side transaction is not yet in progress, we currently - # hardcode to only support "READ COMMITTED" and "AUTOCOMMIT" at the - # cx_oracle level. See #5200. - pass + raise NotImplementedError("implemented by cx_Oracle dialect") def has_table(self, connection, table_name, schema=None): if not schema: |
