diff options
| author | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2010-10-11 13:03:37 +0100 |
|---|---|---|
| committer | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2010-11-05 09:34:48 +0000 |
| commit | 56c02b0f94c3922f7d998b8abf8616d1ee8160c9 (patch) | |
| tree | 71a8041fda28bfed6f15893774d4f244935f6c3c /psycopg/connection_int.c | |
| parent | 09983db6ed3aca1856e550c8a32c51831cd3c618 (diff) | |
| download | psycopg2-56c02b0f94c3922f7d998b8abf8616d1ee8160c9.tar.gz | |
Added tpc_recover method.
Diffstat (limited to 'psycopg/connection_int.c')
| -rw-r--r-- | psycopg/connection_int.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/psycopg/connection_int.c b/psycopg/connection_int.c index 6024a2b..d92d53f 100644 --- a/psycopg/connection_int.c +++ b/psycopg/connection_int.c @@ -957,3 +957,36 @@ conn_tpc_command(connectionObject *self, const char *cmd, XidObject *xid) return rv; } +/* conn_tpc_recover -- return a list of pending TPC Xid */ + +PyObject * +conn_tpc_recover(connectionObject *self) +{ + int status; + PyObject *xids = NULL; + PyObject *rv = NULL; + PyObject *tmp; + + /* store the status to restore it. */ + status = self->status; + + if (!(xids = xid_recover((PyObject *)self))) { goto exit; } + + if (status == CONN_STATUS_READY && self->status == CONN_STATUS_BEGIN) { + /* recover began a transaction: let's abort it. */ + if (!(tmp = PyObject_CallMethod((PyObject *)self, "rollback", NULL))) { + goto exit; + } + Py_DECREF(tmp); + } + + /* all fine */ + rv = xids; + xids = NULL; + +exit: + Py_XDECREF(xids); + + return rv; + +} |
