Skip to content
Snippets Groups Projects
Commit a487e0d3 authored by D'Arcy J.M. Cain's avatar D'Arcy J.M. Cain
Browse files

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.
parent 376fa516
Branches
Tags
No related merge requests found
......@@ -27,6 +27,7 @@
*/
#include <Python.h>
#include <postgres.h>
#include <libpq-fe.h>
#include <libpq/libpq-fs.h>
#include <stdio.h>
......@@ -492,9 +493,9 @@ pgsource_oidstatus(pgsourceobject * self, PyObject * args)
}
/* retrieves oid status */
if ((oid = PQoidValue(self->last_result)) == InvalidOid)
oid = 0;
if ((status = PQoidStatus(self->last_result)))
oid = atol(status);
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:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment