static PyObject* notify_repr(notifyObject *self) { PyObject *rv = NULL; PyObject *format = NULL; PyObject *args = NULL; if (!(format = Text_FromUTF8("Notify(%r, %r, %r)"))) { goto exit; } if (!(args = PyTuple_New(3))) { goto exit; } Py_INCREF(self->pid); PyTuple_SET_ITEM(args, 0, self->pid); Py_INCREF(self->channel); PyTuple_SET_ITEM(args, 1, self->channel); Py_INCREF(self->payload); PyTuple_SET_ITEM(args, 2, self->payload); rv = Text_Format(format, args); exit: Py_XDECREF(args); Py_XDECREF(format); return rv; }
static PyObject* column_repr(columnObject *self) { PyObject *rv = NULL; PyObject *format = NULL; PyObject *args = NULL; PyObject *tmp; if (!(format = Text_FromUTF8("Column(name=%r, type_code=%r)"))) { goto exit; } if (!(args = PyTuple_New(2))) { goto exit; } tmp = self->name ? self->name : Py_None; Py_INCREF(tmp); PyTuple_SET_ITEM(args, 0, tmp); tmp = self->type_code ? self->type_code : Py_None; Py_INCREF(tmp); PyTuple_SET_ITEM(args, 1, tmp); rv = Text_Format(format, args); exit: Py_XDECREF(args); Py_XDECREF(format); return rv; }
/* Return the PostgreSQL transaction_id for this XA xid. * * PostgreSQL wants just a string, while the DBAPI supports the XA standard * and thus a triple. We use the same conversion algorithm implemented by JDBC * in order to allow some form of interoperation. * * The function must be called while holding the GIL. * * see also: the pgjdbc implementation * http://cvs.pgfoundry.org/cgi-bin/cvsweb.cgi/jdbc/pgjdbc/org/postgresql/xa/RecoveredXid.java?rev=1.2 */ PyObject * xid_get_tid(xidObject *self) { PyObject *rv = NULL; PyObject *egtrid = NULL; PyObject *ebqual = NULL; PyObject *format = NULL; PyObject *args = NULL; if (Py_None == self->format_id) { /* Unparsed xid: return the gtrid. */ Py_INCREF(self->gtrid); rv = self->gtrid; } else { /* XA xid: mash together the components. */ if (!(egtrid = _xid_encode64(self->gtrid))) { goto exit; } if (!(ebqual = _xid_encode64(self->bqual))) { goto exit; } /* rv = "%d_%s_%s" % (format_id, egtrid, ebqual) */ if (!(format = Text_FromUTF8("%d_%s_%s"))) { goto exit; } if (!(args = PyTuple_New(3))) { goto exit; } Py_INCREF(self->format_id); PyTuple_SET_ITEM(args, 0, self->format_id); PyTuple_SET_ITEM(args, 1, egtrid); egtrid = NULL; PyTuple_SET_ITEM(args, 2, ebqual); ebqual = NULL; if (!(rv = Text_Format(format, args))) { goto exit; } } exit: Py_XDECREF(args); Py_XDECREF(format); Py_XDECREF(egtrid); Py_XDECREF(ebqual); return rv; }
static PyObject * xid_repr(xidObject *self) { PyObject *rv = NULL; PyObject *format = NULL; PyObject *args = NULL; if (Py_None == self->format_id) { if (!(format = Text_FromUTF8("<Xid: %r (unparsed)>"))) { goto exit; } if (!(args = PyTuple_New(1))) { goto exit; } Py_INCREF(self->gtrid); PyTuple_SET_ITEM(args, 0, self->gtrid); } else { if (!(format = Text_FromUTF8("<Xid: (%r, %r, %r)>"))) { goto exit; } if (!(args = PyTuple_New(3))) { goto exit; } Py_INCREF(self->format_id); PyTuple_SET_ITEM(args, 0, self->format_id); Py_INCREF(self->gtrid); PyTuple_SET_ITEM(args, 1, self->gtrid); Py_INCREF(self->bqual); PyTuple_SET_ITEM(args, 2, self->bqual); } rv = Text_Format(format, args); exit: Py_XDECREF(args); Py_XDECREF(format); return rv; }