diff options
| -rw-r--r-- | psycopg/connection.h | 5 | ||||
| -rw-r--r-- | psycopg/connection_type.c | 2 |
2 files changed, 7 insertions, 0 deletions
diff --git a/psycopg/connection.h b/psycopg/connection.h index a555358..5b7c5d2 100644 --- a/psycopg/connection.h +++ b/psycopg/connection.h @@ -143,6 +143,11 @@ HIDDEN int conn_tpc_begin(connectionObject *self, XidObject *xid); "in asynchronous mode"); \ return NULL; } +#define EXC_IF_TPC_BEGIN(self, cmd) if ((self)->tpc_xid) { \ + PyErr_Format(ProgrammingError, "%s cannot be used " \ + "during a two-phase transaction", #cmd); \ + return NULL; } + #ifdef __cplusplus } #endif diff --git a/psycopg/connection_type.c b/psycopg/connection_type.c index d0e0c50..9cc32a2 100644 --- a/psycopg/connection_type.c +++ b/psycopg/connection_type.c @@ -137,6 +137,7 @@ psyco_conn_commit(connectionObject *self, PyObject *args) { EXC_IF_CONN_CLOSED(self); EXC_IF_CONN_ASYNC(self, commit); + EXC_IF_TPC_BEGIN(self, commit); if (!PyArg_ParseTuple(args, "")) return NULL; @@ -158,6 +159,7 @@ psyco_conn_rollback(connectionObject *self, PyObject *args) { EXC_IF_CONN_CLOSED(self); EXC_IF_CONN_ASYNC(self, rollback); + EXC_IF_TPC_BEGIN(self, rollback); if (!PyArg_ParseTuple(args, "")) return NULL; |
