else:
return False
- @util.deprecated(
- "1.2",
- "The create_xid() method of the cx_Oracle dialect is deprecated and "
- "will be removed in a future release. "
- "Two-phase transaction support is no longer functional "
- "in SQLAlchemy's cx_Oracle dialect as of cx_Oracle 6.0b1, which no "
- "longer supports the API that SQLAlchemy relied upon.",
- )
def create_xid(self):
"""create a two-phase transaction ID.
def do_begin_twophase(self, connection, xid):
connection.connection.begin(*xid)
+ connection.connection.info["cx_oracle_xid"] = xid
def do_prepare_twophase(self, connection, xid):
result = connection.connection.prepare()
self, connection, xid, is_prepared=True, recover=False
):
self.do_rollback(connection.connection)
+ # TODO: need to end XA state here
def do_commit_twophase(
self, connection, xid, is_prepared=True, recover=False
):
+
if not is_prepared:
self.do_commit(connection.connection)
else:
+ if recover:
+ raise NotImplementedError(
+ "2pc recovery not implemented for cx_Oracle"
+ )
oci_prepared = connection.info["cx_oracle_prepared"]
if oci_prepared:
self.do_commit(connection.connection)
+ # TODO: need to end XA state here
def do_set_input_sizes(self, cursor, list_of_tuples, context):
if self.positional:
cursor.setinputsizes(**{key: dbtype for key, dbtype in collection})
def do_recover_twophase(self, connection):
- connection.info.pop("cx_oracle_prepared", None)
+ raise NotImplementedError(
+ "recover two phase query for cx_Oracle not implemented"
+ )
dialect = OracleDialect_cx_oracle
def checkout(dbapi_con, con_record, con_proxy):
_all_conns.add(dbapi_con)
+ @event.listens_for(engine, "checkin")
+ def checkin(dbapi_connection, connection_record):
+ # work around cx_Oracle issue:
+ # https://github.com/oracle/python-cx_Oracle/issues/530
+ # invalidate oracle connections that had 2pc set up
+ if "cx_oracle_xid" in connection_record.info:
+ connection_record.invalidate()
+
@run_reap_dbs.for_db("oracle")
def _reap_oracle_dbs(url, idents):
[
no_support("firebird", "no SA implementation"),
no_support("mssql", "two-phase xact not supported by drivers"),
- no_support(
- "oracle", "two-phase xact not implemented in SQLA/oracle"
- ),
no_support(
"sqlite", "two-phase xact not supported by database"
),
["mysql", "mariadb"],
"still can't get recover to work w/ MariaDB / MySQL",
)
+ + skip_if("oracle", "recovery not functional")
)
@property