summaryrefslogtreecommitdiff
path: root/psycopg/connection_int.c
diff options
context:
space:
mode:
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>2010-10-12 00:27:04 +0100
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>2010-11-05 09:34:49 +0000
commit4fdcfe365c2836d77cb2b497fc6c04fa924e190d (patch)
treea88a9b0ff7d70d4c5bfdea65ce3aecf8930bcf1d /psycopg/connection_int.c
parent774be1d616d4f43c02d3e114d19950a425cabb2f (diff)
downloadpsycopg2-4fdcfe365c2836d77cb2b497fc6c04fa924e190d.tar.gz
xid_get_tid returns a Python string, not a buffer.
Diffstat (limited to 'psycopg/connection_int.c')
-rw-r--r--psycopg/connection_int.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/psycopg/connection_int.c b/psycopg/connection_int.c
index 2f2a48d..00e8fa4 100644
--- a/psycopg/connection_int.c
+++ b/psycopg/connection_int.c
@@ -939,18 +939,20 @@ conn_tpc_command(connectionObject *self, const char *cmd, XidObject *xid)
{
PGresult *pgres = NULL;
char *error = NULL;
- char *tid = NULL;
+ PyObject *tid = NULL;
+ const char *ctid;
int rv = -1;
Dprintf("conn_tpc_command: %s", cmd);
/* convert the xid into PostgreSQL transaction id while keeping the GIL */
if (!(tid = xid_get_tid(xid))) { goto exit; }
+ if (!(ctid = PyString_AsString(tid))) { goto exit; }
Py_BEGIN_ALLOW_THREADS;
pthread_mutex_lock(&self->lock);
- if (0 > (rv = pq_tpc_command_locked(self, cmd, tid,
+ if (0 > (rv = pq_tpc_command_locked(self, cmd, ctid,
&pgres, &error, &_save))) {
pthread_mutex_unlock(&self->lock);
Py_BLOCK_THREADS;
@@ -962,7 +964,7 @@ conn_tpc_command(connectionObject *self, const char *cmd, XidObject *xid)
Py_END_ALLOW_THREADS;
exit:
- PyMem_Free(tid);
+ Py_XDECREF(tid);
return rv;
}