[PATCH] Fix misinterpretation of lo_unlink and lo_export return v alues in pgconnection.c
"Pinchart, Laurent" <[email protected]>
| Newsgroups | gmane.comp.python.db.pypgsql.user |
|---|---|
| Message-ID | <[email protected]> |
Hi, Here's a patch (against CVS HEAD) that fixes a misinterpretation of the lo_unlink and lo_export return values in pgconnection.c. Those functions return -1 when an error occurs, and 1 when successful, while pgconnection.c assumed that any return value other than 0 was an error. I haven't tested thepatch completely yet, but I checked that Connection.unlink raised an exception while still deleting the large object. Laurent Pinchart
pgconnection.c-CVS1.17.diff
(application/octet-stream, 784 B)
--- pgconnection.c 2003-06-12 12:12:51.000000000 +0200
+++ pgconnection.c.new 2003-06-12 12:12:11.000000000 +0200
@@ -985,7 +985,7 @@
if (!PyArg_ParseTuple(args,"is:lo_export", &oid, &filename))
return (PyObject *)NULL;
- if (!(lo_export(PgConnection_Get(self), oid, filename)))
+ if (lo_export(PgConnection_Get(self), oid, filename) < 0)
{
PyErr_SetString(PqErr_OperationalError, "Can't export large object.");
return (PyObject *)NULL;
@@ -1010,7 +1010,7 @@
if (!PyArg_ParseTuple(args,"i:lo_unlink", &oid))
return (PyObject *)NULL;
- if (lo_unlink(PgConnection_Get(self), oid))
+ if (lo_unlink(PgConnection_Get(self), oid) < 0)
{
PyErr_SetString(PyExc_IOError, "error unlinking large object");
return (PyObject *)NULL;