File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change 2727 */
2828
2929#include <Python.h>
30+ #include <postgres.h>
3031#include <libpq-fe.h>
3132#include <libpq/libpq-fs.h>
3233#include <stdio.h>
@@ -492,9 +493,9 @@ pgsource_oidstatus(pgsourceobject * self, PyObject * args)
492493 }
493494
494495 /* retrieves oid status */
495- oid = 0 ;
496- if (( status = PQoidStatus ( self -> last_result )))
497- oid = atol ( status );
496+ if (( oid = PQoidValue ( self -> last_result )) == InvalidOid )
497+ oid = 0 ;
498+
498499 return PyInt_FromLong (oid );
499500}
500501
@@ -2125,7 +2126,7 @@ pg_query(pgobject * self, PyObject * args)
21252126 /* checks result status */
21262127 if ((status = PQresultStatus (result )) != PGRES_TUPLES_OK )
21272128 {
2128- const char * str ;
2129+ Oid oid ;
21292130
21302131 PQclear (result );
21312132
@@ -2140,14 +2141,14 @@ pg_query(pgobject * self, PyObject * args)
21402141 PyErr_SetString (PGError , PQerrorMessage (self -> cnx ));
21412142 break ;
21422143 case PGRES_COMMAND_OK : /* could be an INSERT */
2143- if (* ( str = PQoidStatus (result )) == 0 ) /* nope */
2144+ if (( oid = PQoidValue (result )) == InvalidOid ) /* nope */
21442145 {
21452146 Py_INCREF (Py_None );
21462147 return Py_None ;
21472148 }
21482149
21492150 /* otherwise, return the oid */
2150- return PyInt_FromLong (strtol ( str , NULL , 10 ) );
2151+ return PyInt_FromLong (oid );
21512152
21522153 case PGRES_COPY_OUT : /* no data will be received */
21532154 case PGRES_COPY_IN :
You can’t perform that action at this time.
0 commit comments