Update of /usr/cvs/Public/pygresql/module
In directory druid.net:/tmp/cvs-serv27386/module

Modified Files:
        pgmodule.c 
Log Message:
Raise error when direct copy fails.  From Carl Staelin.


To see the diffs for this commit:
   
http://www.druid.net/pygresql/viewcvs.cgi/cvs/pygresql/module/pgmodule.c.diff?r1=1.75&r2=1.76

Index: pgmodule.c
===================================================================
RCS file: /usr/cvs/Public/pygresql/module/pgmodule.c,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -p -u -r1.75 -r1.76
--- pgmodule.c  24 Feb 2007 07:38:59 -0000      1.75
+++ pgmodule.c  12 Oct 2007 12:20:00 -0000      1.76
@@ -1,5 +1,5 @@
 /*
- * $Id: pgmodule.c,v 1.75 2007/02/24 07:38:59 cito Exp $
+ * $Id: pgmodule.c,v 1.76 2007/10/12 12:20:00 darcy Exp $
  * PyGres, version 2.2 A Python interface for PostgreSQL database. Written by
  * D'Arcy J.M. Cain, ([EMAIL PROTECTED]).  Based heavily on code written by
  * Pascal Andre, [EMAIL PROTECTED] Copyright (c) 1995, Pascal Andre
@@ -2336,7 +2336,11 @@ pg_putline(pgobject * self, PyObject * a
        }
 
        /* sends line to backend */
-       PQputline(self->cnx, line);
+       if (PQputline(self->cnx, line))
+       {
+               PyErr_SetString(PyExc_IOError, PQerrorMessage(self->cnx));
+               return NULL;
+       }
        Py_INCREF(Py_None);
        return Py_None;
 }
@@ -2406,7 +2410,11 @@ pg_endcopy(pgobject * self, PyObject * a
        }
 
        /* ends direct copy */
-       PQendcopy(self->cnx);
+       if (PQendcopy(self->cnx))
+       {
+               PyErr_SetString(PyExc_IOError, PQerrorMessage(self->cnx));
+               return NULL;
+       }
        Py_INCREF(Py_None);
        return Py_None;
 }
@@ -2619,12 +2627,31 @@ pg_inserttable(pgobject * self, PyObject
                *bufpt++ = '\n'; *bufpt = '\0';
 
                /* sends data */
-               PQputline(self->cnx, buffer);
+               if (PQputline(self->cnx, buffer))
+               {
+                       PyErr_SetString(PyExc_IOError, 
PQerrorMessage(self->cnx));
+                       PQendcopy(self->cnx);
+                       free(buffer);
+                       return NULL;
+               }
        }
 
        /* ends query */
-       PQputline(self->cnx, "\\.\n");
-       PQendcopy(self->cnx);
+       if (PQputline(self->cnx, "\\.\n"))
+       {
+               PyErr_SetString(PyExc_IOError, PQerrorMessage(self->cnx));
+               PQendcopy(self->cnx);
+               free(buffer);
+               return NULL;
+       }
+
+       if (PQendcopy(self->cnx))
+       {
+               PyErr_SetString(PyExc_IOError, PQerrorMessage(self->cnx));
+               free(buffer);
+               return NULL;
+       }
+
        free(buffer);
 
        /* no error : returns nothing */

_______________________________________________
PyGreSQL mailing list
[email protected]
http://mailman.vex.net/mailman/listinfo/pygresql

Reply via email to