diff options
| author | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2010-10-08 22:03:06 +0100 |
|---|---|---|
| committer | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2010-11-05 09:34:48 +0000 |
| commit | 4f66de494b2509d45f0752e13170d41468eae561 (patch) | |
| tree | c7d7ef16255ee76b3a991ae395bc1c92fc65140e /psycopg/connection_int.c | |
| parent | 4588fa50f2c7a99dae580f2d09d4fb03e23e9ae4 (diff) | |
| download | psycopg2-4f66de494b2509d45f0752e13170d41468eae561.tar.gz | |
Added tpc_prepare and CONN_STATUS_PREPARED.
Diffstat (limited to 'psycopg/connection_int.c')
| -rw-r--r-- | psycopg/connection_int.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/psycopg/connection_int.c b/psycopg/connection_int.c index 84233ba..6024a2b 100644 --- a/psycopg/connection_int.c +++ b/psycopg/connection_int.c @@ -928,3 +928,32 @@ conn_tpc_begin(connectionObject *self, XidObject *xid) return 0; } + +/* conn_tpc_command -- run one of the TPC-related PostgreSQL commands. + * + * The function doesn't change the connection state as it can be used + * for many commands and for recovered transactions. */ + +int +conn_tpc_command(connectionObject *self, const char *cmd, XidObject *xid) +{ + PGresult *pgres = NULL; + char *error = NULL; + int rv; + + Dprintf("conn_tpc_command: %s", cmd); + + Py_BEGIN_ALLOW_THREADS; + pthread_mutex_lock(&self->lock); + + rv = pq_tpc_command_locked(self, cmd, xid, &pgres, &error, &_save); + + pthread_mutex_unlock(&self->lock); + Py_END_ALLOW_THREADS; + + if (rv < 0) { + pq_complete_error(self, &pgres, &error); + } + return rv; +} + |
