diff options
| author | Federico Di Gregorio <fog@initd.org> | 2008-07-26 15:09:20 +0200 |
|---|---|---|
| committer | Federico Di Gregorio <fog@initd.org> | 2008-07-26 15:09:20 +0200 |
| commit | e95a4d9d2ee995715f09431039360de6717e4738 (patch) | |
| tree | 37ac2226e6db67f6a763fb87e8011b5575ac9aa2 | |
| parent | a5e01ef0dfafc186fc59c022ca41e799850b68dd (diff) | |
| download | psycopg2-e95a4d9d2ee995715f09431039360de6717e4738.tar.gz | |
get_backend_pid() patch and fixes
| -rw-r--r-- | ChangeLog | 5 | ||||
| -rw-r--r-- | NEWS | 6 | ||||
| -rw-r--r-- | psycopg/adapter_qstring.c | 7 | ||||
| -rw-r--r-- | psycopg/connection_type.c | 15 | ||||
| -rw-r--r-- | psycopg/psycopg.h | 2 |
5 files changed, 30 insertions, 5 deletions
@@ -1,3 +1,8 @@ +2008-07-26 Federico Di Gregorio <fog@initd.org> + + * psycopg/connection_type.c: merged get_backend_pid() method + by Casey Duncan. + 2008-06-28 Federico Di Gregorio <fog@initd.org> * setup.py: fixed problem with spaces in pg_config path. @@ -1,3 +1,9 @@ +What's new in psycopg 2.0.8 +--------------------------- + +* The connection object now has a get_backend_pid() method that + returns the current PostgreSQL connection backend process PID. + What's new in psycopg 2.0.7 --------------------------- 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." |
