diff options
Diffstat (limited to 'psycopg')
| -rw-r--r-- | psycopg/adapter_qstring.c | 7 | ||||
| -rw-r--r-- | psycopg/connection_type.c | 15 | ||||
| -rw-r--r-- | psycopg/psycopg.h | 2 |
3 files changed, 19 insertions, 5 deletions
diff --git a/psycopg/adapter_qstring.c b/psycopg/adapter_qstring.c index 3684039..f469fe4 100644 --- a/psycopg/adapter_qstring.c +++ b/psycopg/adapter_qstring.c @@ -39,7 +39,7 @@ /** the quoting code */ #ifndef PSYCOPG_OWN_QUOTING -static size_t +size_t qstring_escape(char *to, char *from, size_t len, PGconn *conn) { #if PG_MAJOR_VERSION > 8 || \ @@ -53,7 +53,7 @@ qstring_escape(char *to, char *from, size_t len, PGconn *conn) return PQescapeString(to, from, len); } #else -static size_t +size_t qstring_escape(char *to, char *from, size_t len, PGconn *conn) { int i, j; @@ -100,9 +100,6 @@ qstring_quote(qstringObject *self) self->encoding but if the encoding is not specified we don't know what to do and we raise an exception */ - /* TODO: we need a real translation table from postgres encoding names to - python ones here */ - Dprintf("qstring_quote: encoding to %s", self->encoding); if (PyUnicode_Check(self->wrapped) && self->encoding) { diff --git a/psycopg/connection_type.c b/psycopg/connection_type.c index 3cdbf1f..35b116a 100644 --- a/psycopg/connection_type.c +++ b/psycopg/connection_type.c @@ -307,6 +307,19 @@ psyco_conn_lobject(connectionObject *self, PyObject *args, PyObject *keywds) return obj; } +/* get the current backend pid */ + +#define psyco_conn_get_backend_pid_doc \ +"get_backend_pid() -- Get backend process id." + +static PyObject * +psyco_conn_get_backend_pid(connectionObject *self) +{ + EXC_IF_CONN_CLOSED(self); + + return PyInt_FromLong((long)PQbackendPID(self->pgconn)); +} + #endif static PyObject * @@ -339,6 +352,8 @@ static struct PyMethodDef connectionObject_methods[] = { METH_VARARGS, psyco_conn_set_client_encoding_doc}, {"get_transaction_status", (PyCFunction)psyco_conn_get_transaction_status, METH_VARARGS, psyco_conn_get_transaction_status_doc}, + {"get_backend_pid", (PyCFunction)psyco_conn_get_backend_pid, + METH_NOARGS, psyco_conn_get_backend_pid_doc}, {"lobject", (PyCFunction)psyco_conn_lobject, METH_VARARGS|METH_KEYWORDS, psyco_conn_lobject_doc}, #endif diff --git a/psycopg/psycopg.h b/psycopg/psycopg.h index 7d79cfb..138383e 100644 --- a/psycopg/psycopg.h +++ b/psycopg/psycopg.h @@ -142,6 +142,8 @@ HIDDEN PyObject *psyco_GetDecimalType(void); HIDDEN void psyco_set_error(PyObject *exc, PyObject *curs, const char *msg, const char *pgerror, const char *pgcode); +HIDDEN size_t qstring_escape(char *to, char *from, size_t len, PGconn *conn); + /* Exceptions docstrings */ #define Error_doc \ "Base class for error exceptions." |
