aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/python/pgmodule.c
diff options
context:
space:
mode:
authorD'Arcy J.M. Cain <darcy@druid.net>2001-03-03 13:42:37 +0000
committerD'Arcy J.M. Cain <darcy@druid.net>2001-03-03 13:42:37 +0000
commita487e0d333d7287f79dc2cb7d7bc9bf23033e7b0 (patch)
treebe04efd65544acbde61813759d5184c22183aa6f /src/interfaces/python/pgmodule.c
parent376fa516bd4d051e7ac4448aa7baff1a0bb3d3fb (diff)
downloadpostgresql-a487e0d333d7287f79dc2cb7d7bc9bf23033e7b0.tar.gz
postgresql-a487e0d333d7287f79dc2cb7d7bc9bf23033e7b0.zip
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.
Diffstat (limited to 'src/interfaces/python/pgmodule.c')
-rw-r--r--src/interfaces/python/pgmodule.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/interfaces/python/pgmodule.c b/src/interfaces/python/pgmodule.c
index d51f8c7b040..99911a97f6a 100644
--- a/src/interfaces/python/pgmodule.c
+++ b/src/interfaces/python/pgmodule.c
@@ -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 */
- 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: