From: Billy G. A. <bal...@us...> - 2001-09-30 06:34:08
|
Update of /cvsroot/pypgsql/pypgsql In directory usw-pr-cvs1:/tmp/cvs-serv32391 Modified Files: pgconnection.c Log Message: 29SEP2001 bga Fixed numerous bugs found during the development of the regres0 sion test cases for pgconnection.c. --- The PgConnection's attributes are now set to a value of None when finish() is called. --- Added regression tests for the pgconnection.c module. Index: pgconnection.c =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pgconnection.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** pgconnection.c 2001/09/24 07:10:56 1.10 --- pgconnection.c 2001/09/30 06:34:04 1.11 *************** *** 29,32 **** --- 29,36 ---- | Date Ini Description | | --------- --- ------------------------------------------------------- | + | 29SEP2001 bga Fixed numerous bugs found during the development of the | + | regression test cases for pgconnection.c. | + | --- The PgConnection's attributes are now set to a value of | + | None when finish() is called. | | 23SEP2001 bga Fixed problem when compiling with gcc. | | --- [Bug #464123] Removed pgFixEsc(). The need for it no | *************** *** 38,44 **** | --- Improved the error checking on the mode parameter in | | lo_creat(). | ! | --- Removed lo_get(). It doesn't provide any useful func- | ! | tionality since you never get a Large Object's OID from | ! | PgResult.getvalue(). You always get a PgLargeObject. | | 20SEP2001 bga [Bug #455514] Modified pgFixEsc to that if will also | | handle octal escape sequences. If the escape sequence | --- 42,47 ---- | --- Improved the error checking on the mode parameter in | | lo_creat(). | ! | --- Removed lo_get(). It's functionality is superceeded by | ! | the PgLargeObject constructor added to libpqmodule.c. | | 20SEP2001 bga [Bug #455514] Modified pgFixEsc to that if will also | | handle octal escape sequences. If the escape sequence | *************** *** 208,212 **** { PyErr_SetString(PqErr_InterfaceError, ! "PgConnection object is not opened"); return FALSE; } --- 211,215 ---- { PyErr_SetString(PqErr_InterfaceError, ! "PgConnection object is closed"); return FALSE; } *************** *** 324,328 **** onOff = ((onOff != 0) ? 1 : 0); ! if (!PQsetnonblocking(PgConnection_Get(self), onOff)) { PyErr_SetString(PqErr_InternalError, --- 327,331 ---- onOff = ((onOff != 0) ? 1 : 0); ! if (PQsetnonblocking(PgConnection_Get(self), onOff)) { PyErr_SetString(PqErr_InternalError, *************** *** 459,463 **** } ! if (!PQflush(PgConnection_Get(self))) { PyErr_SetString(PqErr_InternalError, --- 462,466 ---- } ! if (PQflush(PgConnection_Get(self))) { PyErr_SetString(PqErr_InternalError, *************** *** 544,547 **** --- 547,561 ---- self->conn = (PGconn *)NULL; + Py_XDECREF(self->host); self->host = Py_None; Py_XINCREF(Py_None); + Py_XDECREF(self->port); self->port = Py_None; Py_XINCREF(Py_None); + Py_XDECREF(self->db); self->db = Py_None; Py_XINCREF(Py_None); + Py_XDECREF(self->options); self->options = Py_None; Py_XINCREF(Py_None); + Py_XDECREF(self->tty); self->tty = Py_None; Py_XINCREF(Py_None); + Py_XDECREF(self->user); self->user = Py_None; Py_XINCREF(Py_None); + Py_XDECREF(self->pass); self->pass = Py_None; Py_XINCREF(Py_None); + Py_XDECREF(self->bePID); self->bePID = Py_None; Py_XINCREF(Py_None); + Py_XDECREF(self->socket); self->socket = Py_None; Py_XINCREF(Py_None); + Py_XDECREF(self->version); self->version = Py_None; Py_XINCREF(Py_None); + Py_XDECREF(self->notices); self->notices = Py_None; Py_XINCREF(Py_None); Py_INCREF(Py_None); *************** *** 636,644 **** size += MAX_BUFFER_SIZE; if ((ci_buf = (char *)PyMem_Realloc(ci_buf, size)) == (char *)NULL) ! { ! PyErr_SetString(PyExc_MemoryError, ! "Can't allocate buffer in getline()."); ! return NULL; ! } Py_BEGIN_ALLOW_THREADS --- 650,654 ---- size += MAX_BUFFER_SIZE; if ((ci_buf = (char *)PyMem_Realloc(ci_buf, size)) == (char *)NULL) ! return PyErr_NoMemory(); Py_BEGIN_ALLOW_THREADS *************** *** 664,670 **** static char libPQgetlineAsync_Doc[] = "getlineAsync() -- Reads a newline-terminated line of characters from the " ! "backend\n\t\t without blocking. Returns None if no data is present, an " ! "empty\n\t\t string if the end-of-copy-data marker is seen, or the\n" ! "\t\t the line of characters read"; static PyObject *libPQgetlineAsync(PgConnection *self, PyObject *args) --- 674,680 ---- static char libPQgetlineAsync_Doc[] = "getlineAsync() -- Reads a newline-terminated line of characters from the " ! "backend\n\t\t without blocking. Returns None if no data is present, " ! "'\\.' if\n\t\t the end-of-copy-data marker is seen, or the line of " ! "characters\n\t\t read"; static PyObject *libPQgetlineAsync(PgConnection *self, PyObject *args) *************** *** 676,680 **** if (!PgConnection_check((PyObject *)self)) ! return NULL; if (!PyArg_ParseTuple(args,"")) --- 686,690 ---- if (!PgConnection_check((PyObject *)self)) ! return (PyObject *)NULL; if (!PyArg_ParseTuple(args,"")) *************** *** 682,706 **** PyErr_SetString(PqErr_InterfaceError, "getlineAsync() takes no parameters"); ! return NULL; } cnx = PgConnection_Get(self); ! for (size = idx = leave = 0; leave; idx = size) { size += MAX_BUFFER_SIZE; if ((ci_buf = (char *)PyMem_Realloc(ci_buf, size)) == (char *)NULL) ! { ! PyErr_SetString(PyExc_MemoryError, ! "Can't allocate buffer in getlineAsync()."); ! return NULL; ! } ! if (!PQconsumeInput(PgConnection_Get(self))) { ! PyErr_SetString(PqErr_InternalError, ! PQerrorMessage(PgConnection_Get(self))); PyMem_Free(ci_buf); ! return NULL; } --- 692,712 ---- PyErr_SetString(PqErr_InterfaceError, "getlineAsync() takes no parameters"); ! return (PyObject *)NULL; } cnx = PgConnection_Get(self); ! for (size = idx = leave = 0; !leave; idx = size) { size += MAX_BUFFER_SIZE; + if ((ci_buf = (char *)PyMem_Realloc(ci_buf, size)) == (char *)NULL) ! return PyErr_NoMemory(); ! if (!PQconsumeInput(cnx)) { ! PyErr_SetString(PqErr_InternalError, PQerrorMessage(cnx)); PyMem_Free(ci_buf); ! return (PyObject *)NULL; } *************** *** 710,714 **** case -1: leave = 1; ! result = Py_BuildValue("s", ""); // return EOF indicator break; --- 716,720 ---- case -1: leave = 1; ! result = Py_BuildValue("s", "\\."); // return EOD indicator break; *************** *** 731,734 **** --- 737,743 ---- PyMem_Free(ci_buf); + if (PyErr_Occurred()) + return (PyObject *)NULL; + return result; } *************** *** 1036,1044 **** if (!strcmp(attr, "status")) ! return Py_BuildValue("i", PQstatus(cnx)); if (!strcmp(attr, "errorMessage")) { ! char *m = PQerrorMessage(cnx); if (*m == (char)0) { --- 1045,1068 ---- if (!strcmp(attr, "status")) ! if (cnx == (PGconn *)NULL) ! { ! Py_XINCREF(Py_None); ! return Py_None; ! } ! else ! return Py_BuildValue("i", PQstatus(cnx)); if (!strcmp(attr, "errorMessage")) { ! char *m; ! ! if (cnx == (PGconn *)NULL) ! { ! Py_XINCREF(Py_None); ! return Py_None; ! } ! ! m = PQerrorMessage(cnx); ! if (*m == (char)0) { *************** *** 1051,1058 **** if (!strcmp(attr, "isBusy")) ! return Py_BuildValue("i", PQisBusy(cnx)); if (!strcmp(attr, "isnonblocking")) ! return Py_BuildValue("i", PQisnonblocking(cnx)); if (!strcmp(attr, "__module__")) --- 1075,1094 ---- if (!strcmp(attr, "isBusy")) ! if (cnx == (PGconn *)NULL) ! { ! Py_XINCREF(Py_None); ! return Py_None; ! } ! else ! return Py_BuildValue("i", PQisBusy(cnx)); if (!strcmp(attr, "isnonblocking")) ! if (cnx == (PGconn *)NULL) ! { ! Py_XINCREF(Py_None); ! return Py_None; ! } ! else ! return Py_BuildValue("i", PQisnonblocking(cnx)); if (!strcmp(attr, "__module__")) |