mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-02-18 18:00:35 +03:00
Raise NotSuppoertdError if tpc is used with PostgreSQL < 8.1
This commit is contained in:
parent
ab8e145063
commit
5dbeeba0f2
|
@ -147,6 +147,15 @@ HIDDEN PyObject *conn_tpc_recover(connectionObject *self);
|
||||||
"in asynchronous mode"); \
|
"in asynchronous mode"); \
|
||||||
return NULL; }
|
return NULL; }
|
||||||
|
|
||||||
|
#define EXC_IF_TPC_NOT_SUPPORTED(self) \
|
||||||
|
if ((self)->server_version < 80100) { \
|
||||||
|
PyErr_Format(NotSupportedError, \
|
||||||
|
"server version %d: " \
|
||||||
|
"two-phase transactions not supported", \
|
||||||
|
(self)->server_version); \
|
||||||
|
return NULL; \
|
||||||
|
}
|
||||||
|
|
||||||
#define EXC_IF_TPC_BEGIN(self, cmd) if ((self)->tpc_xid) { \
|
#define EXC_IF_TPC_BEGIN(self, cmd) if ((self)->tpc_xid) { \
|
||||||
PyErr_Format(ProgrammingError, "%s cannot be used " \
|
PyErr_Format(ProgrammingError, "%s cannot be used " \
|
||||||
"during a two-phase transaction", #cmd); \
|
"during a two-phase transaction", #cmd); \
|
||||||
|
|
|
@ -179,6 +179,7 @@ static PyObject *
|
||||||
psyco_conn_xid(connectionObject *self, PyObject *args, PyObject *kwargs)
|
psyco_conn_xid(connectionObject *self, PyObject *args, PyObject *kwargs)
|
||||||
{
|
{
|
||||||
EXC_IF_CONN_CLOSED(self);
|
EXC_IF_CONN_CLOSED(self);
|
||||||
|
EXC_IF_TPC_NOT_SUPPORTED(self);
|
||||||
|
|
||||||
return PyObject_Call((PyObject *)&XidType, args, kwargs);
|
return PyObject_Call((PyObject *)&XidType, args, kwargs);
|
||||||
}
|
}
|
||||||
|
@ -196,6 +197,7 @@ psyco_conn_tpc_begin(connectionObject *self, PyObject *args)
|
||||||
|
|
||||||
EXC_IF_CONN_CLOSED(self);
|
EXC_IF_CONN_CLOSED(self);
|
||||||
EXC_IF_CONN_ASYNC(self, tpc_begin);
|
EXC_IF_CONN_ASYNC(self, tpc_begin);
|
||||||
|
EXC_IF_TPC_NOT_SUPPORTED(self);
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "O", &oxid)) {
|
if (!PyArg_ParseTuple(args, "O", &oxid)) {
|
||||||
goto exit;
|
goto exit;
|
||||||
|
@ -363,6 +365,7 @@ psyco_conn_tpc_commit(connectionObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
EXC_IF_CONN_CLOSED(self);
|
EXC_IF_CONN_CLOSED(self);
|
||||||
EXC_IF_CONN_ASYNC(self, tpc_commit);
|
EXC_IF_CONN_ASYNC(self, tpc_commit);
|
||||||
|
EXC_IF_TPC_NOT_SUPPORTED(self);
|
||||||
|
|
||||||
return _psyco_conn_tpc_finish(self, args,
|
return _psyco_conn_tpc_finish(self, args,
|
||||||
conn_commit, "COMMIT PREPARED");
|
conn_commit, "COMMIT PREPARED");
|
||||||
|
@ -376,6 +379,7 @@ psyco_conn_tpc_rollback(connectionObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
EXC_IF_CONN_CLOSED(self);
|
EXC_IF_CONN_CLOSED(self);
|
||||||
EXC_IF_CONN_ASYNC(self, tpc_rollback);
|
EXC_IF_CONN_ASYNC(self, tpc_rollback);
|
||||||
|
EXC_IF_TPC_NOT_SUPPORTED(self);
|
||||||
|
|
||||||
return _psyco_conn_tpc_finish(self, args,
|
return _psyco_conn_tpc_finish(self, args,
|
||||||
conn_rollback, "ROLLBACK PREPARED");
|
conn_rollback, "ROLLBACK PREPARED");
|
||||||
|
@ -390,6 +394,7 @@ psyco_conn_tpc_recover(connectionObject *self, PyObject *args)
|
||||||
EXC_IF_CONN_CLOSED(self);
|
EXC_IF_CONN_CLOSED(self);
|
||||||
EXC_IF_CONN_ASYNC(self, tpc_recover);
|
EXC_IF_CONN_ASYNC(self, tpc_recover);
|
||||||
EXC_IF_TPC_PREPARED(self, tpc_recover);
|
EXC_IF_TPC_PREPARED(self, tpc_recover);
|
||||||
|
EXC_IF_TPC_NOT_SUPPORTED(self);
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "")) { return NULL; }
|
if (!PyArg_ParseTuple(args, "")) { return NULL; }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user