mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-06-30 17:53:06 +03:00
Notify and Xid objects and types renamed for consistency
They were the only objects starting with uppercase. My fault.
This commit is contained in:
parent
73949cd1b8
commit
a210859326
|
@ -88,7 +88,7 @@ typedef struct {
|
||||||
2 that something horrible happened */
|
2 that something horrible happened */
|
||||||
long int mark; /* number of commits/rollbacks done so far */
|
long int mark; /* number of commits/rollbacks done so far */
|
||||||
int status; /* status of the connection */
|
int status; /* status of the connection */
|
||||||
XidObject *tpc_xid; /* Transaction ID in two-phase commit */
|
xidObject *tpc_xid; /* Transaction ID in two-phase commit */
|
||||||
|
|
||||||
long int async; /* 1 means the connection is async */
|
long int async; /* 1 means the connection is async */
|
||||||
int protocol; /* protocol version */
|
int protocol; /* protocol version */
|
||||||
|
@ -151,9 +151,9 @@ HIDDEN int conn_set_autocommit(connectionObject *self, int value);
|
||||||
RAISES_NEG HIDDEN int conn_switch_isolation_level(connectionObject *self, int level);
|
RAISES_NEG HIDDEN int conn_switch_isolation_level(connectionObject *self, int level);
|
||||||
RAISES_NEG HIDDEN int conn_set_client_encoding(connectionObject *self, const char *enc);
|
RAISES_NEG HIDDEN int conn_set_client_encoding(connectionObject *self, const char *enc);
|
||||||
HIDDEN int conn_poll(connectionObject *self);
|
HIDDEN int conn_poll(connectionObject *self);
|
||||||
RAISES_NEG HIDDEN int conn_tpc_begin(connectionObject *self, XidObject *xid);
|
RAISES_NEG HIDDEN int conn_tpc_begin(connectionObject *self, xidObject *xid);
|
||||||
RAISES_NEG HIDDEN int conn_tpc_command(connectionObject *self,
|
RAISES_NEG HIDDEN int conn_tpc_command(connectionObject *self,
|
||||||
const char *cmd, XidObject *xid);
|
const char *cmd, xidObject *xid);
|
||||||
HIDDEN PyObject *conn_tpc_recover(connectionObject *self);
|
HIDDEN PyObject *conn_tpc_recover(connectionObject *self);
|
||||||
|
|
||||||
/* exception-raising macros */
|
/* exception-raising macros */
|
||||||
|
|
|
@ -183,7 +183,7 @@ conn_notifies_process(connectionObject *self)
|
||||||
if (!(channel = conn_text_from_chars(self, pgn->relname))) { goto error; }
|
if (!(channel = conn_text_from_chars(self, pgn->relname))) { goto error; }
|
||||||
if (!(payload = conn_text_from_chars(self, pgn->extra))) { goto error; }
|
if (!(payload = conn_text_from_chars(self, pgn->extra))) { goto error; }
|
||||||
|
|
||||||
if (!(notify = PyObject_CallFunctionObjArgs((PyObject *)&NotifyType,
|
if (!(notify = PyObject_CallFunctionObjArgs((PyObject *)¬ifyType,
|
||||||
pid, channel, payload, NULL))) {
|
pid, channel, payload, NULL))) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
@ -1216,7 +1216,7 @@ exit:
|
||||||
* until PREPARE. */
|
* until PREPARE. */
|
||||||
|
|
||||||
RAISES_NEG int
|
RAISES_NEG int
|
||||||
conn_tpc_begin(connectionObject *self, XidObject *xid)
|
conn_tpc_begin(connectionObject *self, xidObject *xid)
|
||||||
{
|
{
|
||||||
PGresult *pgres = NULL;
|
PGresult *pgres = NULL;
|
||||||
char *error = NULL;
|
char *error = NULL;
|
||||||
|
@ -1250,7 +1250,7 @@ conn_tpc_begin(connectionObject *self, XidObject *xid)
|
||||||
* for many commands and for recovered transactions. */
|
* for many commands and for recovered transactions. */
|
||||||
|
|
||||||
RAISES_NEG int
|
RAISES_NEG int
|
||||||
conn_tpc_command(connectionObject *self, const char *cmd, XidObject *xid)
|
conn_tpc_command(connectionObject *self, const char *cmd, xidObject *xid)
|
||||||
{
|
{
|
||||||
PGresult *pgres = NULL;
|
PGresult *pgres = NULL;
|
||||||
char *error = NULL;
|
char *error = NULL;
|
||||||
|
|
|
@ -183,7 +183,7 @@ 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);
|
EXC_IF_TPC_NOT_SUPPORTED(self);
|
||||||
|
|
||||||
return PyObject_Call((PyObject *)&XidType, args, kwargs);
|
return PyObject_Call((PyObject *)&xidType, args, kwargs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -194,7 +194,7 @@ static PyObject *
|
||||||
psyco_conn_tpc_begin(connectionObject *self, PyObject *args)
|
psyco_conn_tpc_begin(connectionObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
PyObject *rv = NULL;
|
PyObject *rv = NULL;
|
||||||
XidObject *xid = NULL;
|
xidObject *xid = NULL;
|
||||||
PyObject *oxid;
|
PyObject *oxid;
|
||||||
|
|
||||||
EXC_IF_CONN_CLOSED(self);
|
EXC_IF_CONN_CLOSED(self);
|
||||||
|
@ -286,7 +286,7 @@ _psyco_conn_tpc_finish(connectionObject *self, PyObject *args,
|
||||||
_finish_f opc_f, char *tpc_cmd)
|
_finish_f opc_f, char *tpc_cmd)
|
||||||
{
|
{
|
||||||
PyObject *oxid = NULL;
|
PyObject *oxid = NULL;
|
||||||
XidObject *xid = NULL;
|
xidObject *xid = NULL;
|
||||||
PyObject *rv = NULL;
|
PyObject *rv = NULL;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "|O", &oxid)) { goto exit; }
|
if (!PyArg_ParseTuple(args, "|O", &oxid)) { goto exit; }
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
#ifndef PSYCOPG_NOTIFY_H
|
#ifndef PSYCOPG_NOTIFY_H
|
||||||
#define PSYCOPG_NOTIFY_H 1
|
#define PSYCOPG_NOTIFY_H 1
|
||||||
|
|
||||||
extern HIDDEN PyTypeObject NotifyType;
|
extern HIDDEN PyTypeObject notifyType;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
PyObject_HEAD
|
PyObject_HEAD
|
||||||
|
@ -35,6 +35,6 @@ typedef struct {
|
||||||
PyObject *channel;
|
PyObject *channel;
|
||||||
PyObject *payload;
|
PyObject *payload;
|
||||||
|
|
||||||
} NotifyObject;
|
} notifyObject;
|
||||||
|
|
||||||
#endif /* PSYCOPG_NOTIFY_H */
|
#endif /* PSYCOPG_NOTIFY_H */
|
||||||
|
|
|
@ -52,22 +52,22 @@ static const char payload_doc[] =
|
||||||
"of the server this member is always the empty string.";
|
"of the server this member is always the empty string.";
|
||||||
|
|
||||||
static PyMemberDef notify_members[] = {
|
static PyMemberDef notify_members[] = {
|
||||||
{ "pid", T_OBJECT, offsetof(NotifyObject, pid), READONLY, (char *)pid_doc },
|
{ "pid", T_OBJECT, offsetof(notifyObject, pid), READONLY, (char *)pid_doc },
|
||||||
{ "channel", T_OBJECT, offsetof(NotifyObject, channel), READONLY, (char *)channel_doc },
|
{ "channel", T_OBJECT, offsetof(notifyObject, channel), READONLY, (char *)channel_doc },
|
||||||
{ "payload", T_OBJECT, offsetof(NotifyObject, payload), READONLY, (char *)payload_doc },
|
{ "payload", T_OBJECT, offsetof(notifyObject, payload), READONLY, (char *)payload_doc },
|
||||||
{ NULL }
|
{ NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
notify_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
notify_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
||||||
{
|
{
|
||||||
NotifyObject *self = (NotifyObject *)type->tp_alloc(type, 0);
|
notifyObject *self = (notifyObject *)type->tp_alloc(type, 0);
|
||||||
|
|
||||||
return (PyObject *)self;
|
return (PyObject *)self;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
notify_init(NotifyObject *self, PyObject *args, PyObject *kwargs)
|
notify_init(notifyObject *self, PyObject *args, PyObject *kwargs)
|
||||||
{
|
{
|
||||||
static char *kwlist[] = {"pid", "channel", "payload", NULL};
|
static char *kwlist[] = {"pid", "channel", "payload", NULL};
|
||||||
PyObject *pid = NULL, *channel = NULL, *payload = NULL;
|
PyObject *pid = NULL, *channel = NULL, *payload = NULL;
|
||||||
|
@ -97,7 +97,7 @@ notify_init(NotifyObject *self, PyObject *args, PyObject *kwargs)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
notify_traverse(NotifyObject *self, visitproc visit, void *arg)
|
notify_traverse(notifyObject *self, visitproc visit, void *arg)
|
||||||
{
|
{
|
||||||
Py_VISIT(self->pid);
|
Py_VISIT(self->pid);
|
||||||
Py_VISIT(self->channel);
|
Py_VISIT(self->channel);
|
||||||
|
@ -106,7 +106,7 @@ notify_traverse(NotifyObject *self, visitproc visit, void *arg)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
notify_dealloc(NotifyObject *self)
|
notify_dealloc(notifyObject *self)
|
||||||
{
|
{
|
||||||
Py_CLEAR(self->pid);
|
Py_CLEAR(self->pid);
|
||||||
Py_CLEAR(self->channel);
|
Py_CLEAR(self->channel);
|
||||||
|
@ -124,7 +124,7 @@ notify_del(PyObject *self)
|
||||||
|
|
||||||
/* Convert a notify into a 2 or 3 items tuple. */
|
/* Convert a notify into a 2 or 3 items tuple. */
|
||||||
static PyObject *
|
static PyObject *
|
||||||
notify_astuple(NotifyObject *self, int with_payload)
|
notify_astuple(notifyObject *self, int with_payload)
|
||||||
{
|
{
|
||||||
PyObject *tself;
|
PyObject *tself;
|
||||||
if (!(tself = PyTuple_New(with_payload ? 3 : 2))) { return NULL; }
|
if (!(tself = PyTuple_New(with_payload ? 3 : 2))) { return NULL; }
|
||||||
|
@ -162,15 +162,15 @@ notify_astuple(NotifyObject *self, int with_payload)
|
||||||
* the (pid, channel) pair is no more equivalent as dict key to the Notify.
|
* the (pid, channel) pair is no more equivalent as dict key to the Notify.
|
||||||
*/
|
*/
|
||||||
static PyObject *
|
static PyObject *
|
||||||
notify_richcompare(NotifyObject *self, PyObject *other, int op)
|
notify_richcompare(notifyObject *self, PyObject *other, int op)
|
||||||
{
|
{
|
||||||
PyObject *rv = NULL;
|
PyObject *rv = NULL;
|
||||||
PyObject *tself = NULL;
|
PyObject *tself = NULL;
|
||||||
PyObject *tother = NULL;
|
PyObject *tother = NULL;
|
||||||
|
|
||||||
if (Py_TYPE(other) == &NotifyType) {
|
if (Py_TYPE(other) == ¬ifyType) {
|
||||||
if (!(tself = notify_astuple(self, 1))) { goto exit; }
|
if (!(tself = notify_astuple(self, 1))) { goto exit; }
|
||||||
if (!(tother = notify_astuple((NotifyObject *)other, 1))) { goto exit; }
|
if (!(tother = notify_astuple((notifyObject *)other, 1))) { goto exit; }
|
||||||
rv = PyObject_RichCompare(tself, tother, op);
|
rv = PyObject_RichCompare(tself, tother, op);
|
||||||
}
|
}
|
||||||
else if (PyTuple_Check(other)) {
|
else if (PyTuple_Check(other)) {
|
||||||
|
@ -190,7 +190,7 @@ exit:
|
||||||
|
|
||||||
|
|
||||||
static Py_hash_t
|
static Py_hash_t
|
||||||
notify_hash(NotifyObject *self)
|
notify_hash(notifyObject *self)
|
||||||
{
|
{
|
||||||
Py_hash_t rv = -1L;
|
Py_hash_t rv = -1L;
|
||||||
PyObject *tself = NULL;
|
PyObject *tself = NULL;
|
||||||
|
@ -207,7 +207,7 @@ exit:
|
||||||
|
|
||||||
|
|
||||||
static PyObject*
|
static PyObject*
|
||||||
notify_repr(NotifyObject *self)
|
notify_repr(notifyObject *self)
|
||||||
{
|
{
|
||||||
PyObject *rv = NULL;
|
PyObject *rv = NULL;
|
||||||
PyObject *format = NULL;
|
PyObject *format = NULL;
|
||||||
|
@ -237,13 +237,13 @@ exit:
|
||||||
/* Notify can be accessed as a 2 items tuple for backward compatibility */
|
/* Notify can be accessed as a 2 items tuple for backward compatibility */
|
||||||
|
|
||||||
static Py_ssize_t
|
static Py_ssize_t
|
||||||
notify_len(NotifyObject *self)
|
notify_len(notifyObject *self)
|
||||||
{
|
{
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
notify_getitem(NotifyObject *self, Py_ssize_t item)
|
notify_getitem(notifyObject *self, Py_ssize_t item)
|
||||||
{
|
{
|
||||||
if (item < 0)
|
if (item < 0)
|
||||||
item += 2;
|
item += 2;
|
||||||
|
@ -275,10 +275,10 @@ static PySequenceMethods notify_sequence = {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
PyTypeObject NotifyType = {
|
PyTypeObject notifyType = {
|
||||||
PyVarObject_HEAD_INIT(NULL, 0)
|
PyVarObject_HEAD_INIT(NULL, 0)
|
||||||
"psycopg2.extensions.Notify",
|
"psycopg2.extensions.Notify",
|
||||||
sizeof(NotifyObject),
|
sizeof(notifyObject),
|
||||||
0,
|
0,
|
||||||
(destructor)notify_dealloc, /* tp_dealloc */
|
(destructor)notify_dealloc, /* tp_dealloc */
|
||||||
0, /*tp_print*/
|
0, /*tp_print*/
|
||||||
|
|
|
@ -780,8 +780,8 @@ INIT_MODULE(_psycopg)(void)
|
||||||
Py_TYPE(&asisType) = &PyType_Type;
|
Py_TYPE(&asisType) = &PyType_Type;
|
||||||
Py_TYPE(&listType) = &PyType_Type;
|
Py_TYPE(&listType) = &PyType_Type;
|
||||||
Py_TYPE(&chunkType) = &PyType_Type;
|
Py_TYPE(&chunkType) = &PyType_Type;
|
||||||
Py_TYPE(&NotifyType) = &PyType_Type;
|
Py_TYPE(¬ifyType) = &PyType_Type;
|
||||||
Py_TYPE(&XidType) = &PyType_Type;
|
Py_TYPE(&xidType) = &PyType_Type;
|
||||||
Py_TYPE(&errorType) = &PyType_Type;
|
Py_TYPE(&errorType) = &PyType_Type;
|
||||||
Py_TYPE(&diagnosticsType) = &PyType_Type;
|
Py_TYPE(&diagnosticsType) = &PyType_Type;
|
||||||
|
|
||||||
|
@ -798,8 +798,8 @@ INIT_MODULE(_psycopg)(void)
|
||||||
if (PyType_Ready(&asisType) == -1) goto exit;
|
if (PyType_Ready(&asisType) == -1) goto exit;
|
||||||
if (PyType_Ready(&listType) == -1) goto exit;
|
if (PyType_Ready(&listType) == -1) goto exit;
|
||||||
if (PyType_Ready(&chunkType) == -1) goto exit;
|
if (PyType_Ready(&chunkType) == -1) goto exit;
|
||||||
if (PyType_Ready(&NotifyType) == -1) goto exit;
|
if (PyType_Ready(¬ifyType) == -1) goto exit;
|
||||||
if (PyType_Ready(&XidType) == -1) goto exit;
|
if (PyType_Ready(&xidType) == -1) goto exit;
|
||||||
errorType.tp_base = (PyTypeObject *)PyExc_StandardError;
|
errorType.tp_base = (PyTypeObject *)PyExc_StandardError;
|
||||||
if (PyType_Ready(&errorType) == -1) goto exit;
|
if (PyType_Ready(&errorType) == -1) goto exit;
|
||||||
if (PyType_Ready(&diagnosticsType) == -1) goto exit;
|
if (PyType_Ready(&diagnosticsType) == -1) goto exit;
|
||||||
|
@ -890,8 +890,8 @@ INIT_MODULE(_psycopg)(void)
|
||||||
PyModule_AddObject(module, "connection", (PyObject*)&connectionType);
|
PyModule_AddObject(module, "connection", (PyObject*)&connectionType);
|
||||||
PyModule_AddObject(module, "cursor", (PyObject*)&cursorType);
|
PyModule_AddObject(module, "cursor", (PyObject*)&cursorType);
|
||||||
PyModule_AddObject(module, "ISQLQuote", (PyObject*)&isqlquoteType);
|
PyModule_AddObject(module, "ISQLQuote", (PyObject*)&isqlquoteType);
|
||||||
PyModule_AddObject(module, "Notify", (PyObject*)&NotifyType);
|
PyModule_AddObject(module, "Notify", (PyObject*)¬ifyType);
|
||||||
PyModule_AddObject(module, "Xid", (PyObject*)&XidType);
|
PyModule_AddObject(module, "Xid", (PyObject*)&xidType);
|
||||||
PyModule_AddObject(module, "Diagnostics", (PyObject*)&diagnosticsType);
|
PyModule_AddObject(module, "Diagnostics", (PyObject*)&diagnosticsType);
|
||||||
#ifdef PSYCOPG_EXTENSIONS
|
#ifdef PSYCOPG_EXTENSIONS
|
||||||
PyModule_AddObject(module, "lobject", (PyObject*)&lobjectType);
|
PyModule_AddObject(module, "lobject", (PyObject*)&lobjectType);
|
||||||
|
@ -935,8 +935,8 @@ INIT_MODULE(_psycopg)(void)
|
||||||
listType.tp_alloc = PyType_GenericAlloc;
|
listType.tp_alloc = PyType_GenericAlloc;
|
||||||
chunkType.tp_alloc = PyType_GenericAlloc;
|
chunkType.tp_alloc = PyType_GenericAlloc;
|
||||||
pydatetimeType.tp_alloc = PyType_GenericAlloc;
|
pydatetimeType.tp_alloc = PyType_GenericAlloc;
|
||||||
NotifyType.tp_alloc = PyType_GenericAlloc;
|
notifyType.tp_alloc = PyType_GenericAlloc;
|
||||||
XidType.tp_alloc = PyType_GenericAlloc;
|
xidType.tp_alloc = PyType_GenericAlloc;
|
||||||
errorType.tp_alloc = PyType_GenericAlloc;
|
errorType.tp_alloc = PyType_GenericAlloc;
|
||||||
diagnosticsType.tp_alloc = PyType_GenericAlloc;
|
diagnosticsType.tp_alloc = PyType_GenericAlloc;
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
#ifndef PSYCOPG_XID_H
|
#ifndef PSYCOPG_XID_H
|
||||||
#define PSYCOPG_XID_H 1
|
#define PSYCOPG_XID_H 1
|
||||||
|
|
||||||
extern HIDDEN PyTypeObject XidType;
|
extern HIDDEN PyTypeObject xidType;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
PyObject_HEAD
|
PyObject_HEAD
|
||||||
|
@ -41,11 +41,11 @@ typedef struct {
|
||||||
PyObject *prepared;
|
PyObject *prepared;
|
||||||
PyObject *owner;
|
PyObject *owner;
|
||||||
PyObject *database;
|
PyObject *database;
|
||||||
} XidObject;
|
} xidObject;
|
||||||
|
|
||||||
HIDDEN XidObject *xid_ensure(PyObject *oxid);
|
HIDDEN xidObject *xid_ensure(PyObject *oxid);
|
||||||
HIDDEN XidObject *xid_from_string(PyObject *s);
|
HIDDEN xidObject *xid_from_string(PyObject *s);
|
||||||
HIDDEN PyObject *xid_get_tid(XidObject *self);
|
HIDDEN PyObject *xid_get_tid(xidObject *self);
|
||||||
HIDDEN PyObject *xid_recover(PyObject *conn);
|
HIDDEN PyObject *xid_recover(PyObject *conn);
|
||||||
|
|
||||||
#endif /* PSYCOPG_XID_H */
|
#endif /* PSYCOPG_XID_H */
|
||||||
|
|
|
@ -67,21 +67,21 @@ static const char database_doc[] =
|
||||||
"Database the recovered transaction belongs to.";
|
"Database the recovered transaction belongs to.";
|
||||||
|
|
||||||
static PyMemberDef xid_members[] = {
|
static PyMemberDef xid_members[] = {
|
||||||
{ "format_id", T_OBJECT, offsetof(XidObject, format_id), READONLY, (char *)format_id_doc },
|
{ "format_id", T_OBJECT, offsetof(xidObject, format_id), READONLY, (char *)format_id_doc },
|
||||||
{ "gtrid", T_OBJECT, offsetof(XidObject, gtrid), READONLY, (char *)gtrid_doc },
|
{ "gtrid", T_OBJECT, offsetof(xidObject, gtrid), READONLY, (char *)gtrid_doc },
|
||||||
{ "bqual", T_OBJECT, offsetof(XidObject, bqual), READONLY, (char *)bqual_doc },
|
{ "bqual", T_OBJECT, offsetof(xidObject, bqual), READONLY, (char *)bqual_doc },
|
||||||
{ "prepared", T_OBJECT, offsetof(XidObject, prepared), READONLY, (char *)prepared_doc },
|
{ "prepared", T_OBJECT, offsetof(xidObject, prepared), READONLY, (char *)prepared_doc },
|
||||||
{ "owner", T_OBJECT, offsetof(XidObject, owner), READONLY, (char *)owner_doc },
|
{ "owner", T_OBJECT, offsetof(xidObject, owner), READONLY, (char *)owner_doc },
|
||||||
{ "database", T_OBJECT, offsetof(XidObject, database), READONLY, (char *)database_doc },
|
{ "database", T_OBJECT, offsetof(xidObject, database), READONLY, (char *)database_doc },
|
||||||
{ NULL }
|
{ NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
xid_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
xid_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
||||||
{
|
{
|
||||||
XidObject *self;
|
xidObject *self;
|
||||||
|
|
||||||
if (!(self = (XidObject *)type->tp_alloc(type, 0))) { return NULL; }
|
if (!(self = (xidObject *)type->tp_alloc(type, 0))) { return NULL; }
|
||||||
|
|
||||||
Py_INCREF(Py_None);
|
Py_INCREF(Py_None);
|
||||||
self->format_id = Py_None;
|
self->format_id = Py_None;
|
||||||
|
@ -100,7 +100,7 @@ xid_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
xid_init(XidObject *self, PyObject *args, PyObject *kwargs)
|
xid_init(xidObject *self, PyObject *args, PyObject *kwargs)
|
||||||
{
|
{
|
||||||
static char *kwlist[] = {"format_id", "gtrid", "bqual", NULL};
|
static char *kwlist[] = {"format_id", "gtrid", "bqual", NULL};
|
||||||
int format_id;
|
int format_id;
|
||||||
|
@ -165,7 +165,7 @@ xid_init(XidObject *self, PyObject *args, PyObject *kwargs)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
xid_traverse(XidObject *self, visitproc visit, void *arg)
|
xid_traverse(xidObject *self, visitproc visit, void *arg)
|
||||||
{
|
{
|
||||||
Py_VISIT(self->format_id);
|
Py_VISIT(self->format_id);
|
||||||
Py_VISIT(self->gtrid);
|
Py_VISIT(self->gtrid);
|
||||||
|
@ -177,7 +177,7 @@ xid_traverse(XidObject *self, visitproc visit, void *arg)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xid_dealloc(XidObject *self)
|
xid_dealloc(xidObject *self)
|
||||||
{
|
{
|
||||||
Py_CLEAR(self->format_id);
|
Py_CLEAR(self->format_id);
|
||||||
Py_CLEAR(self->gtrid);
|
Py_CLEAR(self->gtrid);
|
||||||
|
@ -196,13 +196,13 @@ xid_del(PyObject *self)
|
||||||
}
|
}
|
||||||
|
|
||||||
static Py_ssize_t
|
static Py_ssize_t
|
||||||
xid_len(XidObject *self)
|
xid_len(xidObject *self)
|
||||||
{
|
{
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
xid_getitem(XidObject *self, Py_ssize_t item)
|
xid_getitem(xidObject *self, Py_ssize_t item)
|
||||||
{
|
{
|
||||||
if (item < 0)
|
if (item < 0)
|
||||||
item += 3;
|
item += 3;
|
||||||
|
@ -224,13 +224,13 @@ xid_getitem(XidObject *self, Py_ssize_t item)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
xid_str(XidObject *self)
|
xid_str(xidObject *self)
|
||||||
{
|
{
|
||||||
return xid_get_tid(self);
|
return xid_get_tid(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
xid_repr(XidObject *self)
|
xid_repr(xidObject *self)
|
||||||
{
|
{
|
||||||
PyObject *rv = NULL;
|
PyObject *rv = NULL;
|
||||||
PyObject *format = NULL;
|
PyObject *format = NULL;
|
||||||
|
@ -305,10 +305,10 @@ static struct PyMethodDef xid_methods[] = {
|
||||||
{NULL}
|
{NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
PyTypeObject XidType = {
|
PyTypeObject xidType = {
|
||||||
PyVarObject_HEAD_INIT(NULL, 0)
|
PyVarObject_HEAD_INIT(NULL, 0)
|
||||||
"psycopg2.extensions.Xid",
|
"psycopg2.extensions.Xid",
|
||||||
sizeof(XidObject),
|
sizeof(xidObject),
|
||||||
0,
|
0,
|
||||||
(destructor)xid_dealloc, /* tp_dealloc */
|
(destructor)xid_dealloc, /* tp_dealloc */
|
||||||
0, /*tp_print*/
|
0, /*tp_print*/
|
||||||
|
@ -376,13 +376,13 @@ PyTypeObject XidType = {
|
||||||
* or use a regular string they have found in PostgreSQL's pg_prepared_xacts
|
* or use a regular string they have found in PostgreSQL's pg_prepared_xacts
|
||||||
* in order to recover a transaction not generated by psycopg.
|
* in order to recover a transaction not generated by psycopg.
|
||||||
*/
|
*/
|
||||||
XidObject *xid_ensure(PyObject *oxid)
|
xidObject *xid_ensure(PyObject *oxid)
|
||||||
{
|
{
|
||||||
XidObject *rv = NULL;
|
xidObject *rv = NULL;
|
||||||
|
|
||||||
if (PyObject_TypeCheck(oxid, &XidType)) {
|
if (PyObject_TypeCheck(oxid, &xidType)) {
|
||||||
Py_INCREF(oxid);
|
Py_INCREF(oxid);
|
||||||
rv = (XidObject *)oxid;
|
rv = (xidObject *)oxid;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
rv = xid_from_string(oxid);
|
rv = xid_from_string(oxid);
|
||||||
|
@ -445,7 +445,7 @@ _xid_decode64(PyObject *s)
|
||||||
* http://cvs.pgfoundry.org/cgi-bin/cvsweb.cgi/jdbc/pgjdbc/org/postgresql/xa/RecoveredXid.java?rev=1.2
|
* http://cvs.pgfoundry.org/cgi-bin/cvsweb.cgi/jdbc/pgjdbc/org/postgresql/xa/RecoveredXid.java?rev=1.2
|
||||||
*/
|
*/
|
||||||
PyObject *
|
PyObject *
|
||||||
xid_get_tid(XidObject *self)
|
xid_get_tid(xidObject *self)
|
||||||
{
|
{
|
||||||
PyObject *rv = NULL;
|
PyObject *rv = NULL;
|
||||||
PyObject *egtrid = NULL;
|
PyObject *egtrid = NULL;
|
||||||
|
@ -525,7 +525,7 @@ exit:
|
||||||
*
|
*
|
||||||
* Return NULL + exception if parsing failed. Else a new Xid object. */
|
* Return NULL + exception if parsing failed. Else a new Xid object. */
|
||||||
|
|
||||||
static XidObject *
|
static xidObject *
|
||||||
_xid_parse_string(PyObject *str) {
|
_xid_parse_string(PyObject *str) {
|
||||||
PyObject *regex;
|
PyObject *regex;
|
||||||
PyObject *m = NULL;
|
PyObject *m = NULL;
|
||||||
|
@ -536,7 +536,7 @@ _xid_parse_string(PyObject *str) {
|
||||||
PyObject *ebqual = NULL;
|
PyObject *ebqual = NULL;
|
||||||
PyObject *gtrid = NULL;
|
PyObject *gtrid = NULL;
|
||||||
PyObject *bqual = NULL;
|
PyObject *bqual = NULL;
|
||||||
XidObject *rv = NULL;
|
xidObject *rv = NULL;
|
||||||
|
|
||||||
/* check if the string is a possible XA triple with a regexp */
|
/* check if the string is a possible XA triple with a regexp */
|
||||||
if (!(regex = _xid_get_parse_regex())) { goto exit; }
|
if (!(regex = _xid_get_parse_regex())) { goto exit; }
|
||||||
|
@ -560,7 +560,7 @@ _xid_parse_string(PyObject *str) {
|
||||||
if (!(bqual = _xid_decode64(ebqual))) { goto exit; }
|
if (!(bqual = _xid_decode64(ebqual))) { goto exit; }
|
||||||
|
|
||||||
/* Try to build the xid with the parsed material */
|
/* Try to build the xid with the parsed material */
|
||||||
rv = (XidObject *)PyObject_CallFunctionObjArgs((PyObject *)&XidType,
|
rv = (xidObject *)PyObject_CallFunctionObjArgs((PyObject *)&xidType,
|
||||||
format_id, gtrid, bqual, NULL);
|
format_id, gtrid, bqual, NULL);
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
|
@ -579,14 +579,14 @@ exit:
|
||||||
/* Return a new Xid object representing a transaction ID not conform to
|
/* Return a new Xid object representing a transaction ID not conform to
|
||||||
* the XA specifications. */
|
* the XA specifications. */
|
||||||
|
|
||||||
static XidObject *
|
static xidObject *
|
||||||
_xid_unparsed_from_string(PyObject *str) {
|
_xid_unparsed_from_string(PyObject *str) {
|
||||||
XidObject *xid = NULL;
|
xidObject *xid = NULL;
|
||||||
XidObject *rv = NULL;
|
xidObject *rv = NULL;
|
||||||
PyObject *tmp;
|
PyObject *tmp;
|
||||||
|
|
||||||
/* fake args to work around the checks performed by the xid init */
|
/* fake args to work around the checks performed by the xid init */
|
||||||
if (!(xid = (XidObject *)PyObject_CallFunction((PyObject *)&XidType,
|
if (!(xid = (xidObject *)PyObject_CallFunction((PyObject *)&xidType,
|
||||||
"iss", 0, "", ""))) {
|
"iss", 0, "", ""))) {
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
@ -624,9 +624,9 @@ exit:
|
||||||
* If the xid is in the format generated by Psycopg, unpack the tuple into
|
* If the xid is in the format generated by Psycopg, unpack the tuple into
|
||||||
* the struct members. Otherwise generate an "unparsed" xid.
|
* the struct members. Otherwise generate an "unparsed" xid.
|
||||||
*/
|
*/
|
||||||
XidObject *
|
xidObject *
|
||||||
xid_from_string(PyObject *str) {
|
xid_from_string(PyObject *str) {
|
||||||
XidObject *rv;
|
xidObject *rv;
|
||||||
|
|
||||||
if (!(Bytes_Check(str) || PyUnicode_Check(str))) {
|
if (!(Bytes_Check(str) || PyUnicode_Check(str))) {
|
||||||
PyErr_SetString(PyExc_TypeError, "not a valid transaction id");
|
PyErr_SetString(PyExc_TypeError, "not a valid transaction id");
|
||||||
|
@ -654,7 +654,7 @@ xid_recover(PyObject *conn)
|
||||||
PyObject *rv = NULL;
|
PyObject *rv = NULL;
|
||||||
PyObject *curs = NULL;
|
PyObject *curs = NULL;
|
||||||
PyObject *xids = NULL;
|
PyObject *xids = NULL;
|
||||||
XidObject *xid = NULL;
|
xidObject *xid = NULL;
|
||||||
PyObject *recs = NULL;
|
PyObject *recs = NULL;
|
||||||
PyObject *rec = NULL;
|
PyObject *rec = NULL;
|
||||||
PyObject *item = NULL;
|
PyObject *item = NULL;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user