Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita487e0d

Browse files
committed
Added postgres.h header for more type checking.
Changed the way that OID is retrieved on inserts. PQoidStatus appearsto be deprecated so I am using PQoidValue instead.
1 parent376fa51 commita487e0d

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

‎src/interfaces/python/pgmodule.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
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
returnPyInt_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-
constchar*str;
2129+
Oidoid;
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
casePGRES_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
returnPy_None;
21472148
}
21482149

21492150
/* otherwise, return the oid */
2150-
returnPyInt_FromLong(strtol(str,NULL,10));
2151+
returnPyInt_FromLong(oid);
21512152

21522153
casePGRES_COPY_OUT:/* no data will be received */
21532154
casePGRES_COPY_IN:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp