Hello,

I've been looking at implementing two phase commit for the psycopg2
driver for PostgreSQL.  It was suggested that I bring up the issue on
this list to see if there were any suggestions about what form the API
should take.

The API from the initial patch I produced stuck pretty close to the
PostgreSQL API, adding three methods to the connection object:

prepare_transaction(xid) - prepare the transaction, using the given
ID.  This closes off the transaction, allowing a new one to be started
(if needed).

commit_prepared(xid) - commit a previously prepared transaction . Must
be called outside of a transaction (i.e. no execute() calls since the
last commit/rollback).

rollback_prepared(xid) - rollback a previously prepared transaction.

The idea being that this should be enough to plug psycopg2 into a
transaction manager such as Zope's transaction module or similar.

I understand that this API might not be implementable by other
database adapters, which brings up the question: what would be a good
API?

>From a quick search, I found two other adapters implementing 2pc both
with incompatible APIs:

kinterbasdb implements a Connection.prepare() method, which performs
the first phase and causes a subsequent commit() or rollback() to
complete that transaction.  Transaction identifiers are not exposed by
the API.

pymqi provides a patch to the DCOracle2 adapter.  It doesn't seem to
add any explicit API to the connection object, but DCOracle2 does have
an incompatible prepare() method used for prepared statements.


So is there any recommendations for what a two-phase commit API should
look like?

James.
_______________________________________________
DB-SIG maillist  -  DB-SIG@python.org
http://mail.python.org/mailman/listinfo/db-sig

Reply via email to