From a487e0d333d7287f79dc2cb7d7bc9bf23033e7b0 Mon Sep 17 00:00:00 2001 From: "D'Arcy J.M. Cain" Date: Sat, 3 Mar 2001 13:42:37 +0000 Subject: [PATCH] Added postgres.h header for more type checking. Changed the way that OID is retrieved on inserts. PQoidStatus appears to be deprecated so I am using PQoidValue instead. --- src/interfaces/python/pgmodule.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/interfaces/python/pgmodule.c b/src/interfaces/python/pgmodule.c index d51f8c7b04..99911a97f6 100644 --- a/src/interfaces/python/pgmodule.c +++ b/src/interfaces/python/pgmodule.c @@ -27,6 +27,7 @@ */ #include +#include #include #include #include @@ -492,9 +493,9 @@ pgsource_oidstatus(pgsourceobject * self, PyObject * args) } /* retrieves oid status */ - oid = 0; - if ((status = PQoidStatus(self->last_result))) - oid = atol(status); + if ((oid = PQoidValue(self->last_result)) == InvalidOid) + oid = 0; + return PyInt_FromLong(oid); } @@ -2125,7 +2126,7 @@ pg_query(pgobject * self, PyObject * args) /* checks result status */ if ((status = PQresultStatus(result)) != PGRES_TUPLES_OK) { - const char *str; + Oid oid; PQclear(result); @@ -2140,14 +2141,14 @@ pg_query(pgobject * self, PyObject * args) PyErr_SetString(PGError, PQerrorMessage(self->cnx)); break; case PGRES_COMMAND_OK: /* could be an INSERT */ - if (*(str = PQoidStatus(result)) == 0) /* nope */ + if ((oid = PQoidValue(result)) == InvalidOid) /* nope */ { Py_INCREF(Py_None); return Py_None; } /* otherwise, return the oid */ - return PyInt_FromLong(strtol(str, NULL, 10)); + return PyInt_FromLong(oid); case PGRES_COPY_OUT: /* no data will be received */ case PGRES_COPY_IN: -- 2.11.0