You can subscribe to this list here.
2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(52) |
Oct
(21) |
Nov
(10) |
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2002 |
Jan
(3) |
Feb
(7) |
Mar
|
Apr
(8) |
May
(1) |
Jun
(6) |
Jul
(4) |
Aug
(4) |
Sep
(18) |
Oct
(26) |
Nov
(7) |
Dec
(25) |
2003 |
Jan
(1) |
Feb
|
Mar
(1) |
Apr
(1) |
May
(1) |
Jun
(10) |
Jul
(10) |
Aug
|
Sep
|
Oct
(5) |
Nov
(2) |
Dec
(2) |
2004 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
(2) |
Jun
|
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2005 |
Jan
|
Feb
(1) |
Mar
(8) |
Apr
(1) |
May
(3) |
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
(11) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
From: Billy G. A. <bal...@us...> - 2001-09-23 04:02:19
|
Update of /cvsroot/pypgsql/pypgsql In directory usw-pr-cvs1:/tmp/cvs-serv17679 Modified Files: pgresult.c Log Message: 21SEP2001 bga I have removed resultErrorMessage as an attribute. It doesn't make sense to leave it since it will always be None. Why? Because any query that generates an error will raise an exception, not return a PgResult. Index: pgresult.c =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pgresult.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** pgresult.c 2001/09/16 17:54:52 1.9 --- pgresult.c 2001/09/23 04:02:17 1.10 *************** *** 29,32 **** --- 29,36 ---- | Date Ini Description | | --------- --- ------------------------------------------------------- | + | 21SEP2001 bga I have removed resultErrorMessage as an attribute. It | + | doesn't make sense to leave it since it will always be | + | None. Why? Because any query that generates an error | + | will raise an exception, not return a PgResult. | | 14SEP2001 bga Removed code related to PostgreSQL 6.5.x. We now only | | support PostgreSQL 7.0 and later. | *************** *** 116,126 **** self->type = Py_BuildValue("i", type); self->status = Py_BuildValue("i", PQresultStatus(res)); - if (*(m = PQresultErrorMessage(res)) == (char)0) - { - Py_INCREF(Py_None); - self->errmsg = Py_None; - } - else - self->errmsg = Py_BuildValue("s", m); self->ntuples = Py_BuildValue("i", PQntuples(res)); self->nfields = Py_BuildValue("i", PQnfields(res)); --- 120,123 ---- *************** *** 733,737 **** { "resultType", T_OBJECT, RsOFF(type), RO }, { "resultStatus", T_OBJECT, RsOFF(status), RO }, - { "resultErrorMessage", T_OBJECT, RsOFF(errmsg), RO }, { "ntuples", T_OBJECT, RsOFF(ntuples), RO }, { "nfields", T_OBJECT, RsOFF(nfields), RO }, --- 730,733 ---- |
From: Billy G. A. <bal...@us...> - 2001-09-23 03:58:52
|
Update of /cvsroot/pypgsql/pypgsql In directory usw-pr-cvs1:/tmp/cvs-serv17400 Modified Files: pgconnection.c Log Message: 22SEP2001 bga Fixed bugs uncovered during development of the regression test cases for pgconnection.c. --- Improved the error checking on the mode parameter in lo_creat(). --- Removed lo_get(). It doesn't provide any useful functionality since you never get a Large Object OID from PgResult.getvalue(). You always get a PgLargeObject. Index: pgconnection.c =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pgconnection.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** pgconnection.c 2001/09/21 03:46:31 1.7 --- pgconnection.c 2001/09/23 03:58:47 1.8 *************** *** 29,32 **** --- 29,39 ---- | Date Ini Description | | --------- --- ------------------------------------------------------- | + | 22SEP2001 bga Fixed bugs uncovered during testing with the new test | + | cases for regression testing. | + | --- 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 | *************** *** 306,315 **** int rtype; - if (!PyArg_ParseTuple(args,"s:query", &query)) - return NULL; - if (!PgConnection_check((PyObject *)self)) return NULL; (void)pgFixEsc(query); --- 313,322 ---- int rtype; if (!PgConnection_check((PyObject *)self)) return NULL; + if (!PyArg_ParseTuple(args,"s:query", &query)) + return NULL; + (void)pgFixEsc(query); *************** *** 362,371 **** int onOff; - if (!PyArg_ParseTuple(args, "i:setnonblocking", &onOff)) - return NULL; - if (!PgConnection_check((PyObject *)self)) return NULL; onOff = ((onOff != 0) ? 1 : 0); --- 369,378 ---- int onOff; if (!PgConnection_check((PyObject *)self)) return NULL; + if (!PyArg_ParseTuple(args, "i:setnonblocking", &onOff)) + return NULL; + onOff = ((onOff != 0) ? 1 : 0); *************** *** 391,400 **** char *query; - if (!PyArg_ParseTuple(args,"s:sendQuery", &query)) - return NULL; - if (!PgConnection_check((PyObject *)self)) return NULL; if (!PQsendQuery(PgConnection_Get(self), query)) { --- 398,407 ---- char *query; if (!PgConnection_check((PyObject *)self)) return NULL; + if (!PyArg_ParseTuple(args,"s:sendQuery", &query)) + return NULL; + if (!PQsendQuery(PgConnection_Get(self), query)) { *************** *** 420,423 **** --- 427,433 ---- int rtype; + if (!PgConnection_check((PyObject *)self)) + return (PyObject *)NULL; + if (!PyArg_ParseTuple(args,"")) { *************** *** 427,433 **** } - if (!PgConnection_check((PyObject *)self)) - return (PyObject *)NULL; - res = PQgetResult(PgConnection_Get(self)); --- 437,440 ---- *************** *** 464,467 **** --- 471,477 ---- static PyObject *libPQconsumeInput(PgConnection *self, PyObject *args) { + if (!PgConnection_check((PyObject *)self)) + return NULL; + if (!PyArg_ParseTuple(args, "")) { *************** *** 471,477 **** } - if (!PgConnection_check((PyObject *)self)) - return NULL; - if (!PQconsumeInput(PgConnection_Get(self))) { --- 481,484 ---- *************** *** 492,495 **** --- 499,505 ---- static PyObject *libPQflush(PgConnection *self, PyObject *args) { + if (!PgConnection_check((PyObject *)self)) + return NULL; + if (!PyArg_ParseTuple(args, "")) { *************** *** 499,505 **** } - if (!PgConnection_check((PyObject *)self)) - return NULL; - if (!PQflush(PgConnection_Get(self))) { --- 509,512 ---- *************** *** 521,534 **** static PyObject *libPQconnectPoll(PgConnection *self, PyObject *args) { if (!PyArg_ParseTuple(args,"")) { PyErr_SetString(PqErr_InterfaceError, ! "getResult() takes no parameters"); return NULL; } - if (!PgConnection_check((PyObject *)self)) - return NULL; - return Py_BuildValue("i", PQconnectPoll(PgConnection_Get(self))); } --- 528,541 ---- static PyObject *libPQconnectPoll(PgConnection *self, PyObject *args) { + if (!PgConnection_check((PyObject *)self)) + return NULL; + if (!PyArg_ParseTuple(args,"")) { PyErr_SetString(PqErr_InterfaceError, ! "connectPoll() takes no parameters"); return NULL; } return Py_BuildValue("i", PQconnectPoll(PgConnection_Get(self))); } *************** *** 544,547 **** --- 551,557 ---- static PyObject *libPQrequestCancel(PgConnection *self, PyObject *args) { + if (!PgConnection_check((PyObject *)self)) + return NULL; + if (!PyArg_ParseTuple(args, "")) { *************** *** 551,557 **** } - if (!PgConnection_check((PyObject *)self)) - return NULL; - if (!PQrequestCancel(PgConnection_Get(self))) { --- 561,564 ---- *************** *** 574,577 **** --- 581,587 ---- static PyObject * libPQfinish(PgConnection *self, PyObject *args) { + if (!PgConnection_check((PyObject *)self)) + return NULL; + if (!PyArg_ParseTuple(args,"")) { *************** *** 581,587 **** } - if (!PgConnection_check((PyObject *)self)) - return NULL; - PQfinish(PgConnection_Get(self)); --- 591,594 ---- *************** *** 602,605 **** --- 609,615 ---- static PyObject *libPQreset(PgConnection *self, PyObject *args) { + if (!PgConnection_check((PyObject *)self)) + return NULL; + if (!PyArg_ParseTuple(args,"")) { *************** *** 609,615 **** } - if (!PgConnection_check((PyObject *)self)) - return NULL; - Py_BEGIN_ALLOW_THREADS PQreset(PgConnection_Get(self)); --- 619,622 ---- *************** *** 637,640 **** --- 644,650 ---- static PyObject *libPQnotifies(PgConnection *self, PyObject *args) { + if (!PgConnection_check((PyObject *)self)) + return (PyObject *)NULL; + if (!PyArg_ParseTuple(args,"")) { *************** *** 644,650 **** } - if (!PgConnection_check((PyObject *)self)) - return (PyObject *)NULL; - return PgNotify_New(PQnotifies(PgConnection_Get(self))); } --- 654,657 ---- *************** *** 662,666 **** PyObject *result; ! PGconn *cnx = PgConnection_Get(self); if (!PyArg_ParseTuple(args,"")) --- 669,674 ---- PyObject *result; ! if (!PgConnection_check((PyObject *)self)) ! return NULL; if (!PyArg_ParseTuple(args,"")) *************** *** 671,676 **** } ! if (!PgConnection_check((PyObject *)self)) ! return NULL; for (size = idx = 0, res = 1; res > 0; idx = (size - 1)) --- 679,683 ---- } ! PGconn *cnx = PgConnection_Get(self); for (size = idx = 0, res = 1; res > 0; idx = (size - 1)) *************** *** 716,720 **** PyObject *result = (PyObject *)NULL; ! PGconn *cnx = PgConnection_Get(self); if (!PyArg_ParseTuple(args,"")) --- 723,728 ---- PyObject *result = (PyObject *)NULL; ! if (!PgConnection_check((PyObject *)self)) ! return NULL; if (!PyArg_ParseTuple(args,"")) *************** *** 725,730 **** } ! if (!PgConnection_check((PyObject *)self)) ! return NULL; for (size = idx = leave = 0; leave; idx = size) --- 733,737 ---- } ! PGconn *cnx = PgConnection_Get(self); for (size = idx = leave = 0; leave; idx = size) *************** *** 785,794 **** int res; - if (!PyArg_ParseTuple(args,"s:putline", &line)) - return NULL; - if (!PgConnection_check((PyObject *)self)) return NULL; Pg_BEGIN_ALLOW_THREADS(PgConnection_Get(self)) res = PQputline(PgConnection_Get(self), line); --- 792,801 ---- int res; if (!PgConnection_check((PyObject *)self)) return NULL; + if (!PyArg_ParseTuple(args,"s:putline", &line)) + return NULL; + Pg_BEGIN_ALLOW_THREADS(PgConnection_Get(self)) res = PQputline(PgConnection_Get(self), line); *************** *** 815,818 **** --- 822,828 ---- int res; + if (!PgConnection_check((PyObject *)self)) + return NULL; + if (!PyArg_ParseTuple(args,"")) { *************** *** 822,828 **** } - if (!PgConnection_check((PyObject *)self)) - return NULL; - Pg_BEGIN_ALLOW_THREADS(PgConnection_Get(self)) res = PQendcopy(PgConnection_Get(self)); --- 832,835 ---- *************** *** 850,858 **** PyObject *out; - if (!PyArg_ParseTuple(args,"O!:trace", &PyFile_Type, &out)) - return NULL; - if (!PgConnection_check((PyObject *)self)) return NULL; PQtrace(PgConnection_Get(self), PyFile_AsFile(out)); --- 857,865 ---- PyObject *out; if (!PgConnection_check((PyObject *)self)) return NULL; + + if (!PyArg_ParseTuple(args,"O!:trace", &PyFile_Type, &out)) + return NULL; PQtrace(PgConnection_Get(self), PyFile_AsFile(out)); *************** *** 869,872 **** --- 876,882 ---- static PyObject *libPQuntrace(PgConnection *self, PyObject *args) { + if (!PgConnection_check((PyObject *)self)) + return NULL; + if (!PyArg_ParseTuple(args,"")) { *************** *** 876,882 **** } - if (!PgConnection_check((PyObject *)self)) - return NULL; - PQuntrace(PgConnection_Get(self)); --- 886,889 ---- *************** *** 887,890 **** --- 894,907 ---- /*--------------------------------------------------------------------------*/ + /* The following define is only used internally, to track if the 'b' + * flag in the mode is seen. + */ + #define INV_BIN 0x00010000 + + extern struct { + char *name; + int mode; + } validmodes[]; + static char PgLo_creat_Doc[] = "lo_creat(mode) -- Creates a PgLargeObject with the attribues given in " *************** *** 894,929 **** { Oid oid; ! int mode; /* mode */ ! ! if (!PyArg_ParseTuple(args,"i:lo_creat", &mode)) ! return (PyObject *)NULL; if (!PgConnection_check((PyObject *)self)) return (PyObject *)NULL; ! if (!(oid = lo_creat(PgConnection_Get(self), mode))) { ! PyErr_SetString(PqErr_OperationalError, "Can't create large object."); ! return (PyObject *)NULL; } - - return PgLargeObject_New((PyObject *)self, oid); - } ! /*--------------------------------------------------------------------------*/ ! static char PgLo_get_Doc[] = ! "lo_get(oid, mode) -- Creates a PgLargeObject instance for oid and mode."; ! static PyObject *PgLo_get(PgConnection *self, PyObject *args) ! { ! Oid oid; /* Large Object OID */ ! if (!PyArg_ParseTuple(args,"i:lo_get", &oid)) ! return (PyObject *)NULL; ! if (!PgConnection_check((PyObject *)self)) return (PyObject *)NULL; ! return PgLargeObject_New((PyObject *)self, oid); } --- 911,965 ---- { Oid oid; ! int i; ! int mode; /* mode */ ! char *mname; /* mode (as string) */ if (!PgConnection_check((PyObject *)self)) return (PyObject *)NULL; ! mname = (char *)NULL; ! mode = 0; ! ! if (!PyArg_ParseTuple(args,"s:lo_creat", &mname)) { ! PyErr_Clear(); ! if (!PyArg_ParseTuple(args, "i:lo_creat", &mode)) ! return (PyObject *)NULL; } ! if (mname != (char *)NULL) ! for (i = 0; validmodes[i].name != (char *)NULL; i++) ! if (strcmp(mname, validmodes[i].name) == 0) ! { ! mode = validmodes[i].mode; ! break; ! } ! /* This loop will look up the text version of mode, if passed in as an ! * integer, or normalize the text version of mode if passed in as a ! * string. ! */ ! for (i = 0; validmodes[i].name != (char *)NULL; i++) ! if (mode == validmodes[i].mode) ! { ! mname = validmodes[i].name; ! break; ! } ! if (validmodes[i].name == (char *)NULL) ! { ! PyErr_SetString(PyExc_ValueError, "invalid mode for lo_creat()"); ! return (PyObject *)NULL; ! } ! // Make sure that INV_BIN is not set. ! mode &= (INV_READ | INV_WRITE); ! if (!(oid = lo_creat(PgConnection_Get(self), mode))) ! { ! PyErr_SetString(PqErr_OperationalError, "Can't create large object."); return (PyObject *)NULL; ! } ! return PgLargeObject_New((PyObject *)self, oid); } *************** *** 936,947 **** static PyObject *PgLo_import(PgConnection *self, PyObject *args) { Oid oid; ! char *filename; if (!PyArg_ParseTuple(args,"s:lo_import", &filename)) return (PyObject *)NULL; - if (PgConnection_check((PyObject *)self)) - return (PyObject *)NULL; - if (!(oid = lo_import(PgConnection_Get(self), filename))) { --- 972,983 ---- static PyObject *PgLo_import(PgConnection *self, PyObject *args) { Oid oid; ! char *filename = (char *)NULL; ! ! if (!PgConnection_check((PyObject *)self)) ! return (PyObject *)NULL; if (!PyArg_ParseTuple(args,"s:lo_import", &filename)) return (PyObject *)NULL; if (!(oid = lo_import(PgConnection_Get(self), filename))) { *************** *** 962,971 **** Oid oid; if (!PyArg_ParseTuple(args,"i:lo_unlink", &oid)) return (PyObject *)NULL; - if (PgConnection_check((PyObject *)self)) - return (PyObject *)NULL; - if (lo_unlink(PgConnection_Get(self), oid)) { --- 998,1007 ---- Oid oid; + if (!PgConnection_check((PyObject *)self)) + return (PyObject *)NULL; + if (!PyArg_ParseTuple(args,"i:lo_unlink", &oid)) return (PyObject *)NULL; if (lo_unlink(PgConnection_Get(self), oid)) { *************** *** 988,992 **** {"getlineAsync", (PyCFunction)libPQgetlineAsync, 1, libPQgetlineAsync_Doc}, {"lo_creat", (PyCFunction)PgLo_creat, 1, PgLo_creat_Doc}, - {"lo_get", (PyCFunction)PgLo_get, 1, PgLo_get_Doc}, {"lo_import", (PyCFunction)PgLo_import, 1, PgLo_import_Doc}, {"lo_unlink", (PyCFunction)PgLo_unlink, 1, PgLo_unlink_Doc}, --- 1024,1027 ---- |
From: Billy G. A. <bal...@us...> - 2001-09-21 03:46:35
|
Update of /cvsroot/pypgsql/pypgsql In directory usw-pr-cvs1:/tmp/cvs-serv2306 Modified Files: pgconnection.c Log Message: 20SEP2001 bga Fixed a bug I introduced into pgFixEsc. Index: pgconnection.c =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pgconnection.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** pgconnection.c 2001/09/21 03:00:24 1.6 --- pgconnection.c 2001/09/21 03:46:31 1.7 *************** *** 35,38 **** --- 35,39 ---- | 127, then the escape sequence is replaced by the actual | | character. This should fix the reported problem. | + | --- Fixed a bug I introduced into pgFixEsc. | | 19SEP2001 bga Re-ordered the items in PgConnection_members so that | | the attributes handled directly by PgConnection_getattr | *************** *** 110,139 **** if (*p == 'x' || *p == 'X') { ! p++; ! xbuf[0] = *p++; ! xbuf[1] = *p++; v = strtol(xbuf, &e, 16); if (e == (xbuf + 2)) { ! s[2] = (v & 7) + '0'; v >>= 3; ! s[1] = (v & 7) + '0'; v >>= 3; ! s[0] = (v & 7) + '0'; } - s += 3; } else if (isdigit(*p)) { ! obuf[0] = *p++; ! obuf[1] = *p++; ! obuf[2] = *p++; v = strtol(obuf, &e, 8); ! if ((e == (obuf + 3)) && (v > 127)) { s[-1] = (char)v; } - else - s += 3; } } --- 111,138 ---- if (*p == 'x' || *p == 'X') { ! *s++ = *p++; ! xbuf[0] = *s++ = *p++; ! xbuf[1] = *s++ = *p++; v = strtol(xbuf, &e, 16); if (e == (xbuf + 2)) { ! s[-1] = (v & 7) + '0'; v >>= 3; ! s[-2] = (v & 7) + '0'; v >>= 3; ! s[-3] = (v & 7) + '0'; } } else if (isdigit(*p)) { ! obuf[0] = *s++ = *p++; ! obuf[1] = *s++ = *p++; ! obuf[2] = *s++ = *p++; v = strtol(obuf, &e, 8); ! if ((e == &obuf[3]) && (v > 127)) { + s -= 3; s[-1] = (char)v; } } } |
From: Billy G. A. <bal...@us...> - 2001-09-21 03:00:27
|
Update of /cvsroot/pypgsql/pypgsql In directory usw-pr-cvs1:/tmp/cvs-serv27936 Modified Files: pgconnection.c Log Message: 20SEP2001 bga [Bug #455514] Modified pgFixEsc to that if will also handle octal escape sequences. If the escape sequence comes in as octal, then a character encoding such as Latin-2 is in use. If the value of the character is > 127, then the escape se- quence is replaced by the actual character. This should fix the reported problem. Index: pgconnection.c =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pgconnection.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** pgconnection.c 2001/09/19 03:47:56 1.5 --- pgconnection.c 2001/09/21 03:00:24 1.6 *************** *** 29,32 **** --- 29,38 ---- | Date Ini Description | | --------- --- ------------------------------------------------------- | + | 20SEP2001 bga [Bug #455514] Modified pgFixEsc to that if will also | + | handle octal escape sequences. If the escape sequence | + | comes in as octal, then a character encoding such as | + | Latin-2 is in use. If the value of the character is > | + | 127, then the escape sequence is replaced by the actual | + | character. This should fix the reported problem. | | 19SEP2001 bga Re-ordered the items in PgConnection_members so that | | the attributes handled directly by PgConnection_getattr | *************** *** 83,90 **** | seqences in the form '\xNN', PostgreSQL wants them as '\OOO'. | |-----------------------------------------------------------------------| ! | Note: If the value of the escaped charact > 127, then the actual | ! | character is placed in the string. This provides a work-around | ! | for an apparent problem in PostgreSQL. See bug #455514 for de- | ! | tails. | \***********************************************************************/ --- 89,97 ---- | seqences in the form '\xNN', PostgreSQL wants them as '\OOO'. | |-----------------------------------------------------------------------| ! | Note: If the value of the escaped character comes in as octal, then a | ! | character encoding such as Latin-2 is in use. If the value of | ! | the character is > 127, then the escape sequence is replaced by | ! | the actual character. This provides a work-around for an ap- | ! | parent problem in PostgreSQL. See bug #455514 for details. | \***********************************************************************/ *************** *** 93,97 **** char *p, *s, *e; int v; ! char ibuf[3] = "00"; s = p = src; --- 100,105 ---- char *p, *s, *e; int v; ! char obuf[4] = "000"; ! char *xbuf = &obuf[1]; s = p = src; *************** *** 102,124 **** if (*p == 'x' || *p == 'X') { ! if (isxdigit(*(p+1)) && isxdigit(*(p+2))) { ! p++; ! ibuf[0] = *p++; ! ibuf[1] = *p++; ! if ((v = strtol(ibuf, NULL, 16)) < 128) ! { ! s[2] = (v & 7) + '0'; ! v >>= 3; ! s[1] = (v & 7) + '0'; ! v >>= 3; ! s[0] = (v & 7) + '0'; ! s += 3; ! } ! else ! { ! s[-1] = v; ! } } } } --- 110,139 ---- if (*p == 'x' || *p == 'X') { ! p++; ! xbuf[0] = *p++; ! xbuf[1] = *p++; ! v = strtol(xbuf, &e, 16); ! if (e == (xbuf + 2)) { ! s[2] = (v & 7) + '0'; ! v >>= 3; ! s[1] = (v & 7) + '0'; ! v >>= 3; ! s[0] = (v & 7) + '0'; } + s += 3; + } + else if (isdigit(*p)) + { + obuf[0] = *p++; + obuf[1] = *p++; + obuf[2] = *p++; + v = strtol(obuf, &e, 8); + if ((e == (obuf + 3)) && (v > 127)) + { + s[-1] = (char)v; + } + else + s += 3; } } |
From: Gerhard H?r. <gha...@us...> - 2001-09-20 04:19:48
|
Update of /cvsroot/pypgsql/pypgsql/examples In directory usw-pr-cvs1:/tmp/cvs-serv15077 Modified Files: demo2a.py Log Message: 20SEP2001 gh Changed demo2a to use select.select instead of select.poll. This is to make the example work on platforms that don't support the poll function. Index: demo2a.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/examples/demo2a.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** demo2a.py 2001/08/24 22:26:00 1.2 --- demo2a.py 2001/09/20 04:19:38 1.3 *************** *** 49,61 **** # to res, the previous result is cleaned up automagically. ! pobj = select.poll() ! pobj.register(cnx.socket, select.POLLIN) sys.stdout.write('Waiting.') while 1: ! # Wait a little (using poll()) sys.stdout.flush() ! pres = pobj.poll(1000) ! if len(pres) == 0: sys.stdout.write('.') else: --- 49,62 ---- # to res, the previous result is cleaned up automagically. ! # To make this also work on Windows, we use select.select() instead of the much ! # nicer select.poll() ! sys.stdout.write('Waiting.') while 1: ! # Wait a little (using select()) sys.stdout.flush() ! ready_sockets = select.select([cnx.socket], [], [], 1.0)[0] ! if len(ready_sockets) == 0: sys.stdout.write('.') else: |
From: Billy G. A. <bal...@us...> - 2001-09-20 03:52:35
|
Update of /cvsroot/pypgsql/pypgsql In directory usw-pr-cvs1:/tmp/cvs-serv11404 Modified Files: Announce ChangeLog MANIFEST README setup.py Log Message: 19SEP2001 bga Modified these files to get ready for Release 1.6. Index: Announce =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/Announce,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Announce 2001/08/30 01:57:29 1.10 --- Announce 2001/09/20 03:52:32 1.11 *************** *** 1,9 **** ! Announce: pyPgSQL - Version 1.5 is released. =========================================================================== ! pyPgSQL v1.5.1 has been released. It is a bug fix release to version 1.5. ! It corrects problems with the PgLargeObject.read() method and improves the ! stability of pyPgSQL in the MS Windows environment. It is available at http://sourceforge.net/projects/pypgsql. --- 1,11 ---- ! Announce: pyPgSQL - Version 1.6 is released. =========================================================================== + pyPgSQL v1.6 has been released. It is primarily a bug fix release to ver- + sion 1.5.1, but also include some enhancements. ! NOTE: This release drops support for PostgreSQL 6.5.x and Python 1.5.x. ! If you are still using those versions, you are badly in need of an ! upgrade. It is available at http://sourceforge.net/projects/pypgsql. *************** *** 16,20 **** support for various PostgreSQL data types, such as INT8, NUMERIC, MONEY, BOOL, ARRAYS, etc. This module is written in Python and works with ! PostgreSQL 6.5.2 or later and Python 2.0 or later. Note: It is highly recommended that you use PostgreSQL 7.1 or later and --- 18,22 ---- support for various PostgreSQL data types, such as INT8, NUMERIC, MONEY, BOOL, ARRAYS, etc. This module is written in Python and works with ! PostgreSQL 7.0 or later and Python 2.0 or later. Note: It is highly recommended that you use PostgreSQL 7.1 or later and *************** *** 23,40 **** PostgreSQL is a sophisticated Object-Relational DBMS, supporting almost all SQL constructs, including sub-selects, transactions, and user-defined types ! and functions. It is the most advanced open-source database available ! anywhere More information about PostgreSQL can be found at the PostgreSQL ! home page at http://www.postgresql.org. Python is an interpreted, interactive, object-oriented programming lang- ! uage. It combines remarkable power with very clear syntax. It has ! modules, classes, exceptions, very high level dynamic data types, and ! dynamic typing. There are interfaces to many system calls and libraries, ! as well as to various windowing systems (X11, Motif, Tk, Mac, MFC). New ! builtin modules are easily written in C or C++. Python is also usable as ! an extension language for applications that need a programmable interface. ! Python is copyrighted but freely usable and distributable, even for ! commercial use. More information about Python can be found on the Python ! home page at http://www.python.org. --------------------------------------------------------------------------- --- 25,42 ---- PostgreSQL is a sophisticated Object-Relational DBMS, supporting almost all SQL constructs, including sub-selects, transactions, and user-defined types ! and functions. It is the most advanced open-source database available any- ! where More information about PostgreSQL can be found at the PostgreSQL home ! page at http://www.postgresql.org. Python is an interpreted, interactive, object-oriented programming lang- ! uage. It combines remarkable power with very clear syntax. It has mod- ! ules, classes, exceptions, very high level dynamic data types, and dynamic ! typing. There are interfaces to many system calls and libraries, as well ! as to various windowing systems (X11, Motif, Tk, Mac, MFC). New builtin ! modules are easily written in C or C++. Python is also usable as an exten- ! sion language for applications that need a programmable interface. Python ! is copyrighted but freely usable and distributable, even for commercial ! use. More information about Python can be found on the Python home page at ! http://www.python.org. --------------------------------------------------------------------------- *************** *** 42,79 **** =========================================================================== ! Changes since pyPgSQL Version 1.5 ! ================================= ! Compiled the code with options to perform extra syntactic, symantic, and ! lint-like checks and corrected any problems that were found. Changes to pglargeobject.c -------------------------- ! * Why did I introduce a new variable (save) and execute another call to ! lo_tell() when it wasn't needed? (I have to stop working on code late ! at night. :-) ! * Fixed another bug in PgLo_read(). This one would only rear it's ugly ! head when read() was called with no arguments, and then, only sometimes. ! (I REALLY need to stop working on code late at night [or is that early ! in the morning] :-). Changes to pgnotify.c --------------------- ! * Changed calls to PyObject_DEL() to Py_XDECREF() when deleting objects ! embedded in my extension objects. This corrects a problem expirenced on ! MS Windows. Changes to pgresult.c --------------------- ! * Part of the logic for building the cursor.desccription attribute retrives ! an OID from the database that is usually zero (0). This causes a query to ! the database to check to see if the OID represents a large object. An OID ! of zero can never be a large object, so the code was changed so that when ! the OID is zero, the check to see if it is a large object is skipped. ! Changes to setup.py ! ------------------- ! * Add include_dirs and lib_dirs for building on cygwin. This change should ! allow pyPgSQL to build 'out of the box' on MS Windows using the cygwin ! environment. --- 44,202 ---- =========================================================================== ! Changes since pyPgSQL Version 1.5.1 ! =================================== ! The following regression test cases have been added. These tests are ! designed to rigorously test a specific part of pyPgSQL: ! ! pgresult.py - Test cases for the libpq.PgResult object. ! pgversion.py - Test cases for the libpq.PgVersion object. ! pgconnection.py - Test cases for the libpq.PgConnection object. ! ! Changes to PgSQL.py ! ------------------- ! * Cleaned up the logic in hadleArray(). + * Updated the PgSQL.__doc__ string. + + * [Feature Request #462588] Cursor.close() no longer ends (rollback) the + open transaction when the last cursor is closed. + + * On Connection.close(), reset all the attributes to a sane state (i.e. + None or 0, as appropriate). + + * [Bug #462589] In a fit of optimization, I had introduced a bug that + caused comparisons of PgResultSets to anything to fail. This bug has + been squashed. + + * Fixed several cases of references to non-existing globals in PgMoney. + + * Previously, I was not building up the description attribute if no rows + were returned. The description attribute is now built on the first + successful select or cursor fetch. + + Changes to libpqmodule.c + ------------------------ + * Removed code related to PostgreSQL 6.5.x. We now only support + PostgreSQL 7.0 and later. + + * Changed 'long long' to 'LONG_LONG'. That way there is no assumption of + how a 64bit integer is declared. + + Changes to pgboolean.c + ---------------------- + * Fix bug in PgBoolean_FromString; also improve and simplify the string + stripping in this method. + + Changes to pgconnection.c + ------------------------- + * Re-ordered the items in PgConnection_members so that the attributes + handled directly by PgConnection_getattr are grouped together and + commented appropriately. + + * Removed code related to PostgreSQL 6.5.x. We now only support + PostgreSQL 7.0 and later. + + * Modified pgFixEsc so that any escaped sequence (\xHH) whose value is + greater than 127 is replaced by the actual character. This works + around an apparent problem in PostgreSQL involving encodings. [Bug + #455514] + + * Use PyObject_Del() instead of PyMem_Free() in dealloc() to delete the + object. + + Changes to pgint2object.c + ------------------------- + * Use PyObject_Del() instead of PyMem_Free() in dealloc() to delete the + object. + + Changes to pgint8object.c + ------------------------- + * Modified code for 64bit (long long) support in the MS Windows + environment with MS Visual C++. + + * Made changes to avoid use of long long constants. This was done to + assist in the use of MS Visual C++, which uses something other than LL + to specify long long constants. (It's ugly, I know. Thanks MS.) + + * Use PyObject_Del() instead of PyMem_Free() in dealloc() to delete the + object. + Changes to pglargeobject.c -------------------------- ! * Removed an un-used variable. ! * Use PyObject_Del() instead of PyMem_Free() in dealloc() to delete the ! object. Changes to pgnotify.c --------------------- ! * Clarified an embedded assignment within an if test. + * Use PyObject_Del() instead of PyMem_Free() in dealloc() to delete the + object. + Changes to pgresult.c --------------------- ! * Removed code related to PostgreSQL 6.5.x. We now only support ! PostgreSQL 7.0 and later. ! * Fixed a gcc reported int format <-> long int argument mis-match. ! ! * Added check to make sure that the result was from a DQL (Data Query ! Language) statement in methods that only make sense for DQL statement ! results (fname(), etc.). ! ! * Methods that take field and/or tuple indices will now raise an ! exception if those indices are out of range. The previous behavior ! was to return the error code from the underlying PostgreSQL C-API ! function. ! ! * The fnumber() method will now raise an exception if it is passed a ! string that is not a valid column name. The previous behavior was to ! return the error code from the PostgreSQL C-API PQfnumber function. ! ! * Correct some incorrect comments. ! ! * Use PyObject_Del() instead of PyMem_Free() in dealloc() to delete the ! object. ! ! * Added a cache (implemented with a Python Dictionary) for OIDs to hold ! the result of the check to see if the OID is a large object. This ! should reduce the number queries sent to the database for this ! purpose. ! ! * Add code to not check OIDs whose value is less than or equal to 1700 ! (PG_NUMERIC). These OIDs are not large objects. ! ! Changes to pgversion.c ! ---------------------- ! * Removed variables that are no longer needed/referenced. ! ! * Fixed code so that coercion generates an exception if the other object ! could not be converted to a PgVersion object. ! ! * Fixed problem where a variable in PgVersion_New() could be used before ! it was initialized. ! ! * Improved detection of erroneous input strings. ! ! * Various minor bug fixes and code cleanup. ! ! * Made constructed version string more closely mimic the actual format of ! the PostgreSQL version string. ! ! * Having a __dict__ attribute and calling PyMember_Get() in the ! PyVersion_getattr function causes dir() to do strange things (like list ! members twice). I've removed the __dict__ attribute and added methods ! to emulate a mapping object to PgVersion. A PgVersion object will now ! act like a dictionary, so use version[key] instead of ! version.__dict__[key]. ! ! * Make PgVersion_New safe for arbitrary input strings. ! ! * Make the repr method really return the version string. ! ! * Initialize a variable (value) in ver_coerce() to quite an erroneous gcc ! warning message. ! Index: ChangeLog =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/ChangeLog,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** ChangeLog 2001/08/30 01:57:29 1.10 --- ChangeLog 2001/09/20 03:52:32 1.11 *************** *** 1,4 **** --- 1,161 ---- #ident "$Id$" + Changes since pyPgSQL Version 1.5.1 + =================================== + + The following regression test cases have been added. These tests are + designed to rigorously test a specific part of pyPgSQL: + + pgresult.py - Test cases for the libpq.PgResult object. + pgversion.py - Test cases for the libpq.PgVersion object. + pgconnection.py - Test cases for the libpq.PgConnection object. + + Changes to PgSQL.py + ------------------- + * Cleaned up the logic in hadleArray(). + + * Updated the PgSQL.__doc__ string. + + * [Feature Request #462588] Cursor.close() no longer ends (rollback) the + open transaction when the last cursor is closed. + + * On Connection.close(), reset all the attributes to a sane state (i.e. + None or 0, as appropriate). + + * [Bug #462589] In a fit of optimization, I had introduced a bug that + caused comparisons of PgResultSets to anything to fail. This bug has + been squashed. + + * Fixed several cases of references to non-existing globals in PgMoney. + + * Previously, I was not building up the description attribute if no rows + were returned. The description attribute is now built on the first + successful select or cursor fetch. + + Changes to libpqmodule.c + ------------------------ + * Removed code related to PostgreSQL 6.5.x. We now only support + PostgreSQL 7.0 and later. + + * Changed 'long long' to 'LONG_LONG'. That way there is no assumption of + how a 64bit integer is declared. + + Changes to pgboolean.c + ---------------------- + * Fix bug in PgBoolean_FromString; also improve and simplify the string + stripping in this method. + + Changes to pgconnection.c + ------------------------- + * Re-ordered the items in PgConnection_members so that the attributes + handled directly by PgConnection_getattr are grouped together and + commented appropriately. + + * Removed code related to PostgreSQL 6.5.x. We now only support + PostgreSQL 7.0 and later. + + * Modified pgFixEsc so that any escaped sequence (\xHH) whose value is + greater than 127 is replaced by the actual character. This works + around an apparent problem in PostgreSQL involving encodings. [Bug + #455514] + + * Use PyObject_Del() instead of PyMem_Free() in dealloc() to delete the + object. + + Changes to pgint2object.c + ------------------------- + * Use PyObject_Del() instead of PyMem_Free() in dealloc() to delete the + object. + + Changes to pgint8object.c + ------------------------- + * Modified code for 64bit (long long) support in the MS Windows + environment with MS Visual C++. + + * Made changes to avoid use of long long constants. This was done to + assist in the use of MS Visual C++, which uses something other than LL + to specify long long constants. (It's ugly, I know. Thanks MS.) + + * Use PyObject_Del() instead of PyMem_Free() in dealloc() to delete the + object. + + Changes to pglargeobject.c + -------------------------- + * Removed an un-used variable. + + * Use PyObject_Del() instead of PyMem_Free() in dealloc() to delete the + object. + + Changes to pgnotify.c + --------------------- + * Clarified an embedded assignment within an if test. + + * Use PyObject_Del() instead of PyMem_Free() in dealloc() to delete the + object. + + Changes to pgresult.c + --------------------- + * Removed code related to PostgreSQL 6.5.x. We now only support + PostgreSQL 7.0 and later. + + * Fixed a gcc reported int format <-> long int argument mis-match. + + * Added check to make sure that the result was from a DQL (Data Query + Language) statement in methods that only make sense for DQL statement + results (fname(), etc.). + + * Methods that take field and/or tuple indices will now raise an + exception if those indices are out of range. The previous behavior + was to return the error code from the underlying PostgreSQL C-API + function. + + * The fnumber() method will now raise an exception if it is passed a + string that is not a valid column name. The previous behavior was to + return the error code from the PostgreSQL C-API PQfnumber function. + + * Correct some incorrect comments. + + * Use PyObject_Del() instead of PyMem_Free() in dealloc() to delete the + object. + + * Added a cache (implemented with a Python Dictionary) for OIDs to hold + the result of the check to see if the OID is a large object. This + should reduce the number queries sent to the database for this + purpose. + + * Add code to not check OIDs whose value is less than or equal to 1700 + (PG_NUMERIC). These OIDs are not large objects. + + Changes to pgversion.c + ---------------------- + * Removed variables that are no longer needed/referenced. + + * Fixed code so that coercion generates an exception if the other object + could not be converted to a PgVersion object. + + * Fixed problem where a variable in PgVersion_New() could be used before + it was initialized. + + * Improved detection of erroneous input strings. + + * Various minor bug fixes and code cleanup. + + * Made constructed version string more closely mimic the actual format of + the PostgreSQL version string. + + * Having a __dict__ attribute and calling PyMember_Get() in the + PyVersion_getattr function causes dir() to do strange things (like list + members twice). I've removed the __dict__ attribute and added methods + to emulate a mapping object to PgVersion. A PgVersion object will now + act like a dictionary, so use version[key] instead of + version.__dict__[key]. + + * Make PgVersion_New safe for arbitrary input strings. + + * Make the repr method really return the version string. + + * Initialize a variable (value) in ver_coerce() to quite an erroneous gcc + warning message. + Changes since pyPgSQL Version 1.5 ================================= Index: MANIFEST =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/MANIFEST,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** MANIFEST 2001/08/24 22:26:00 1.5 --- MANIFEST 2001/09/20 03:52:32 1.6 *************** *** 30,33 **** --- 30,36 ---- examples/demo2b.py test/PgSQLTestCases.py + test/regression/pgresult.py + test/regression/pgversion.py + windows/llsupport.h windows/strtok.c windows/strtoll.c Index: README =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/README,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** README 2001/08/25 16:41:26 1.11 --- README 2001/09/20 03:52:32 1.12 *************** *** 6,10 **** =============================== ! pyPgSQL, version 1.5 A Python DB-API 2.0 compliant interface for PostgreSQL Copyright 2000 by Billy G. Allie. --- 6,10 ---- =============================== ! pyPgSQL, version 1.6 A Python DB-API 2.0 compliant interface for PostgreSQL Copyright 2000 by Billy G. Allie. *************** *** 33,64 **** ---------------- ! PostgreSQL is a sophisticated Object-Relational DBMS, supporting almost all ! SQL constructs, including sub-selects, transactions, and user-defined types ! and functions. It is the most advanced open-source database available ! anywhere More information about PostgreSQL can be found at the PostgreSQL ! home page at http://www.postgresql.org. ! Python is an interpreted, interactive, object-oriented programming lang- ! uage. It combines remarkable power with very clear syntax. It has ! modules, classes, exceptions, very high level dynamic data types, and ! dynamic typing. There are interfaces to many system calls and libraries, ! as well as to various windowing systems (X11, Motif, Tk, Mac, MFC). New ! builtin modules are easily written in C or C++. Python is also usable as ! an extension language for applications that need a programmable interface. ! Python is copyrighted but freely usable and distributable, even for ! commercial use. More information about Python can be found on the Python ! home page at http://www.python.org. pyPgSQL is a package of two (2) modules that provide a Python DB-API 2.0 ! compliant interface to PostgreSQL databases. The first module, libpq, ! exports the PostgreSQL C API to Python. This module is written in C and ! can be compiled into Python or can be dynamically loaded on demand. The ! second module, PgSQL, provides the DB-API 2.0 compliant interface and ! support for various PostgreSQL data types, such as INT8, NUMERIC, MONEY, ! BOOL, ARRAYS, etc. This module is written in Python. This version works ! with PostgreSQL 6.5.2 or later and Python 2.0 or later. ! pyPgSQL was developed on a UnixWare 7.1.1 system and tested on both ! UnixWare and RedHat Linux. 1.2 Distribution Files --- 33,63 ---- ---------------- ! PostgreSQL is a sophisticated Object-Relational DBMS, supporting almost all SQL ! constructs, including sub-selects, transactions, and user-defined types and ! functions. It is the most advanced open-source database available anywhere More ! information about PostgreSQL can be found at the PostgreSQL home page at ! http://www.postgresql.org. ! Python is an interpreted, interactive, object-oriented programming language. ! It combines remarkable power with very clear syntax. It has modules, classes, ! exceptions, very high level dynamic data types, and dynamic typing. There are ! interfaces to many system calls and libraries, as well as to various windowing ! systems (X11, Motif, Tk, Mac, MFC). New builtin modules are easily written in ! C or C++. Python is also usable as an extension language for applications that ! need a programmable interface. Python is copyrighted but freely usable and ! distributable, even for commercial use. More information about Python can be ! found on the Python home page at http://www.python.org. pyPgSQL is a package of two (2) modules that provide a Python DB-API 2.0 ! compliant interface to PostgreSQL databases. The first module, libpq, exports ! the PostgreSQL C API to Python. This module is written in C and can be com- ! piled into Python or can be dynamically loaded on demand. The second module, ! PgSQL, provides the DB-API 2.0 compliant interface and support for various ! PostgreSQL data types, such as INT8, NUMERIC, MONEY, BOOL, ARRAYS, etc. This ! module is written in Python. This version works with PostgreSQL 6.5.2 or later ! and Python 2.0 or later. ! pyPgSQL was developed on a UnixWare 7.1.1 system and tested on both UnixWare ! and RedHat Linux. 1.2 Distribution Files *************** *** 96,99 **** --- 95,99 ---- test/PgSQLTestCases.py - A set of functional test cases built using the Python Unit Testing Framework (pyunit) + test/regression/* - Test cases to test specific object in pyPgSQL. examples/demo1a.py - Some example programs using libpq and PgSQL examples/demo1b.py *************** *** 105,117 **** ---------------- ! These instructions assume you have Python 1.6 (or later) and PostgreSQL ! 7.0 (7.1.x recommended) installed on your system. If you are going to use ! the DB-API 2.0 compliant module, you must also install the mxDateTime module ! from http://starship.python.net/~lemburg/mxDateTime.html. a. Download pyPgSQL files if you haven't already done so. ! b. Edit the setup.py file to reflect the your environment. The setup.py ! file contains comments to guide you in customizing this file. c. Execute "python setup.py build" to build the extension module. --- 105,117 ---- ---------------- ! These instructions assume you have Python 2.0 (or later) and PostgreSQL 7.0 ! (7.1.x recommended) installed on your system. If you are going to use the ! DB-API 2.0 compliant module, you must also install the mxDateTime module from ! http://starship.python.net/~lemburg/mxDateTime.html. a. Download pyPgSQL files if you haven't already done so. ! b. Edit the setup.py file to reflect the your environment. The setup.py file ! contains comments to guide you in customizing this file. c. Execute "python setup.py build" to build the extension module. *************** *** 121,128 **** local system administrator. ! Note: To build pyPgSQL to work with PostgreSQL 6.5.x (I highly recommend ! that you upgrade your PostgreSQL to the latest version) you must ! arrange for the macro 'PGSQL_6X' to be defined when you compile the ! C code. 1.3.1 Platform specific notes --- 121,127 ---- local system administrator. ! Note: To build pyPgSQL to work with PostgreSQL 6.5.x (I highly recommend that ! you upgrade your PostgreSQL to the latest version) you must arrange for ! the macro 'PGSQL_6X' to be defined when you compile the C code. 1.3.1 Platform specific notes *************** *** 131,152 **** Windows: (Thanks to Gerhard Haering <ge...@bi...> for this information) ! To compile the C sources, you'll need a compiler that supports the ! "long long" type. Microsoft Visual C++ doesn't work for this reason. ! The GNU compilers are known to work. ! "python setup.py --compiler=mingw32" will build with the native win32 ! mode of the GNU compiler. ! Current versions of the GNU tools on Windows don't include the ! functions strtoll, strtoull and strtok_r. You'll need these to compile ! successfully. strtok.c and modified (to compile under the cygwin) ! versions of strtoll.c and strtoull.c from the FreeBSD CVS have been ! added to the pyPgSQL source tree. You can download the original files ! from the following URL: http://www.freebsd.org/cgi/cvsweb.cgi/src/lib/libc/stdlib/ ! To successfully compile on Windows, you'll need a fairly recent ! PostgreSQL version: version 7.1.2 plus the update for the file src/interfaces/libpq/libpqdll.def from CVS. --- 130,150 ---- Windows: (Thanks to Gerhard Haering <ge...@bi...> for this information) ! To compile the C sources, you'll need a compiler that supports the "long ! long" type. Microsoft Visual C++ doesn't work for this reason. The GNU ! compilers are known to work. ! "python setup.py --compiler=mingw32" will build with the native win32 mode ! of the GNU compiler. ! Current versions of the GNU tools on Windows don't include the functions ! strtoll, strtoull and strtok_r. You'll need these to compile successfully. ! strtok.c and modified (to compile under the cygwin) versions of strtoll.c ! and strtoull.c from the FreeBSD CVS have been added to the pyPgSQL source ! tree. You can download the original files from the following URL: http://www.freebsd.org/cgi/cvsweb.cgi/src/lib/libc/stdlib/ ! To successfully compile on Windows, you'll need a fairly recent PostgreSQL ! version: version 7.1.2 plus the update for the file src/interfaces/libpq/libpqdll.def from CVS. *************** *** 165,176 **** If the test cases run without any failures, then you can be reasonably sure ! that the module built correctly. Please note that the current test cases ! are not complete, but this will change over time. ! If you do not wish to install pgunit, run the demo1a.py and demo1b.py ! programs in the examples directory. Both demo1a.py and demo1b.py print the ! contents of the pg_database table from the template1 database. Demo1a.py ! was written to use the libpq module, while demo1b.py was written to use the ! PgSQL module. 1.5 Addition information about ... --- 163,173 ---- If the test cases run without any failures, then you can be reasonably sure ! that the module built correctly. Please note that the current test cases are ! not complete, but this will change over time. ! If you do not wish to install pgunit, run the demo1a.py and demo1b.py programs ! in the examples directory. Both demo1a.py and demo1b.py print the contents of ! the pg_database table from the template1 database. Demo1a.py was written to ! use the libpq module, while demo1b.py was written to use the PgSQL module. 1.5 Addition information about ... *************** *** 196,204 **** PgResults - handles the query results. PgLargeObject - handles the access to PostgreSQL large objects. ! PgNotify - the notify class. It contains information about a no- ! tification event sent from a PostgreSQL backend process. ! PgVersion - the version class. It contains information about the ! version of the PostgreSQL backend that a connection object ! is connected to. The module makes error information available via the following exception --- 193,201 ---- PgResults - handles the query results. PgLargeObject - handles the access to PostgreSQL large objects. ! PgNotify - the notify class. It contains information about a notifi- ! cation event sent from a PostgreSQL backend process. ! PgVersion - the version class. It contains information about the ver- ! sion of the PostgreSQL backend that a connection object is ! connected to. The module makes error information available via the following exception *************** *** 208,213 **** IntegrityError, InternalError, ProgrammingError, NotSupportedError ! Additional information about these exceptions can be found in the Python ! DB-API 2.0 documentation. The following methods are defined by libpq: --- 205,210 ---- IntegrityError, InternalError, ProgrammingError, NotSupportedError ! Additional information about these exceptions can be found in the Python DB-API ! 2.0 documentation. The following methods are defined by libpq: *************** *** 226,234 **** PgInt8 - creates a PgInt8 object from a string or number. ! There are a number of constants defined in libpq. They are intended to be ! used as parameters for method calls and to compare against certain results ! generated by method calls. You should refer to the libpq section of the ! PostgreSQL programmer's manual for information about them. These constants ! are: Connection related constants: --- 223,230 ---- PgInt8 - creates a PgInt8 object from a string or number. ! There are a number of constants defined in libpq. They are intended to be used ! as parameters for method calls and to compare against certain results generated ! by method calls. You should refer to the libpq section of the PostgreSQL pro- ! grammer's manual for information about them. These constants are: Connection related constants: *************** *** 815,818 **** --- 811,815 ---- tuple data, 0 if it contains ASCII data. It returns the output of the PQbinaryTuples function call. + Note: Binary portals are not supported at this time. cmdStatus - The command status string from the SQL command that generated the PGresult. It returns the output to the *************** *** 821,826 **** returns the output of the PQcmdTuples function. oidValue - The object id of the tuple inserted, if the SQL com- ! (7.x and above) mand was an INSERT. Otherwise, contains InvalidOid. ! It returns the output of the PQoidValue function. The PgResult Object has the following methods: --- 818,823 ---- returns the output of the PQcmdTuples function. oidValue - The object id of the tuple inserted, if the SQL com- ! (7.x and above) mand was an INSERT. Otherwise, contains None. It ! returns the output of the PQoidValue function. The PgResult Object has the following methods: *************** *** 936,943 **** --------------- ---------------------- PG_BOOL PgBoolean ! PG_OID Integer or PgLargeObject PG_INT2 PgInt2 PG_INT4 Integer ! PG_INT8 PgInt8(1) or Long PG_MONEY Float PG_FLOAT4 Float --- 933,940 ---- --------------- ---------------------- PG_BOOL PgBoolean ! PG_OID Integer or PgLargeObject(1) PG_INT2 PgInt2 PG_INT4 Integer ! PG_INT8 PgInt8(2) or Long PG_MONEY Float PG_FLOAT4 Float *************** *** 945,949 **** All Other Types String ! (1) PgInt8 type is only available on system that have long long (64 bit integer) support. --- 942,949 ---- All Other Types String ! (1) getvalue() will determine if the OID represents a ! PostgreSQL Large Object and returns the appropiate ! object. ! (2) PgInt8 type is only available on system that have long long (64 bit integer) support. *************** *** 952,958 **** Exceptions: InterfaceError, TypeError - Note: getvalue will attempt to determine if a PG_OID type represents - a PgLargeObject, and return the appropriate object. - 2.3.7 getlength --------------- --- 952,955 ---- *************** *** 1012,1034 **** The PgLargeObject class provides methods for accessing the PostgreSQL Large Object (LO) system. It allows access to the LO using Python's File Object ! semantics. The PgLargeObject class defines the following private, read-only attributes: - conn - The PgConnection object associated with this PgLargeObject. - oid - The OID that identifies this large object to PostgreSQL. - fd - The file descriptor used to read/write to the LO. - dirty - Flag: 1 = data was written to the internal buffer. - offset - Offset in the LO where the internal buffer was read from. - buffer - Internal buffer used to support readline() calls. - size - Size (length) of the data in the internal buffer. - index - Index into internal buffer where the next byte is read/written. - - and the following public, read-only attributes: - mode - The mode used to open the LO name - A string, in the form of "<...>", indicating the source of the LO. closed - Flag: 1 = the LO is closed. - and the following public, read-write attribute: --- 1009,1019 ---- The PgLargeObject class provides methods for accessing the PostgreSQL Large Object (LO) system. It allows access to the LO using Python's File Object ! semantics. The PgLargeObject class defines the following public, read-only attributes: mode - The mode used to open the LO name - A string, in the form of "<...>", indicating the source of the LO. closed - Flag: 1 = the LO is closed. and the following public, read-write attribute: *************** *** 1116,1120 **** For example, for version 6.5.3, the contents of the PgVersion object would be: ! repr(connection.version) == "PostgreSQL 6.5.3 on <system dependant info>" connection.version.major == 6 connection.version.minor == 5 --- 1101,1105 ---- For example, for version 6.5.3, the contents of the PgVersion object would be: ! connection.version == "PostgreSQL 6.5.3 on <system dependant info>" connection.version.major == 6 connection.version.minor == 5 *************** *** 1124,1128 **** For example, for version 7.1.1, the contents of PgVer would be: ! repr(connection.version) == "PostgreSQL 7.1.1 on <system dependant info>" connection.version.major == 7 connection.version.minor == 1 --- 1109,1113 ---- For example, for version 7.1.1, the contents of PgVer would be: ! connection.version == "PostgreSQL 7.1.1 on <system dependant info>" connection.version.major == 7 connection.version.minor == 1 *************** *** 1147,1151 **** connection.version == "7.0.2" will be false. connection.version < "7.0.1" will be false. ! connection.version > "7.0.1" will be true. Note: Both the libpq and PgSQL connection objects have the version attribute. --- 1132,1136 ---- connection.version == "7.0.2" will be false. connection.version < "7.0.1" will be false. ! connection.version > "7.1" will be true. Note: Both the libpq and PgSQL connection objects have the version attribute. *************** *** 1154,1158 **** -------------------- ! The PgSQL module provide a Python DB=API 2.0 compliant module on top of the libpq module. As the DB-API 2.0 interface is documented elsewhere (http://www.python.org/topics/database/DatabaseAPI-2.0.html), I will only --- 1139,1143 ---- -------------------- ! The PgSQL module provide a Python DB-API 2.0 compliant module on top of the libpq module. As the DB-API 2.0 interface is documented elsewhere (http://www.python.org/topics/database/DatabaseAPI-2.0.html), I will only *************** *** 1263,1271 **** result set (or nothing). ! 3. When using the execute method, you should only use '%s' [or '%(name)s'] to ! specify locations where the parameters are to be subsituted, even for ! integers, floats and other non-string variables. The execute method will ! convert all the paramters to a string, applying any quoting that may be ! necessary before sending the query to the back-end. 4. The fetchone method will return a PgResultSet object instead of a sequence. --- 1248,1256 ---- result set (or nothing). ! 3. When using the execute method, you should only use '%s' [or '%(name)s'] ! (without the quote marks) to specify locations where the parameters are to ! be subsituted, even for integers, floats and other non-string variables. ! The execute method will convert all the paramters to a string, applying any ! quoting that may be necessary before sending the query to the back-end. 4. The fetchone method will return a PgResultSet object instead of a sequence. *************** *** 1282,1288 **** 6. A PostgreSQL specific attribute, named oidValue, was added to the cursor ! object. This attribute returns the value of the oidValue attribute of ! the PgResult object associated with the cursor object and provides a ! convenient way to get the object ID of a newly inserted record. 3.4 General Notes and Observations --- 1267,1273 ---- 6. A PostgreSQL specific attribute, named oidValue, was added to the cursor ! object. This attribute returns the value of the oidValue attribute of the ! PgResult object associated with the cursor object and provides a convenient ! way to get the object ID of a newly inserted record. 3.4 General Notes and Observations *************** *** 1292,1298 **** auto-commit mode unless a transaction is started. To achive the DB-API 2.0 mandated behaviour, when connection.autocommit is 0, a transaction is started ! when the first cursor is created for a connection. After a commit or ! rollback, a new transaction is created on the next call to execute(). - When the last opened cursor for a connection is closed, a rollback will occur - if there is still an open transaction (a commit or rollback wasn't issued).. --- 1277,1281 ---- auto-commit mode unless a transaction is started. To achive the DB-API 2.0 mandated behaviour, when connection.autocommit is 0, a transaction is started ! when the first cursor is created for a connection. After a commit or rollback, ! a new transaction is created on the next call to execute(). Index: setup.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/setup.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** setup.py 2001/09/04 02:28:24 1.10 --- setup.py 2001/09/20 03:52:32 1.11 *************** *** 69,73 **** from distutils.extension import Extension ! __version__ = "1.5.1" # Define the runtime library path for this module. It starts out as None. --- 69,73 ---- from distutils.extension import Extension ! __version__ = "1.6" # Define the runtime library path for this module. It starts out as None. |
From: Billy G. A. <bal...@us...> - 2001-09-20 03:51:16
|
Update of /cvsroot/pypgsql/pypgsql In directory usw-pr-cvs1:/tmp/cvs-serv11090 Modified Files: PgSQL.py Log Message: 19SEP2001 bga Cleaned up the logic in hadleArray(). --- Updated the PgSQL.__doc__ string. Index: PgSQL.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/PgSQL.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** PgSQL.py 2001/09/19 03:44:26 1.20 --- PgSQL.py 2001/09/20 03:51:00 1.21 *************** *** 30,33 **** --- 30,35 ---- # Date Ini Description | # --------- --- ------------------------------------------------------- | + # 19SEP2001 bga Cleaned up the logic in hadleArray(). | + # --- Updated the PgSQL.__doc__ string. | # 18SEP2001 bga [Feature Request #462588] Cursor.close() no longer ends | # (rollback) the open transaction when the last cursor is | *************** *** 110,121 **** Commit any pending transactions for this connection. ! NOTE: This will close any open cursors for this connection. connection.rollback() Rollback any pending transactions for this connection. ! NOTE: This will close any open cursors for this connection. ! connection.binary(string) -> blob Create a new PostgreSQL large object. If string is present, it is written to the new large object. The returned large object will --- 112,127 ---- Commit any pending transactions for this connection. ! NOTE: This will reset any open cursors for this connection to their ! inital state. Any PostgreSQL portals in use by cursors will ! be closed and any remaining query results will be discarded. connection.rollback() Rollback any pending transactions for this connection. ! NOTE: This will reset any open cursors for this connection to their ! inital state. Any PostgreSQL portals in use by cursors will ! be closed and any remaining query results will be discarded. ! connection.binary(string) -> PgLargeObject Create a new PostgreSQL large object. If string is present, it is written to the new large object. The returned large object will *************** *** 141,163 **** cursor.execute(query[, param1[, param2, ..., paramN]) Execute a query, binding the parameters if they are passed. The ! binding syntax is the same as the '%' operator except that only ! %s [or %(name)s] should be used and the %s [or %(name)s] should ! not be quoted. Any necessary quoting will be performed by the ! execute method. ! cursor.execute(query[, tuple]) ! Execute a query, binding the contents of the tuple as parameters. ! The binding syntax is the same as the '%' operator except that ! only %s should be used and the %s should not be quoted. Any ! necessary quoting will be performed by the execute method. cursor.execute(query[, dictionary]) Execute a query, binding the contents of the dictionary as para- ! meters. The binding syntax is the same as the '%' operator ex- ! cept that only %s [or %(name)s] should be used and the %s [or ! %(name)s] should not be quoted. Any necessary quoting will be ! performed by the execute method. ! NOTE: In order to use a PostgreSQL cursor (i.e. DECLARE ... CURSOR FOR ...), the word SELECT must be the first word in the query, and can only be be proceeded by spaces and tabs. If this is not --- 147,169 ---- cursor.execute(query[, param1[, param2, ..., paramN]) Execute a query, binding the parameters if they are passed. The ! binding syntax is the same as the '%' operator except that only %s ! [or %(name)s] should be used and the %s [or %(name)s] should not be ! quoted. Any necessary quoting will be performed by the execute ! method. ! cursor.execute(query[, sequence]) ! Execute a query, binding the contents of the sequence as parameters. ! The binding syntax is the same as the '%' operator except that only ! %s should be used and the %s should not be quoted. Any necessary ! quoting will be performed by the execute method. cursor.execute(query[, dictionary]) Execute a query, binding the contents of the dictionary as para- ! meters. The binding syntax is the same as the '%' operator except ! that only %s [or %(name)s] should be used and the %s [or %(name)s] ! should not be quoted. Any necessary quoting will be performed by ! the execute method. ! NOTE: In order to use a PostgreSQL portal (i.e. DECLARE ... CURSOR FOR ...), the word SELECT must be the first word in the query, and can only be be proceeded by spaces and tabs. If this is not *************** *** 499,537 **** _ftv = _ft.value ! if _ftv == PG_INT4: ! for _i in range(len(lst)): ! if type(lst[_i]) == ListType: ! lst[_i] = self.handleArray(colinfo, lst[_i]) ! else: ! lst[_i] = int(lst[_i]) ! elif _ftv == PG_INT8: ! for _i in range(len(lst)): ! if type(lst[_i]) == ListType: ! lst[_i] = self.handleArray(colinfo, lst[_i]) ! else: ! lst[_i] = PgInt8(lst[_i]) ! elif _ftv == PG_NUMERIC: ! for _i in range(len(lst)): ! if type(lst[_i]) == ListType: ! lst[_i] = self.handleArray(colinfo, lst[_i]) ! else: ! lst[_i] = PgNumeric(lst[_i], _p, _s) ! elif _ftv == PG_INT2: ! for _i in range(len(lst)): ! if type(lst[_i]) == ListType: ! lst[_i] = self.handleArray(colinfo, lst[_i]) ! else: ! lst[_i] = PgInt2(lst[_i]) ! elif _ftv == DATETIME: ! for _i in range(len(lst)): ! if type(lst[_i]) == ListType: ! lst[_i] = self.handleArray(colinfo, lst[_i]) ! else: ! lst[_i] = DateTime.ISO.ParseAny(lst[_i]) ! elif _ftv == PG_MONEY: ! for _i in range(len(lst)): ! if type(lst[_i]) == ListType: ! lst[_i] = self.handleArray(colinfo, lst[_i]) ! elif lst[_i][0] == '(': lst[_i] = PgMoney(-float(replace(lst[_i][2:-1], ',', ''))) elif lst[_i][0] == '-': --- 505,523 ---- _ftv = _ft.value ! for _i in range(len(lst)): ! if type(lst[_i]) == ListType: ! lst[_i] = self.handleArray(colinfo, lst[_i]) ! elif _ftv == PG_INT4: ! lst[_i] = int(lst[_i]) ! elif _ftv == PG_INT8: ! lst[_i] = PgInt8(lst[_i]) ! elif _ftv == PG_NUMERIC: ! lst[_i] = PgNumeric(lst[_i], _p, _s) ! elif _ftv == PG_INT2: ! lst[_i] = PgInt2(lst[_i]) ! elif _ftv == DATETIME: ! lst[_i] = DateTime.ISO.ParseAny(lst[_i]) ! elif _ftv == PG_MONEY: ! if lst[_i][0] == '(': lst[_i] = PgMoney(-float(replace(lst[_i][2:-1], ',', ''))) elif lst[_i][0] == '-': *************** *** 539,548 **** else: lst[_i] = PgMoney(float(replace(lst[_i][1:], ',', ''))) ! elif _ftv == BINARY: ! for _i in range(len(lst)): ! if type(lst[_i]) == ListType: ! lst[_i] = self.handleArray(colinfo, lst[_i]) ! else: ! lst[_i] = self.conn.conn.lo_get(lst[_i]) return lst --- 525,530 ---- else: lst[_i] = PgMoney(float(replace(lst[_i][1:], ',', ''))) ! elif _ftv == BINARY: ! lst[_i] = self.conn.conn.lo_get(lst[_i]) return lst |
From: Billy G. A. <bal...@us...> - 2001-09-19 03:47:59
|
Update of /cvsroot/pypgsql/pypgsql In directory usw-pr-cvs1:/tmp/cvs-serv12158 Modified Files: pgconnection.c Log Message: 19SEP2001 bga Re-ordered the items in PgConnection_members so that the attributes handled directly by PgConnection_getattr are grouped together and commented appropiately. Index: pgconnection.c =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pgconnection.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** pgconnection.c 2001/09/16 17:54:52 1.4 --- pgconnection.c 2001/09/19 03:47:56 1.5 *************** *** 29,32 **** --- 29,35 ---- | Date Ini Description | | --------- --- ------------------------------------------------------- | + | 19SEP2001 bga Re-ordered the items in PgConnection_members so that | + | the attributes handled directly by PgConnection_getattr | + | are grouped together and commented appropiately. | | 14SEP2001 bga Removed code related to PostgreSQL 6.5.x. We now only | | support PostgreSQL 7.0 and later. | *************** *** 1000,1011 **** { "user", T_OBJECT, CoOFF(user), RO }, { "password", T_OBJECT, CoOFF(pass), RO }, - { "status", T_INT, 0, RO }, - { "errorMessage", T_STRING, 0, RO }, { "backendPID", T_OBJECT, CoOFF(bePID), RO }, - { "isBusy", T_INT, 0, RO }, { "socket", T_OBJECT, CoOFF(socket), RO }, - { "isnonblocking", T_INT, 0, RO }, { "notices", T_OBJECT, CoOFF(notices), RO }, { "version", T_OBJECT, CoOFF(version), RO }, { NULL } }; --- 1003,1015 ---- { "user", T_OBJECT, CoOFF(user), RO }, { "password", T_OBJECT, CoOFF(pass), RO }, { "backendPID", T_OBJECT, CoOFF(bePID), RO }, { "socket", T_OBJECT, CoOFF(socket), RO }, { "notices", T_OBJECT, CoOFF(notices), RO }, { "version", T_OBJECT, CoOFF(version), RO }, + // The remaining attributes are handles directly in PgConnection_getattr() + { "status", T_INT, 0, RO }, + { "errorMessage", T_STRING, 0, RO }, + { "isBusy", T_INT, 0, RO }, + { "isnonblocking", T_INT, 0, RO }, { NULL } }; |
From: Billy G. A. <bal...@us...> - 2001-09-19 03:46:52
|
Update of /cvsroot/pypgsql/pypgsql In directory usw-pr-cvs1:/tmp/cvs-serv11993 Modified Files: pgversion.c Log Message: 18SEP2001 bga Removed variables that are no longer needed/referenced. Index: pgversion.c =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pgversion.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** pgversion.c 2001/09/17 04:37:06 1.11 --- pgversion.c 2001/09/19 03:46:49 1.12 *************** *** 32,35 **** --- 32,36 ---- | Date Ini Description | | --------- --- ------------------------------------------------------- | + | 18SEP2001 bga Removed variables that are no longer needed/referenced. | | 16SEP2001 bga Corrected my mis-conceptions about Python ignoring ex- | | ceptions generated during coercion. | *************** *** 273,277 **** { PgVersion *s; - PyObject *exception, *message, *traceback; char *vstr; --- 274,277 ---- |
From: Billy G. A. <bal...@us...> - 2001-09-19 03:44:30
|
Update of /cvsroot/pypgsql/pypgsql In directory usw-pr-cvs1:/tmp/cvs-serv11395 Modified Files: PgSQL.py Log Message: 19SEP2001 bga On Connection.close(), reset all the attributes to a sane state (i.e. None or 0, as appropiate). --- [Bug #462589] In a fit of optimization, I had introduced a bug that caused comparisons of PgResultSets to anything to fail. This problem has been fixed. Index: PgSQL.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/PgSQL.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** PgSQL.py 2001/09/18 19:23:35 1.19 --- PgSQL.py 2001/09/19 03:44:26 1.20 *************** *** 33,36 **** --- 33,41 ---- # (rollback) the open transaction when the last cursor is | # closed. | + # --- On Connection.close(), reset all the attributes to a | + # sane state (i.e. None or 0, as appropiate). | + # --- [Bug #462589] In a fit of optimization, I had intro- | + # duced a bug that caused comparisons of PgResultSets to | + # anything to fail. This bug has been squashed. | # 03SEP2001 gh Fixed several cases of references to non-existing | # globals in PgMoney. | *************** *** 69,169 **** # parameter subsitution on the query string if no addi- | # tional parameters are passed to execute. | - # 16JUL2001 bga Fixed a nasty little bug involving the difference be- | - # tween PgInt[2|8] as a type object and PgInt[2|8] as a | - # class. I was not correctly handling the distinction in | - # the code. | - # 12JUN2001 bga Used weak references (if availble) to remove the prob- | - # lem of circular references between the Connection ob- | - # ject and the Cursor objects created with it. The cir- | - # cular references between the Connection object and it's | - # associated TypeCache object are also resolved. | - # 11JUN2001 bga Fixed incorrect reference to .__reset() in the connec- | - # tion object. | - # 10JUN2001 bga Changed .execute() so that if a SELECT statement is | - # executed the remaining results (if any) of a previous | - # SELECT statement is discarded and replaced with the re- | - # sults of the new SELECT query. The previous behaviour | - # was to raise an InterfaceError in that situation. | - # --- Since .execute() will call the reset method as needed, | - # the .reset() method was renamed to .__reset() to make | - # private (at least a private as it gets in Python :-). | - # --- Change 'version' so that it holds the version number of | - # PgSQL.py. PostgreSQL version information is now held | - # in 'version' attribute of the connection object. | - # 09JUN2001 bga Modified the code so that the .close() method in Cursor | - # conforms to the DB-API 2.0 specification. Closing a | - # cursor now prevents it from being used any further, and | - # dis-associates the cursor from it's connection. | - # Commiting or rolling back a transaction will no longer | - # closes all the connection's cursors. It will, however, | - # reset the cursor to it's inital result and invalidate | - # any unread query results. | - # --- Reworked the code so that the .__getattr__() method in | - # Cursor is no longer needed. | - # --- Change ._reset_() so that it closes the PostgreSQL | - # portal, if one is opened. | - # --- Renamed _reset_() to reset() and document it as an ex- | - # tension to the DB-API 2.0 specification. | - # --- Updated the PgSQL.__doc__ string. | - # 04JUN2001 bga Added code to load DateTime from an alternate location | - # (from mx import DateTime) if import DateTime failed. | - # The alternate location came from a patch submitted by | - # Gerhard Häring <gha...@sf...>. | - # 03JUN2001 bga Minor bug fixes and improvments. | - # --- Improved the speed of initializing a new PgResultSet by | - # pre-building the name to index dictionary when the cur- | - # sor description attribute is built. | - # 02JUN2001 bga Modified code to use the C implementation of the PgInt2 | - # object. | - # 01JUN2001 bga Fixed problem with the __pow__ method in the PgInt8 | - # PgInt2, and PgMoney classes. | - # --- Added check to see if PgInt8 was imported from libpq, | - # If so, don't define the PgInt8 class. | - # 27MAY2001 bga Fixed a problem with the emulated numeric types that | - # caused exponetiation ('x ** y') to fail. | - # --- Fixed PgInt8, PgInt2, and PgMoney __rdiv()__ method. | - # --- Added missing __hash__() and __cmp__() methods to | - # PgOther and PgMoney. | - # --- Added missing __hash__() method to PgTypes. | - # --- Changed all occurances of OverflowException to | - # OverflowError. | - # 24MAY2001 bga Cleaned up some minor bugs caused by typos and also | - # cleaned up some minor inefficencies. | - # 22MAY2001 bga Made some additional changes in an effort to imporve | - # performance. Mostly, it was removing __getattr__ from | - # the Connection and Cursor classes. | - # --- Delayed getting the version number of the PostgreSQL | - # backend until the first time a connection to the data- | - # base is made. The newly created connection is used to | - # perform the 'SELECT version()' query. | - # 21MAY2001 bga Made some minor changes to __fetchOneRow() in an effort | - # to improve performance. In particular, setting the | - # variable named PgSQL.fetchReturnsList = 1 will cause | - # __fetchOneRow() (and subsequentially, all the fetch*() | - # methods) to return a list instead of a PgResultSet. | - # This should improve the performance of the fetch*() | - # methods by sacrificing the convenient access methods | - # provided by a PgResultSet. | - # 20MAY2001 bga Made some performance improvments in the following | - # methods/functions: | - # TypeCahce.typecast() | - # Cursor.__getattr__() | - # Cursor.__setattr__() | - # Connection.__setattr__() | - # These changes are based on ideas from Ondrej Palkovsky | - # (on...@us...). | - # 18MAY2001 bga Corrected error in the __nonzero__ method of PgInt2 and | - # PgInt8. | - # --- PostgreSQL only supports read-only cursors. Because of | - # this, any SELECT ... FOR UPDATE queries will not use a | - # PostgreSQL cursor. | - # --- PostgreSQL can now rollback deletions of large objects. | - # Modify PgSQL to reflect that fact. | - # --- Fixed the (broken) handling of empty lists in the | - # _handleArray() function. | - # 07MAY2001 bga PostgreSQL can now rollback drops of tables and indices | # Modify PgSQL to reflect that fact. | # --------- bga Remove prior comments to reduce the size of the flower | ! # box. See revision 1.5 for earlier comments. | #--(H-)-----------------------------------------------------------------+ """ --- 74,80 ---- # parameter subsitution on the query string if no addi- | # tional parameters are passed to execute. | # Modify PgSQL to reflect that fact. | # --------- bga Remove prior comments to reduce the size of the flower | ! # box. See revision 1.19 for earlier comments. | #--(H-)-----------------------------------------------------------------+ """ *************** *** 354,358 **** from libpq import * ! version = '1.5.1' apilevel = '2.0' --- 265,269 ---- from libpq import * ! version = '1.6' apilevel = '2.0' *************** *** 1252,1279 **** return - # __xlatKey transform a string (column name) key into an integer key - # used to access the column data. - def __xlatKey(self, key): - if self._xlatkey.has_key(key): - key = self._xlatkey[key] - else: - lkey = string.lower(key) - if self._xlatkey.has_key(lkey): - key = self._xlatkey[lkey] - else: - raise NameError, key - - return key - def __getattr__(self, key): ! return self.baseObj[self._xlatkey[key]] # We define a __setattr__ routine that will only allow the attributes that # are the column names to be updated. All other attributes are read-only. def __setattr__(self, key, value): ! if key in ('baseObj', ): raise AttributeError, "%s is read-only." % key ! self.__dict__['baseObj'][self.__xlatKey(key)] = value def __len__(self): --- 1163,1181 ---- return def __getattr__(self, key): ! if self._xlatkey.has_key(key): ! return self.baseObj[self._xlatkey[key]] ! raise AttributeError, key # We define a __setattr__ routine that will only allow the attributes that # are the column names to be updated. All other attributes are read-only. def __setattr__(self, key, value): ! if key in ('baseObj', '_xlatkey', '_desc_'): raise AttributeError, "%s is read-only." % key ! if self._xlatkey.has_key(key): ! self.__dict__['baseObj'][self._xlatkey(key)] = value ! else: ! raise AttributeError, key def __len__(self): *************** *** 1635,1642 **** pass - self.__dict__["_isOpen"] = 0 self.__dict__["_cache"] = None ! self.__dict__["notices"] = None self.__dict__["conn"] = None def commit(self): --- 1537,1548 ---- pass self.__dict__["_cache"] = None ! self.__dict__["_isOpen"] = 0 ! self.__dict__["autocommit"] = None self.__dict__["conn"] = None + self.__dict__["cursors"] = None + self.__dict__["inTransaction"] = 0 + self.__dict__["version"] = None + self.__dict__["notices"] = None def commit(self): |
From: Billy G. A. <bal...@us...> - 2001-09-18 19:23:37
|
Update of /cvsroot/pypgsql/pypgsql In directory usw-pr-cvs1:/tmp/cvs-serv7560 Modified Files: PgSQL.py Log Message: 18SEP2001 bga [Feature Request #462588] Cursor.close() no longer rollbacks the open transaction when the last cursor is closed. Index: PgSQL.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/PgSQL.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** PgSQL.py 2001/09/03 04:43:31 1.18 --- PgSQL.py 2001/09/18 19:23:35 1.19 *************** *** 30,33 **** --- 30,36 ---- # Date Ini Description | # --------- --- ------------------------------------------------------- | + # 18SEP2001 bga [Feature Request #462588] Cursor.close() no longer ends | + # (rollback) the open transaction when the last cursor is | + # closed. | # 03SEP2001 gh Fixed several cases of references to non-existing | # globals in PgMoney. | *************** *** 36,40 **** # attribute is now built on the first successful select | # or cursor fetch. | ! # 23AUG2001 bga [Bug #454653]Change the code to rollback an open trans- | # action, if any, when the last cursor of a connection is | # closed. | --- 39,43 ---- # attribute is now built on the first successful select | # or cursor fetch. | ! # 23AUG2001 bga [Bug #454653] Change the code to rollback an open trans-| # action, if any, when the last cursor of a connection is | # closed. | *************** *** 1559,1571 **** raise AttributeError, \ "Can't change autocommit when a cursor is active." - else: - # It's possible that the connection can still have an open - # transaction, even though there are no active cursors. This - # will only happen with weak references when the cursors have - # been deleted but not garbage collected. We will issue a - # rollback if this is the case. ! if self.inTransaction: ! self.rollback() if value: --- 1562,1571 ---- raise AttributeError, \ "Can't change autocommit when a cursor is active." ! # It's possible that the connection can still have an open ! # transaction, even though there are no active cursors. ! ! if self.inTransaction: ! self.rollback() if value: *************** *** 2040,2053 **** if noWeakRef: _cc.remove(self) ! anyLeft = len(_cc) > 0 ! if (anyLeft): # We have additional cursors, garbage collect them. _cc._Connection__gcCursors() else: del _cc.data[id(self)] - anyLeft = len(_cc.data.keys()) > 0 - - if not (anyLeft and self.conn.inTransaction): - self.conn.rollback() except: pass --- 2040,2048 ---- if noWeakRef: _cc.remove(self) ! if (len(_cc) > 0): # We have additional cursors, garbage collect them. _cc._Connection__gcCursors() else: del _cc.data[id(self)] except: pass |
From: Billy G. A. <bal...@us...> - 2001-09-17 17:09:17
|
Update of /cvsroot/pypgsql/pypgsql/test In directory usw-pr-cvs1:/tmp/cvs-serv22585 Modified Files: PgSQLTestCases.py Log Message: 17SEP2001 bga Modified test case(s) to reflect changes to pgversion.c. Index: PgSQLTestCases.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/test/PgSQLTestCases.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** PgSQLTestCases.py 2001/09/10 04:42:36 1.14 --- PgSQLTestCases.py 2001/09/17 17:09:13 1.15 *************** *** 462,468 **** self.failUnless(type(a) == type(b) == type(version), 'Coercion from float to PgVersion failed.') ! a, b = coerce(version, '7. 1.3') ! self.failUnless(b.post70 == None, ! 'Coercion from garbage string to PgVersion *should* have failed.') except StandardError, msg: self.fail(msg) --- 462,472 ---- self.failUnless(type(a) == type(b) == type(version), 'Coercion from float to PgVersion failed.') ! try: ! a, b = coerce(version, '7. 1.3') ! self.fail( ! 'Coercion from garbage string to PgVersion *should* have failed.' ! ) ! except ValueError, msg: ! pass except StandardError, msg: self.fail(msg) |
From: Billy G. A. <bal...@us...> - 2001-09-17 04:37:14
|
Update of /cvsroot/pypgsql/pypgsql In directory usw-pr-cvs1:/tmp/cvs-serv18017 Modified Files: pgversion.c Log Message: 16SEP2001 bga Corrected a mis-conception on my part about how Python handles exceptions generated during coercion. Index: pgversion.c =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pgversion.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** pgversion.c 2001/09/17 03:44:53 1.10 --- pgversion.c 2001/09/17 04:37:06 1.11 *************** *** 32,38 **** | Date Ini Description | | --------- --- ------------------------------------------------------- | ! | 16SEP2001 bga Fixed a problem that occurred with Python 2.2, which | ! | requires a -1 to be returned from the comparison func- | ! | tion before it honors any exception. | | 15SEP2001 bga Fixed problem where a variable in PgVersion_New() could | | be used before it was initialized. | --- 32,37 ---- | Date Ini Description | | --------- --- ------------------------------------------------------- | ! | 16SEP2001 bga Corrected my mis-conceptions about Python ignoring ex- | ! | ceptions generated during coercion. | | 15SEP2001 bga Fixed problem where a variable in PgVersion_New() could | | be used before it was initialized. | *************** *** 280,284 **** { PyErr_NoMemory(); ! return (1); } --- 279,283 ---- { PyErr_NoMemory(); ! return (-1); } *************** *** 344,383 **** coerce_error: - /*******************************************************************\ - | A bit of explaination is in order here. | - | | - | Python will ignore any exceptions raised from the call to coerce | - | types. In order to work around this problem, coerce will always | - | convert the other type to a PgVersion object, but if an error oc- | - | curs, that object will contain the saved error information. When | - | the compare function for PgVersion is call, it will re-raise the | - | saved exception. | - \*******************************************************************/ - PyMem_Free(vstr); ! ! PyErr_Fetch(&exception, &message, &traceback); ! ! s = (PgVersion *)PyObject_New(PgVersion, &PgVersion_Type); ! if (s == (PgVersion *)NULL) ! return (1); ! ! s->version = message; ! s->major = exception; ! s->minor = traceback; ! s->patch = Py_None; Py_INCREF(Py_None); ! s->post70 = Py_None; Py_INCREF(Py_None); ! s->value = Py_BuildValue("i", -1); ! ! if (PyErr_Occurred()) ! { ! PgVersion_dealloc(s); ! return (1); ! } ! ! *r = (PyObject *)s; ! Py_XINCREF(*l); ! ! return (0); } --- 343,348 ---- coerce_error: PyMem_Free(vstr); ! return (-1); } *************** *** 477,495 **** long right = PyInt_AS_LONG(o->value); - /*******************************************************************\ - | Check to see if one of the PgVersion objects contain error infor- | - | mation. If it does, restore the error condition. | - \*******************************************************************/ - - if (left < 0 || right < 0) - { - PgVersion *t = (left < 0 ? s : o); - - PyErr_Restore(t->major, t->version, t->minor); - t->major = Py_None; Py_XINCREF(t->major); - t->version = Py_None; Py_XINCREF(t->version); - t->minor = Py_None; Py_XINCREF(t->minor); - return (-1); - } return (left < right) ? -1 : (left > right) ? 1 : 0; } --- 442,445 ---- |
From: Billy G. A. <bal...@us...> - 2001-09-17 04:35:27
|
Update of /cvsroot/pypgsql/pypgsql/test/regression In directory usw-pr-cvs1:/tmp/cvs-serv17622 Modified Files: pgversion.py Log Message: 16SEP2001 bga Corrected a mis-conception on my part about the handling of exceptions generated in coercion functions by Python. Index: pgversion.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/test/regression/pgversion.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** pgversion.py 2001/09/14 04:05:00 1.1 --- pgversion.py 2001/09/17 04:35:24 1.2 *************** *** 34,37 **** --- 34,38 ---- # Date Ini Description | # --------- --- ------------------------------------------------------- | + # 16SEP2001 bga Change tests to reflect changes in pgversion.c. | # 13SEP2001 bga Completed the test cases for PgVersion. | # --- The coercion rules in Python 2.0 do not allow compari- | *************** *** 108,114 **** else: vers == '' ! self.fail( ! 'Comparison to badly formatted string succeeded.' ! ) except ValueError, msg: pass --- 109,113 ---- else: vers == '' ! self.fail('Comparison to badly formatted string succeeded.') except ValueError, msg: pass *************** *** 120,126 **** else: vers == '7.1. 2' ! self.fail( ! 'Comparison to badly formatted string succeeded.' ! ) except ValueError, msg: pass --- 119,123 ---- else: vers == '7.1. 2' ! self.fail('Comparison to badly formatted string succeeded.') except ValueError, msg: pass *************** *** 132,138 **** else: vers == '7.1Test' ! self.fail( ! 'Comparison to badly formatted string succeeded.' ! ) except ValueError, msg: pass --- 129,133 ---- else: vers == '7.1Test' ! self.fail('Comparison to badly formatted string succeeded.') except ValueError, msg: pass *************** *** 199,231 **** # Now test coercions that will fail. ! a, b = coerce(vers, '') ! self.failUnless(type(a) == type(b) == type(vers), ! 'Coercion from coerce to PgVersion failed.') ! expected = ['Ivalid format for PgVersion construction.', ! ValueError, None, None, None] ! self.CheckMemberValues(b, expected) ! a, b = coerce(vers, '7. 1.3') ! self.failUnless(type(a) == type(b) == type(vers), ! 'Coercion from coerce to PgVersion failed.') ! expected = ['Ivalid format for PgVersion construction.', ! ValueError, None, None, None] ! self.CheckMemberValues(b, expected) ! a, b = coerce(vers, 4294967296L) ! self.failUnless(type(a) == type(b) == type(vers), ! 'Coercion from long to PgVersion failed.') ! expected = ['long int too large to convert', ! OverflowError, None, None, None] ! if version < 20100: ! expected[0] = 'long int too long to convert' ! self.CheckMemberValues(b, expected) ! a, b = coerce(vers, 4294967296.0) ! self.failUnless(type(a) == type(b) == type(vers), ! 'Coercion from float to PgVersion failed.') ! expected = ['float too large to convert', ! OverflowError, None, None, None] ! self.CheckMemberValues(b, expected) def CheckPgVersionSanity(self): --- 194,220 ---- # Now test coercions that will fail. ! try: ! a, b = coerce(vers, '') ! self.fail('Comparison to badly formatted string succeeded.') ! except ValueError, msg: ! pass ! try: ! a, b = coerce(vers, '7. 1.3') ! self.fail('Comparison to badly formatted string succeeded.') ! except ValueError, msg: ! pass ! try: ! a, b = coerce(vers, 4294967296L) ! self.fail('Comparison to large valued long succeeded.') ! except OverflowError, msg: ! pass ! try: ! a, b = coerce(vers, 4294967296.0) ! self.fail('Comparison to large valued float succeeded.') ! except OverflowError, msg: ! pass def CheckPgVersionSanity(self): |
From: Billy G. A. <bal...@us...> - 2001-09-17 03:44:56
|
Update of /cvsroot/pypgsql/pypgsql In directory usw-pr-cvs1:/tmp/cvs-serv9769 Modified Files: pgversion.c Log Message: 16SEP2001 bga Fixed a problem that occurred with Python 2.2, which requires that a -1 be returned from the comparison function before it will honor any raised exceptions (this behaviour is changed from Python 2.1 and 2.0). Index: pgversion.c =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pgversion.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** pgversion.c 2001/09/16 17:53:27 1.9 --- pgversion.c 2001/09/17 03:44:53 1.10 *************** *** 32,35 **** --- 32,38 ---- | Date Ini Description | | --------- --- ------------------------------------------------------- | + | 16SEP2001 bga Fixed a problem that occurred with Python 2.2, which | + | requires a -1 to be returned from the comparison func- | + | tion before it honors any exception. | | 15SEP2001 bga Fixed problem where a variable in PgVersion_New() could | | be used before it was initialized. | *************** *** 487,490 **** --- 490,494 ---- t->version = Py_None; Py_XINCREF(t->version); t->minor = Py_None; Py_XINCREF(t->minor); + return (-1); } return (left < right) ? -1 : (left > right) ? 1 : 0; |
From: Billy G. A. <bal...@us...> - 2001-09-16 17:54:55
|
Update of /cvsroot/pypgsql/pypgsql In directory usw-pr-cvs1:/tmp/cvs-serv2947 Modified Files: libpqmodule.c libpqmodule.h pgconnection.c pgresult.c Log Message: 15SEP2001 bga Dropped support for PostgreSQL prior to version 7.0. Index: libpqmodule.c =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/libpqmodule.c,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** libpqmodule.c 2001/09/06 04:59:26 1.13 --- libpqmodule.c 2001/09/16 17:54:52 1.14 *************** *** 32,35 **** --- 32,37 ---- | Date Ini Description | | --------- --- ------------------------------------------------------- | + | 14SEP2001 bga Removed code related to PostgreSQL 6.5.x. We now only | + | support PostgreSQL 7.0 and later. | | 02SEP2001 bga Changed 'long long' to 'LONG_LONG'. That way there is | | no assumption of how a 64bit integer is declared. | *************** *** 610,614 **** /*-----------------------------------------------------------------------*/ - #if !defined(PGSQL_6X) PyDict_SetItemString(d, "POLLING_FAILED", Py_BuildValue("i", PGRES_POLLING_FAILED)); --- 612,615 ---- *************** *** 621,625 **** PyDict_SetItemString(d, "POLLING_ACTIVE", Py_BuildValue("i", PGRES_POLLING_ACTIVE)); - #endif PyDict_SetItemString(d, "EMPTY_QUERY", Py_BuildValue("i", PGRES_EMPTY_QUERY)); --- 622,625 ---- Index: libpqmodule.h =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/libpqmodule.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** libpqmodule.h 2001/09/04 02:28:24 1.5 --- libpqmodule.h 2001/09/16 17:54:52 1.6 *************** *** 70,74 **** \***********************************************************************/ ! #if defined(WITH_THREAD) && !defined(PGSQL_6X) # define Pg_BEGIN_ALLOW_THREADS(cnx) \ { \ --- 70,74 ---- \***********************************************************************/ ! #if defined(WITH_THREAD) # define Pg_BEGIN_ALLOW_THREADS(cnx) \ { \ Index: pgconnection.c =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pgconnection.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** pgconnection.c 2001/09/03 00:35:46 1.3 --- pgconnection.c 2001/09/16 17:54:52 1.4 *************** *** 29,32 **** --- 29,34 ---- | Date Ini Description | | --------- --- ------------------------------------------------------- | + | 14SEP2001 bga Removed code related to PostgreSQL 6.5.x. We now only | + | support PostgreSQL 7.0 and later. | | 02SEP2001 bga Modified pgFixEsc so that any escaped sequence (\xHH) | | whose value is greater than 127 is replaced by the | *************** *** 105,111 **** { s[2] = (v & 7) + '0'; ! v /= 8; s[1] = (v & 7) + '0'; ! v /= 8; s[0] = (v & 7) + '0'; s += 3; --- 107,113 ---- { s[2] = (v & 7) + '0'; ! v >>= 3; s[1] = (v & 7) + '0'; ! v >>= 3; s[0] = (v & 7) + '0'; s += 3; *************** *** 215,220 **** char buf[100]; ! (void)sprintf(buf, "<PgConnection instance at %p: %s>", (void *)self, ! (self->conn ? "OPENED" : "CLOSED")); return Py_BuildValue("s", buf); } --- 217,222 ---- char buf[100]; ! (void)sprintf(buf, "<%s PgConnection at %p>", ! (self->conn ? "Opened" : "Closed"), (void *)self); return Py_BuildValue("s", buf); } *************** *** 273,277 **** } ! return(t); } --- 275,279 ---- } ! return (t); } *************** *** 335,342 **** /*--------------------------------------------------------------------------*/ - #if !defined(PGSQL_6X) static char libPQsetnonblocking_Doc[] = ! "setnonblocking(onOff) -- Make the connection non-blocking if 'onOff' is TRUE,\n" ! "\t\t\t otherwise make the connection blocking.\n"; static PyObject *libPQsetnonblocking(PgConnection *self, PyObject *args) --- 337,343 ---- /*--------------------------------------------------------------------------*/ static char libPQsetnonblocking_Doc[] = ! "setnonblocking(onOff) -- Make the connection non-blocking if 'onOff' is " ! "TRUE,\n\t\t\t otherwise make the connection blocking.\n"; static PyObject *libPQsetnonblocking(PgConnection *self, PyObject *args) *************** *** 362,366 **** return Py_None; } - #endif /*--------------------------------------------------------------------------*/ --- 363,366 ---- *************** *** 470,474 **** /*--------------------------------------------------------------------------*/ - #if !defined(PGSQL_6X) static char libPQflush_Doc[] = "flush() -- Attempt to flush any data queued on the backend."; --- 470,473 ---- *************** *** 496,504 **** return Py_None; } - #endif /*--------------------------------------------------------------------------*/ - #if !defined(PGSQL_6X) static char libPQconnectPoll_Doc[] = "PQconnectPoll(PgConnection) -> Integer\n" --- 495,501 ---- *************** *** 519,523 **** return Py_BuildValue("i", PQconnectPoll(PgConnection_Get(self))); } - #endif /*--------------------------------------------------------------------------*/ --- 516,519 ---- *************** *** 986,995 **** {"trace", (PyCFunction)libPQtrace, 1, libPQtrace_Doc}, {"untrace", (PyCFunction)libPQuntrace, 1, libPQuntrace_Doc}, - #if !defined(PGSQL_6X) {"connectPoll", (PyCFunction)libPQconnectPoll, 1, libPQconnectPoll_Doc}, {"flush", (PyCFunction)libPQflush, 1, libPQflush_Doc}, {"setnonblocking", (PyCFunction)libPQsetnonblocking, 1, libPQsetnonblocking_Doc}, - #endif { NULL, NULL } }; --- 982,989 ---- *************** *** 1011,1017 **** { "isBusy", T_INT, 0, RO }, { "socket", T_OBJECT, CoOFF(socket), RO }, - #if !defined(PGSQL_6X) { "isnonblocking", T_INT, 0, RO }, - #endif { "notices", T_OBJECT, CoOFF(notices), RO }, { "version", T_OBJECT, CoOFF(version), RO }, --- 1005,1009 ---- *************** *** 1056,1063 **** return Py_BuildValue("i", PQisBusy(cnx)); - #if !defined(PGSQL_6X) if (!strcmp(attr, "isnonblocking")) return Py_BuildValue("i", PQisnonblocking(cnx)); - #endif if (!strcmp(attr, "__module__")) --- 1048,1053 ---- Index: pgresult.c =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pgresult.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** pgresult.c 2001/09/06 04:42:21 1.8 --- pgresult.c 2001/09/16 17:54:52 1.9 *************** *** 29,32 **** --- 29,34 ---- | Date Ini Description | | --------- --- ------------------------------------------------------- | + | 14SEP2001 bga Removed code related to PostgreSQL 6.5.x. We now only | + | support PostgreSQL 7.0 and later. | | 06SEP2001 bga Fixed a gcc reported int format <-> long int arguement | | mis-match. | *************** *** 139,143 **** else self->ctuples = Py_BuildValue("l", strtol(m, NULL, 10)); - #if !defined(PGSQL_6X) o = PQoidValue(res); if (o == InvalidOid) --- 141,144 ---- *************** *** 148,152 **** else self->oidval = Py_BuildValue("l", (long)o); - #endif } --- 149,152 ---- *************** *** 170,176 **** Py_XDECREF(self->cstatus); Py_XDECREF(self->ctuples); - #if !defined(PGSQL_6X) Py_XDECREF(self->oidval); - #endif PyObject_Del((PyObject *)self); --- 170,174 ---- *************** *** 741,747 **** { "cmdStatus", T_OBJECT, RsOFF(cstatus), RO }, { "cmdTuples", T_OBJECT, RsOFF(ctuples), RO }, - #if !defined(PGSQL_6X) { "oidValue", T_OBJECT, RsOFF(oidval), RO }, - #endif { NULL } }; --- 739,743 ---- |
From: Billy G. A. <bal...@us...> - 2001-09-16 17:53:31
|
Update of /cvsroot/pypgsql/pypgsql In directory usw-pr-cvs1:/tmp/cvs-serv2751 Modified Files: pgversion.c Log Message: 15SEP2001 bga Fixed problem where a variable in PgVersion_New() could be used before it was initialized. Index: pgversion.c =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pgversion.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** pgversion.c 2001/09/14 04:01:37 1.8 --- pgversion.c 2001/09/16 17:53:27 1.9 *************** *** 32,35 **** --- 32,37 ---- | Date Ini Description | | --------- --- ------------------------------------------------------- | + | 15SEP2001 bga Fixed problem where a variable in PgVersion_New() could | + | be used before it was initialized. | | 12SEP2001 bga Improved detection of erronious input strings. | | --- Various minor bug fixes and code cleanup. | *************** *** 151,158 **** { PgVersion *self; ! char *s; /* writeable temporary copy of version string */ ! char *vstr; /* The version number from the version string */ ! char *token; /* parsed token */ ! char *save_ptr; /* saves strtok_r state for subsequent calls */ long major, minor, patch, value; --- 153,160 ---- { PgVersion *self; ! char *s = (char *)NULL; /* writeable temporary copy of version string */ ! char *vstr; /* The version number from the version string */ ! char *token; /* parsed token */ ! char *save_ptr; /* saves strtok_r state for subsequent calls */ long major, minor, patch, value; |
From: Billy G. A. <bal...@us...> - 2001-09-14 04:05:03
|
Update of /cvsroot/pypgsql/pypgsql/test/regression In directory usw-pr-cvs1:/tmp/cvs-serv17006/test/regression Added Files: pgversion.py Log Message: 13SEP2001 bga Added regression test case(s) for the PgVersion Object. --- NEW FILE: pgversion.py --- #!/usr/local/bin/python #ident "@(#) $Id: pgversion.py,v 1.1 2001/09/14 04:05:00 ballie01 Exp $" #-----------------------------------------------------------------------+ # Name: pgversion.py | # | # Description: pgversion.py contains (white box) regression test cases | # for the PgVersion object. | # | # Note: These test cases requires that a test database named | # pypgsql exists and that the person running the test has | # full rights to the database. | #=======================================================================| # Copyright 2001 by Billy G. Allie. | # All rights reserved. | # | # Permission to use, copy, modify, and distribute this software and its | # documentation for any purpose and without fee is hereby granted, pro- | # vided that the above copyright notice appear in all copies and that | # both that copyright notice and this permission notice appear in sup- | # porting documentation, and that the copyright owner's name not be | # used in advertising or publicity pertaining to distribution of the | # software without specific, written prior permission. | # | # THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, | # INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN | # NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR | # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS | # OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE | # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE | # USE OR PERFORMANCE OF THIS SOFTWARE. | #=======================================================================| # Revision History: | # | # Date Ini Description | # --------- --- ------------------------------------------------------- | # 13SEP2001 bga Completed the test cases for PgVersion. | # --- The coercion rules in Python 2.0 do not allow compari- | # sons of PgVersion object to String Object to work. The | # test cases will coerce strings to PgVersion objects be- | # for comparing them to a PgVersion object. | # 10SEP2001 bga Initial release by Billy G. Allie. | #-----------------------------------------------------------------------+ import sys import unittest import types import string import libpq version = sys.version_info version = ((((version[0] * 100) + version[1]) * 100) + version[2]) # Get a connection and a version string to be used globally. cnx = libpq.PQconnectdb("dbname=pypgsql") vers = cnx.version dbvstr = cnx.query('select version()').getvalue(0, 0) vstr = dbvstr.split()[1] cnx.finish() del cnx class PgVersionTestCases(unittest.TestCase): def setUp(self): global vers, vstr, dbvstr self.vers = vers self.vstr = vstr self.dbvstr = dbvstr self.members = ['version', 'major', 'minor', 'level', 'post70'] def CheckForMembers(self, res): for i in self.members: self.assert_(i in res.__members__, 'PgVersion is missing member "%s".' % i) def CheckMemberValues(self, res, expected): for i in range(len(self.members)): exec 'v = res.%s' % self.members[i] self.assertEquals(v, expected[i], 'PgVersion.%s is %s, it should be %s!' % \ (self.members[i], v, expected[i])) def CheckPgVersionComparison(self): global version # Build up the value to compare against the PgVersion Object value = (((vers.major * 100) + vers.minor) * 100) + vers.level self.assert_(vers == value, "Numeric equality check failed.") self.assert_(vers < (value + 1), "Numeric less than check failed.") self.assert_(vers > (value - 1), "Numeric greater than check failed.") if version < 20100: # Python Version 2.0 coercion rules prevents comparison of a # PgVersion object to a String object from working :-( a, b = coerce(vers, self.vstr) self.assert_(vers == b, "String equality check failed.") a, b = coerce(vers, '99.99.99') self.assert_(vers < b, "String less than check failed.") a, b = coerce(vers, '1.0.0') self.assert_(vers > b, "String greater than check failed.") else: self.assert_(vers == self.vstr, "String equality check failed.") self.assert_(vers < '99.99.99', "String less than check failed.") self.assert_(vers > '1.0.0', "String greater than check failed.") # Now test that exceptions are raises on coversion errors. try: if version < 20100: a, b = coerce(vers, '') vers == b else: vers == '' self.fail( 'Comparison to badly formatted string succeeded.' ) except ValueError, msg: pass try: if version < 20100: a, b = coerce(vers, '7.1. 2') vers == b else: vers == '7.1. 2' self.fail( 'Comparison to badly formatted string succeeded.' ) except ValueError, msg: pass try: if version < 20100: a, b = coerce(vers, '7.1Test') vers == b else: vers == '7.1Test' self.fail( 'Comparison to badly formatted string succeeded.' ) except ValueError, msg: pass try: if version < 20100: a, b = coerce(vers, '7.1 on') vers == b else: vers == '7.1 on' self.fail( 'Comparison to badly formatted string succeeded.' ) except ValueError, msg: pass try: vers == 4294967296L self.fail('Comparison to large valued long succeeded.') except OverflowError, msg: pass try: vers == 4294967296.0 self.fail('Comparison to large valued float succeeded.') except OverflowError, msg: pass def CheckPgVersionCoercion(self): global version # Note that these tests are designed to also check the calculation # of the post70 attribute. For the first 2 coercions, post70 will # be 0. It will be 1 for that second 2 coercions. a, b = coerce(vers, '6.1.5') self.failUnless(type(a) == type(b) == type(vers), 'Coercion from string to PgVersion failed.') expected = ['PostgreSQL 6.1.5 on UNKNOWN, compiled by UNKNOWN', 6, 1, 5, 0] self.CheckMemberValues(b, expected) a, b = coerce(vers, 70003) self.failUnless(type(a) == type(b) == type(vers), 'Coercion from int to PgVersion failed.') expected = ['PostgreSQL 7.0.3 on UNKNOWN, compiled by UNKNOWN', 7, 0, 3, 0] self.CheckMemberValues(b, expected) a, b = coerce(vers, 70100.0) self.failUnless(type(a) == type(b) == type(vers), 'Coercion from float to PgVersion failed.') expected = ['PostgreSQL 7.1.0 on UNKNOWN, compiled by UNKNOWN', 7, 1, 0, 1] self.CheckMemberValues(b, expected) a, b = coerce(vers, 80002L) self.failUnless(type(a) == type(b) == type(vers), 'Coercion from long to PgVersion failed.') expected = ['PostgreSQL 8.0.2 on UNKNOWN, compiled by UNKNOWN', 8, 0, 2, 1] self.CheckMemberValues(b, expected) # Now test coercions that will fail. a, b = coerce(vers, '') self.failUnless(type(a) == type(b) == type(vers), 'Coercion from coerce to PgVersion failed.') expected = ['Ivalid format for PgVersion construction.', ValueError, None, None, None] self.CheckMemberValues(b, expected) a, b = coerce(vers, '7. 1.3') self.failUnless(type(a) == type(b) == type(vers), 'Coercion from coerce to PgVersion failed.') expected = ['Ivalid format for PgVersion construction.', ValueError, None, None, None] self.CheckMemberValues(b, expected) a, b = coerce(vers, 4294967296L) self.failUnless(type(a) == type(b) == type(vers), 'Coercion from long to PgVersion failed.') expected = ['long int too large to convert', OverflowError, None, None, None] if version < 20100: expected[0] = 'long int too long to convert' self.CheckMemberValues(b, expected) a, b = coerce(vers, 4294967296.0) self.failUnless(type(a) == type(b) == type(vers), 'Coercion from float to PgVersion failed.') expected = ['float too large to convert', OverflowError, None, None, None] self.CheckMemberValues(b, expected) def CheckPgVersionSanity(self): self.CheckForMembers(vers) # Build up what the attributes of the PgVersion Object should be # from the result of the 'select version() query. a = vstr.split('.') major = int(a[0]) minor = int(a[1]) if len(a[2]) == 0: level = 0 else: level = int(a[2]) value = (((major * 100) + minor) * 100) + level post70 = (value > 70100) # Compare the PgVersion object against the expected values. expected = [dbvstr, major, minor, level, post70] self.CheckMemberValues(vers, expected) # Compare the PgVersions value against the calculated value from it's # major, minor, and level attributes value = (((vers.major * 100) + vers.minor) * 100) + vers.level self.assertEquals(vers, value, "PgVersion object's value does not match componet parts."); if __name__ == "__main__": TestSuite = unittest.TestSuite() TestSuite.addTest(PgVersionTestCases("CheckPgVersionSanity")) TestSuite.addTest(PgVersionTestCases("CheckPgVersionCoercion")) TestSuite.addTest(PgVersionTestCases("CheckPgVersionComparison")) runner = unittest.TextTestRunner() runner.run(TestSuite) |
From: Billy G. A. <bal...@us...> - 2001-09-14 04:01:40
|
Update of /cvsroot/pypgsql/pypgsql In directory usw-pr-cvs1:/tmp/cvs-serv14906 Modified Files: pgversion.c Log Message: 12SEP2001 bga Improved detection of erronious input strings. --- Various minor bug fixes and code cleanup. --- Made constructed version string more closely mimic the actual format of the PostgreSQL version string. 09SEP2001 bga Fixed the broken comparison function. This proved to be a not so easy task since any errors set in the extensions module's coerce() function are ignored (unless called by Python's built- in coerce() function). Python will clear the error and try to convert the PgVersion object to the other type if the coersion to PgVersion fails. I do not want that to happen. If the ob- ject can't be coerced to a PgVersion, then the comparison does not make sense, so an exception should occur. To get this be- haviour required a bit sneaky-ness. See the comments in the code for details. A concequence of this change is that coerce will always succeed. I can not see any way around this. --- Having a __dict__ attribute and calling PyMember_Get() in the PyVersion_getattr function causes dir() to do strange things (like list members twice). I've removed the __dict__ attribute and adding methods to emulate a mapping object to PgVersion. A PgVersion object will now act like a dictionary, so use version[key] instead of version.__dict__[key]. Index: pgversion.c =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pgversion.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** pgversion.c 2001/09/10 04:41:32 1.7 --- pgversion.c 2001/09/14 04:01:37 1.8 *************** *** 32,35 **** --- 32,39 ---- | Date Ini Description | | --------- --- ------------------------------------------------------- | + | 12SEP2001 bga Improved detection of erronious input strings. | + | --- Various minor bug fixes and code cleanup. | + | --- Made constructed version string more closely mimic the | + | actual format of the PostgreSQL version string. | | 09SEP2001 bga Fixed the broken comparison function. This proved to | | be a not so easy task since any errors set in the ex- | *************** *** 76,79 **** --- 80,84 ---- #include <ctype.h> #include <limits.h> + #include <errno.h> #include <Python.h> #include <structmember.h> *************** *** 90,95 **** PyObject *minor; PyObject *patch; - PyObject *value; PyObject *post70; } PgVersion; --- 95,100 ---- PyObject *minor; PyObject *patch; PyObject *post70; + PyObject *value; } PgVersion; *************** *** 110,126 **** char *last; ! *result = strtol(token, &last, 0); ! if ((token == (char *)NULL) || ! (*token == '\0') || ! isspace(*token) || ! (*last != 0)) ! { ! PyErr_SetString(PyExc_ValueError, ! "Invalid format for PgVersion construction."); ! return (1); ! } ! return (0); } --- 115,134 ---- char *last; ! /*******************************************************************\ ! | For our purposes, an error occurs when parsing a token if: | ! | 1. the 1st character of token is not a digit. | ! | 2. strtol() set errno to something other than 0. | ! | 3. strtol() could not translate the entire token (i.e. *last is | ! | not the ASCII NUL character). | ! \*******************************************************************/ ! if (!isdigit(*token)) ! return 1; ! errno = 0; ! ! *result = strtol(token, &last, 0); ! ! return ((errno != 0) || (*last != (char)0)); } *************** *** 159,164 **** if ((self->version == (PyObject *)NULL) || (s == (char *)NULL)) { ! PyErr_SetString(PyExc_MemoryError, ! "Can't allocate memory in PgVersion_New()."); goto new_error; } --- 167,171 ---- if ((self->version == (PyObject *)NULL) || (s == (char *)NULL)) { ! PyErr_NoMemory(); goto new_error; } *************** *** 176,186 **** major = minor = patch = value = 0; token = strtok_r(s, " \t", &save_ptr); if (strcmp(token, "PostgreSQL") != 0) - { - PyErr_SetString(PyExc_ValueError, - "Ivalid format for PgVersion construction."); goto new_error; - } vstr = strtok_r((char *)NULL, " \t", &save_ptr); --- 183,196 ---- major = minor = patch = value = 0; + /* Pre-set the error condition. + * We'll clear it if everything's OK + */ + PyErr_SetString(PyExc_ValueError, + "Ivalid format for PgVersion construction."); + + token = strtok_r(s, " \t", &save_ptr); if (strcmp(token, "PostgreSQL") != 0) goto new_error; vstr = strtok_r((char *)NULL, " \t", &save_ptr); *************** *** 188,196 **** token = strtok_r((char *)NULL, " \t", &save_ptr); if (strcmp(token, "on") != 0) - { - PyErr_SetString(PyExc_ValueError, - "Ivalid format for PgVersion construction."); goto new_error; ! } /***************************************************************\ --- 198,211 ---- token = strtok_r((char *)NULL, " \t", &save_ptr); if (strcmp(token, "on") != 0) goto new_error; ! ! /***************************************************************\ ! | This test is in case someone tries to compares against a | ! | string such as '7.2 on'. | ! \***************************************************************/ ! ! token = strtok_r((char *)NULL, " \t", &save_ptr); ! if (strcmp(token, "on") == 0) ! goto new_error; /***************************************************************\ *************** *** 217,220 **** --- 232,241 ---- value = (((major * 100) + minor) * 100) + patch; + /* OK, the version information has been parsed, + * Clear the pre-set error + */ + (void)PyErr_Clear(); + + /* And build the attributes */ self->major = Py_BuildValue("i", major); self->minor = Py_BuildValue("i", minor); *************** *** 227,231 **** PyMem_Free(s); - return (PyObject *)self; --- 248,251 ---- *************** *** 249,264 **** { PgVersion *s; char *vstr; if (PyString_Check(*r)) { ! vstr = PyMem_Malloc(32 + strlen(PyString_AsString(*r))); ! if (vstr == (char *)NULL) ! { ! PyErr_SetString(PyExc_MemoryError, ! "Can't allocate memory in PgVersion_coerce()."); ! return (1); ! } ! sprintf(vstr, "PostgreSQL %s on Dummy", PyString_AsString(*r)); } else --- 269,285 ---- { PgVersion *s; + PyObject *exception, *message, *traceback; char *vstr; + if ((vstr = PyMem_Malloc(128)) == (char *)NULL) + { + PyErr_NoMemory(); + return (1); + } + if (PyString_Check(*r)) { ! sprintf(vstr, "PostgreSQL %.80s on UNKNOWN, compiled by UNKNOWN", ! PyString_AsString(*r)); } else *************** *** 266,275 **** long value = 0; - if ((vstr = PyMem_Malloc(128)) == (char *)NULL) - { - PyErr_NoMemory(); - return (1); - } - if (PgInt2_Check(*r)) { --- 287,290 ---- *************** *** 295,299 **** { PyErr_SetString(PyExc_OverflowError, ! "converting Float to Integer"); } else --- 310,314 ---- { PyErr_SetString(PyExc_OverflowError, ! "float too large to convert"); } else *************** *** 304,310 **** goto coerce_error; ! sprintf(vstr, "PostgreSQL %ld.%ld.%ld on Dummy", (value / 10000), ! ((value / 100) % 100), (value % 100)); } s = (PgVersion *)PgVersion_New(vstr); --- 319,326 ---- goto coerce_error; ! sprintf(vstr, "PostgreSQL %ld.%ld.%ld on UNKNOWN, compiled by UNKNOWN", ! (value / 10000), ((value / 100) % 100), (value % 100)); } + s = (PgVersion *)PgVersion_New(vstr); *************** *** 336,347 **** PyMem_Free(vstr); s = (PgVersion *)PyObject_New(PgVersion, &PgVersion_Type); if (s == (PgVersion *)NULL) return (1); ! PyErr_Fetch(&s->major, &s->version, &s->minor); ! s->value = Py_BuildValue("i", -1); ! s->patch = Py_None; Py_INCREF(Py_None); ! s->post70 = Py_None; Py_INCREF(Py_None); if (PyErr_Occurred()) --- 352,367 ---- PyMem_Free(vstr); + PyErr_Fetch(&exception, &message, &traceback); + s = (PgVersion *)PyObject_New(PgVersion, &PgVersion_Type); if (s == (PgVersion *)NULL) return (1); ! s->version = message; ! s->major = exception; ! s->minor = traceback; ! s->patch = Py_None; Py_INCREF(Py_None); ! s->post70 = Py_None; Py_INCREF(Py_None); ! s->value = Py_BuildValue("i", -1); if (PyErr_Occurred()) *************** *** 462,468 **** PyErr_Restore(t->major, t->version, t->minor); ! Py_XINCREF(t->major); ! Py_XINCREF(t->version); ! Py_XINCREF(t->minor); } return (left < right) ? -1 : (left > right) ? 1 : 0; --- 482,488 ---- PyErr_Restore(t->major, t->version, t->minor); ! t->major = Py_None; Py_XINCREF(t->major); ! t->version = Py_None; Py_XINCREF(t->version); ! t->minor = Py_None; Py_XINCREF(t->minor); } return (left < right) ? -1 : (left > right) ? 1 : 0; |
From: Billy G. A. <bal...@us...> - 2001-09-10 07:22:01
|
Update of /cvsroot/pypgsql/pypgsql/test/regression In directory usw-pr-cvs1:/tmp/cvs-serv25198/test/regression Modified Files: pgresult.py Log Message: 10SEP2001 bga Completed (for now :-) the pgresult unit test cases. Index: pgresult.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/test/regression/pgresult.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** pgresult.py 2001/09/10 04:42:36 1.4 --- pgresult.py 2001/09/10 07:21:57 1.5 *************** *** 34,37 **** --- 34,39 ---- # Date Ini Description | # --------- --- ------------------------------------------------------- | + # 10SEP2001 bga Added the test cases for methods. This unit test file | + # is complete (for now :-). | # 09SEP2001 bga Modified tests to reflect changes to PgVersion object. | # In particulare, a PgVersion object no longer has a | *************** *** 56,60 **** class PgResultMemberTestCases(unittest.TestCase): - def setUp(self): global cnx --- 58,61 ---- *************** *** 107,111 **** def CheckCloseBinaryPgResult(self): ! res = self.cnx.query("CLOSE pgres_cursor") self.CheckForMembers(res) self.CheckForMethods(res) --- 108,112 ---- def CheckCloseBinaryPgResult(self): ! res = self.cnx.query("CLOSE pgres_bcursor") self.CheckForMembers(res) self.CheckForMethods(res) *************** *** 236,255 **** class PgResultTestCases(unittest.TestCase): def setUp(self): ! self.cnx = libpq.PQconnectdb('dbname=pypgsql') ! self.vstr = "%(major)d.%(minor)d" % self.cnx.version ! self.cnx.query('begin work') ! ! def tearDown(self): ! try: ! self.cnx.query('rollback') ! self.cnx.finish() ! except AttributeError: ! pass ! except libpq.InterfaceError: ! pass def CheckSelectOfNonPrintableString(self): try: - self.cnx.toggleShowQuery a = '\x01\x02\x03\x04' res = self.cnx.query("select %s as a" % repr(a)) --- 237,488 ---- class PgResultTestCases(unittest.TestCase): def setUp(self): ! global cnx ! global vstr ! ! self.cnx = cnx ! self.vstr = vstr ! self.members = ['binaryTuples', 'cmdStatus', 'cmdTuples', 'nfields', ! 'ntuples', 'oidValue', 'resultErrorMessage', ! 'resultStatus', 'resultType'] ! ! def CheckMemberValues(self, res, expected): ! for i in range(len(self.members)): ! exec 'v = res.%s' % self.members[i] ! self.assertEquals(v, expected[i], ! 'PgResult.%s is %s, it should be %s!' % \ ! (self.members[i], v, expected[i])) ! ! def CheckDropPgResult(self): ! res = self.cnx.query("DROP TABLE pgresult_test") ! expected = [0, 'DROP', None, 0, 0, None, None, 1, 2 ] ! self.CheckMemberValues(res, expected) ! self.failUnlessRaises(libpq.InterfaceError, res.fmod, 0) ! self.failUnlessRaises(libpq.InterfaceError, res.fname, 0) ! self.failUnlessRaises(libpq.InterfaceError, res.fnumber, "NoSuchName") ! self.failUnlessRaises(libpq.InterfaceError, res.fsize, 0) ! self.failUnlessRaises(libpq.InterfaceError, res.ftype, 0) ! self.failUnlessRaises(libpq.InterfaceError, res.getisnull, 0, 0) ! self.failUnlessRaises(libpq.InterfaceError, res.getlength, 0, 0) ! self.failUnlessRaises(libpq.InterfaceError, res.getvalue, 0, 0) ! ! def CheckEndPgResult(self): ! res = self.cnx.query("END WORK") ! expected = [0, 'COMMIT', None, 0, 0, None, None, 1, 2 ] ! self.CheckMemberValues(res, expected) ! self.failUnlessRaises(libpq.InterfaceError, res.fmod, 0) ! self.failUnlessRaises(libpq.InterfaceError, res.fname, 0) ! self.failUnlessRaises(libpq.InterfaceError, res.fnumber, "NoSuchName") ! self.failUnlessRaises(libpq.InterfaceError, res.fsize, 0) ! self.failUnlessRaises(libpq.InterfaceError, res.ftype, 0) ! self.failUnlessRaises(libpq.InterfaceError, res.getisnull, 0, 0) ! self.failUnlessRaises(libpq.InterfaceError, res.getlength, 0, 0) ! self.failUnlessRaises(libpq.InterfaceError, res.getvalue, 0, 0) ! ! def CheckClosePgResult(self): ! res = self.cnx.query("CLOSE pgres_cursor") ! expected = [0, 'CLOSE', None, 0, 0, None, None, 1, 2 ] ! self.CheckMemberValues(res, expected) ! self.failUnlessRaises(libpq.InterfaceError, res.fmod, 0) ! self.failUnlessRaises(libpq.InterfaceError, res.fname, 0) ! self.failUnlessRaises(libpq.InterfaceError, res.fnumber, "NoSuchName") ! self.failUnlessRaises(libpq.InterfaceError, res.fsize, 0) ! self.failUnlessRaises(libpq.InterfaceError, res.ftype, 0) ! self.failUnlessRaises(libpq.InterfaceError, res.getisnull, 0, 0) ! self.failUnlessRaises(libpq.InterfaceError, res.getlength, 0, 0) ! self.failUnlessRaises(libpq.InterfaceError, res.getvalue, 0, 0) ! ! def CheckMovePgResult(self): ! res = self.cnx.query("MOVE BACKWARD ALL IN pgres_cursor") ! expected = [0, 'MOVE', None, 0, 0, None, None, 1, 2 ] ! self.CheckMemberValues(res, expected) ! self.failUnlessRaises(libpq.InterfaceError, res.fmod, 0) ! self.failUnlessRaises(libpq.InterfaceError, res.fname, 0) ! self.failUnlessRaises(libpq.InterfaceError, res.fnumber, "NoSuchName") ! self.failUnlessRaises(libpq.InterfaceError, res.fsize, 0) ! self.failUnlessRaises(libpq.InterfaceError, res.ftype, 0) ! self.failUnlessRaises(libpq.InterfaceError, res.getisnull, 0, 0) ! self.failUnlessRaises(libpq.InterfaceError, res.getlength, 0, 0) ! self.failUnlessRaises(libpq.InterfaceError, res.getvalue, 0, 0) ! ! def CheckFetchPgResult(self): ! res = self.cnx.query("FETCH 2 FROM pgres_cursor") ! expected = [0, 'FETCH', None, 2, 2, None, None, 2, 1 ] ! self.CheckMemberValues(res, expected) ! self.assertEquals(res.fmod(0), -1, ! "fmod(0) was %d, it should be -1." % res.fmod(0)) ! self.assertEquals(res.fname(0), 'f1', ! "fname(0) was '%s', it should be 'f1'." % ! res.fname(0)) ! self.assertEquals(res.fnumber('f2'), 1, ! "fnumber('f2') was %d, it should be 1." % ! res.fnumber('f2')) ! self.assertEquals(res.fsize(0), 4, ! "fsize(0) is %d, it should be 4." % res.fsize(0)) ! self.assertEquals(res.ftype(1), 25, ! "ftype(1) is %d, it should be 25." % res.ftype(1)) ! self.assertEquals(res.getisnull(0, 1), 0, ! "getisnull(0, 1) returned %d, it should be 0." % ! res.getisnull(0, 1)) ! self.assertEquals(res.getlength(1, 1), 18, ! "getlength(1, 1) is %d, it should be 19." % ! res.getlength(1, 1)) ! value = res.getvalue(1, 1) ! self.assertEquals(value, 'This is a test (2)', ! "getvalue(1, 1) returned incorrect results.") ! self.assertEquals(res.getlength(1, 1), len(value), ! "getlength(1, 1) does not match len(getvalue(1, 1)).") ! ! def CheckDeclarePgResult(self): ! res = self.cnx.query("""DECLARE pgres_cursor CURSOR FOR ! SELECT * FROM pgresult_test ! ORDER BY f1""") ! expected = [0, 'SELECT', None, 0, 0, None, None, 1, 2 ] ! self.CheckMemberValues(res, expected) ! self.failUnlessRaises(libpq.InterfaceError, res.fmod, 0) ! self.failUnlessRaises(libpq.InterfaceError, res.fname, 0) ! self.failUnlessRaises(libpq.InterfaceError, res.fnumber, "NoSuchName") ! self.failUnlessRaises(libpq.InterfaceError, res.fsize, 0) ! self.failUnlessRaises(libpq.InterfaceError, res.ftype, 0) ! self.failUnlessRaises(libpq.InterfaceError, res.getisnull, 0, 0) ! self.failUnlessRaises(libpq.InterfaceError, res.getlength, 0, 0) ! self.failUnlessRaises(libpq.InterfaceError, res.getvalue, 0, 0) ! ! def CheckBeginPgResult(self): ! res = self.cnx.query("BEGIN WORK") ! expected = [0, 'BEGIN', None, 0, 0, None, None, 1, 2 ] ! self.CheckMemberValues(res, expected) ! self.failUnlessRaises(libpq.InterfaceError, res.fmod, 0) ! self.failUnlessRaises(libpq.InterfaceError, res.fname, 0) ! self.failUnlessRaises(libpq.InterfaceError, res.fnumber, "NoSuchName") ! self.failUnlessRaises(libpq.InterfaceError, res.fsize, 0) ! self.failUnlessRaises(libpq.InterfaceError, res.ftype, 0) ! self.failUnlessRaises(libpq.InterfaceError, res.getisnull, 0, 0) ! self.failUnlessRaises(libpq.InterfaceError, res.getlength, 0, 0) ! self.failUnlessRaises(libpq.InterfaceError, res.getvalue, 0, 0) + def CheckSelectPgResult(self): + res = self.cnx.query("SELECT * FROM pgresult_test ORDER BY f1") + expected = [0, 'SELECT', None, 2, 4, None, None, 2, 1 ] + self.CheckMemberValues(res, expected) + self.assertEquals(res.fmod(0), -1, + "fmod(0) was %d, it should be -1." % res.fmod(0)) + self.assertEquals(res.fname(0), 'f1', + "fname(0) was '%s', it should be 'f1'." % + res.fname(0)) + self.assertEquals(res.fnumber('f2'), 1, + "fnumber('f2') was %d, it should be 1." % + res.fnumber('f2')) + self.assertEquals(res.fsize(0), 4, + "fsize(0) is %d, it should be 4." % res.fsize(0)) + self.assertEquals(res.ftype(1), 25, + "ftype(1) is %d, it should be 25." % res.ftype(1)) + self.assertEquals(res.getisnull(0, 1), 0, + "getisnull(0, 1) returned %d, it should be 0." % + res.getisnull(0, 1)) + self.assertEquals(res.getisnull(3, 1), 1, + "getisnull(3, 1) returned %d, it should be 1." % + res.getisnull(0, 1)) + self.assertEquals(res.getlength(2, 1), 19, + "getlength(2, 1) is %d, it should be 19." % + res.getlength(2, 1)) + value = res.getvalue(2, 1) + self.assertEquals(value, 'This is a test (3u)', + "getvalue(2, 1) returned incorrect results.") + self.assertEquals(res.getlength(2, 1), len(value), + "getlength(2, 1) does not match len(getvalue(2, 1)).") + + def CheckUpdatePgResult(self): + res = self.cnx.query("""UPDATE pgresult_test + SET f2 = 'This is a test (3u)' + WHERE f1 = 3""") + cs = 'UPDATE %s' % res.cmdTuples + expected = [0, cs, 1, 0, 0, None, None, 1, 3 ] + self.CheckMemberValues(res, expected) + self.failUnlessRaises(libpq.InterfaceError, res.fmod, 0) + self.failUnlessRaises(libpq.InterfaceError, res.fname, 0) + self.failUnlessRaises(libpq.InterfaceError, res.fnumber, "NoSuchName") + self.failUnlessRaises(libpq.InterfaceError, res.fsize, 0) + self.failUnlessRaises(libpq.InterfaceError, res.ftype, 0) + self.failUnlessRaises(libpq.InterfaceError, res.getisnull, 0, 0) + self.failUnlessRaises(libpq.InterfaceError, res.getlength, 0, 0) + self.failUnlessRaises(libpq.InterfaceError, res.getvalue, 0, 0) + + def CheckInsertPgResult(self): + res = self.cnx.query("""INSERT INTO pgresult_test + VALUES (1, 'This is a test (1)')""") + # The PgResult object's members can't be tested with CheckMemberValues() + # directly. Set up things so we can call CheckMember Values() + cs = 'INSERT %s %s' % (res.oidValue, res.cmdTuples) + expected = [0, cs, 1, 0, 0, res.oidValue, None, 1, 3 ] + self.assert_(res.oidValue != None, + "PgResult.oidValue is None, it shouldn't be None.") + self.CheckMemberValues(res, expected) + self.failUnlessRaises(libpq.InterfaceError, res.fmod, 0) + self.failUnlessRaises(libpq.InterfaceError, res.fname, 0) + self.failUnlessRaises(libpq.InterfaceError, res.fnumber, "NoSuchName") + self.failUnlessRaises(libpq.InterfaceError, res.fsize, 0) + self.failUnlessRaises(libpq.InterfaceError, res.ftype, 0) + self.failUnlessRaises(libpq.InterfaceError, res.getisnull, 0, 0) + self.failUnlessRaises(libpq.InterfaceError, res.getlength, 0, 0) + self.failUnlessRaises(libpq.InterfaceError, res.getvalue, 0, 0) + res = self.cnx.query("""INSERT INTO pgresult_test + VALUES (2, 'This is a test (2)')""") + res = self.cnx.query("""INSERT INTO pgresult_test + VALUES (3, 'This is a test (3)')""") + res = self.cnx.query("""INSERT INTO pgresult_test + VALUES (4, NULL)""") + + def CheckCreatePgResult(self): + query = "CREATE TABLE pgresult_test(f1 INT, f2 TEXT)" + res = self.cnx.query(query) + expected = [0, 'CREATE', None, 0, 0, None, None, 1, 2 ] + self.CheckMemberValues(res, expected) + self.failUnlessRaises(libpq.InterfaceError, res.fmod, 0) + self.failUnlessRaises(libpq.InterfaceError, res.fname, 0) + self.failUnlessRaises(libpq.InterfaceError, res.fnumber, "NoSuchName") + self.failUnlessRaises(libpq.InterfaceError, res.fsize, 0) + self.failUnlessRaises(libpq.InterfaceError, res.ftype, 0) + self.failUnlessRaises(libpq.InterfaceError, res.getisnull, 0, 0) + self.failUnlessRaises(libpq.InterfaceError, res.getlength, 0, 0) + self.failUnlessRaises(libpq.InterfaceError, res.getvalue, 0, 0) + + def CheckPgResult(self): + res = self.cnx.query("SELECT * FROM pg_database LIMIT 3") + expected = [0, 'SELECT', None, 7, 3, None, None, 2, 1 ] + self.CheckMemberValues(res, expected) + # Check that fname returns the expected results + cols = ['datname', 'datdba', 'encoding', 'datistemplate', + 'datallowconn', 'datlastsysoid'] + for i in range(len(cols)): + self.assertEquals(res.fname(i), cols[i], + "Name for field %d is %s, it should be %s." % + (i, res.fname(i), cols[i])) + self.assertEquals(res.fnumber(cols[i]), i, + "Number for field named %s is %d, it should be %d." % + (cols[i], res.fnumber(cols[i]), i)) + self.failUnlessRaises(ValueError, res.fmod, -1) + self.failUnlessRaises(ValueError, res.fmod, res.nfields) + self.failUnlessRaises(ValueError, res.fname, -1) + self.failUnlessRaises(ValueError, res.fname, res.nfields) + self.failUnlessRaises(ValueError, res.fnumber, "NoSuchName") + self.failUnlessRaises(ValueError, res.fsize, -1) + self.failUnlessRaises(ValueError, res.fsize, res.nfields) + self.failUnlessRaises(ValueError, res.ftype, -1) + self.failUnlessRaises(ValueError, res.ftype, res.nfields) + self.failUnlessRaises(ValueError, res.getisnull, -1, 0) + self.failUnlessRaises(ValueError, res.getisnull, res.ntuples, 0) + self.failUnlessRaises(ValueError, res.getisnull, 0, -1) + self.failUnlessRaises(ValueError, res.getisnull, 0, res.nfields) + self.failUnlessRaises(ValueError, res.getlength, -1, 0) + self.failUnlessRaises(ValueError, res.getlength, res.ntuples, 0) + self.failUnlessRaises(ValueError, res.getlength, 0, -1) + self.failUnlessRaises(ValueError, res.getlength, 0, res.nfields) + self.failUnlessRaises(ValueError, res.getvalue, -1, 0) + self.failUnlessRaises(ValueError, res.getvalue, res.ntuples, 0) + self.failUnlessRaises(ValueError, res.getvalue, 0, -1) + self.failUnlessRaises(ValueError, res.getvalue, 0, res.nfields) + def CheckSelectOfNonPrintableString(self): try: a = '\x01\x02\x03\x04' res = self.cnx.query("select %s as a" % repr(a)) *************** *** 284,287 **** --- 517,531 ---- TestSuite.addTest(PgResultTestCases("CheckSelectOfNonPrintableString")) + TestSuite.addTest(PgResultTestCases("CheckPgResult")) + TestSuite.addTest(PgResultTestCases("CheckCreatePgResult")) + TestSuite.addTest(PgResultTestCases("CheckInsertPgResult")) + TestSuite.addTest(PgResultTestCases("CheckUpdatePgResult")) + TestSuite.addTest(PgResultTestCases("CheckSelectPgResult")) + TestSuite.addTest(PgResultTestCases("CheckBeginPgResult")) + TestSuite.addTest(PgResultTestCases("CheckDeclarePgResult")) + TestSuite.addTest(PgResultTestCases("CheckFetchPgResult")) + TestSuite.addTest(PgResultTestCases("CheckClosePgResult")) + TestSuite.addTest(PgResultTestCases("CheckEndPgResult")) + TestSuite.addTest(PgResultTestCases("CheckDropPgResult")) runner = unittest.TextTestRunner() |
From: Billy G. A. <bal...@us...> - 2001-09-10 04:42:39
|
Update of /cvsroot/pypgsql/pypgsql/test/regression In directory usw-pr-cvs1:/tmp/cvs-serv24390/test/regression Modified Files: pgresult.py Log Message: 10SEP2001 bga Modified the test cases to reflect recent changes to pgversion.c Index: pgresult.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/test/regression/pgresult.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** pgresult.py 2001/09/07 00:19:26 1.3 --- pgresult.py 2001/09/10 04:42:36 1.4 *************** *** 34,37 **** --- 34,40 ---- # Date Ini Description | # --------- --- ------------------------------------------------------- | + # 09SEP2001 bga Modified tests to reflect changes to PgVersion object. | + # In particulare, a PgVersion object no longer has a | + # __dict__ attribute, but now acts as a mapping object. | # 06SEP2001 bga Completed the PgResult Member test cases, just have to | # do the PgResult Method test cases. | *************** *** 50,54 **** # Get a connection and a version string to be used globally. cnx = libpq.PQconnectdb("dbname=pypgsql") ! vstr = "%(major)d.%(minor)d" % cnx.version.__dict__ class PgResultMemberTestCases(unittest.TestCase): --- 53,57 ---- # Get a connection and a version string to be used globally. cnx = libpq.PQconnectdb("dbname=pypgsql") ! vstr = "%(major)d.%(minor)d" % cnx.version class PgResultMemberTestCases(unittest.TestCase): *************** *** 234,238 **** def setUp(self): self.cnx = libpq.PQconnectdb('dbname=pypgsql') ! self.vstr = "%(major)d.%(minor)d" % self.cnx.version.__dict__ self.cnx.query('begin work') --- 237,241 ---- def setUp(self): self.cnx = libpq.PQconnectdb('dbname=pypgsql') ! self.vstr = "%(major)d.%(minor)d" % self.cnx.version self.cnx.query('begin work') *************** *** 248,251 **** --- 251,255 ---- def CheckSelectOfNonPrintableString(self): try: + self.cnx.toggleShowQuery a = '\x01\x02\x03\x04' res = self.cnx.query("select %s as a" % repr(a)) |
From: Billy G. A. <bal...@us...> - 2001-09-10 04:42:39
|
Update of /cvsroot/pypgsql/pypgsql/test In directory usw-pr-cvs1:/tmp/cvs-serv24390/test Modified Files: PgSQLTestCases.py Log Message: 10SEP2001 bga Modified the test cases to reflect recent changes to pgversion.c Index: PgSQLTestCases.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/test/PgSQLTestCases.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** PgSQLTestCases.py 2001/09/08 16:12:51 1.13 --- PgSQLTestCases.py 2001/09/10 04:42:36 1.14 *************** *** 33,36 **** --- 33,43 ---- # Date Ini Description | # --------- --- ------------------------------------------------------- | + # 09SEP2001 bga Modified tests to reflect changes to PgVersion object. | + # In particulare, a PgVersion object no longer has a | + # __dict__ attribute, but now acts as a mapping object. | + # The coerce method of the PgVersion object will always | + # succeed, but will return a 'special' PgVersion Object | + # that contains any error information if the coersion | + # failed. | # 08SEP2001 gh Added more tests for PgVersion object. | # 03SEP2001 gh Added more checks for PgMoney methods. | *************** *** 261,265 **** self.cnx = PgSQL.connect(database='template1') self.cur = self.cnx.cursor() ! self.vstr = "%(major)d.%(minor)d" % self.cnx.version.__dict__ def tearDown(self): --- 268,272 ---- self.cnx = PgSQL.connect(database='template1') self.cur = self.cnx.cursor() ! self.vstr = "%(major)d.%(minor)d" % self.cnx.version def tearDown(self): *************** *** 432,438 **** v = string.split(self.cur.fetchone()[0])[1] self.cur.close() ! vstr = "%(major)d.%(minor)d" % self.cnx.version.__dict__ if self.cnx.version.level != 0: ! vstr = vstr + ".%(level)d" % self.cnx.version.__dict__ self.failUnlessEqual(v, vstr, 'SELECT version() says %s, cnx.version says %s' % --- 439,445 ---- v = string.split(self.cur.fetchone()[0])[1] self.cur.close() ! vstr = "%(major)d.%(minor)d" % self.cnx.version if self.cnx.version.level != 0: ! vstr = vstr + ".%(level)d" % self.cnx.version self.failUnlessEqual(v, vstr, 'SELECT version() says %s, cnx.version says %s' % *************** *** 455,466 **** self.failUnless(type(a) == type(b) == type(version), 'Coercion from float to PgVersion failed.') except StandardError, msg: self.fail(msg) - try: - a, b = coerce(version, '') - self.fail('Coercion from garbage string to PgVersion *should*\ - have failed.') - except TypeError, msg: - pass # expected def CheckExecuteWithSingleton(self): --- 462,470 ---- self.failUnless(type(a) == type(b) == type(version), 'Coercion from float to PgVersion failed.') + a, b = coerce(version, '7. 1.3') + self.failUnless(b.post70 == None, + 'Coercion from garbage string to PgVersion *should* have failed.') except StandardError, msg: self.fail(msg) def CheckExecuteWithSingleton(self): |
From: Billy G. A. <bal...@us...> - 2001-09-10 04:41:36
|
Update of /cvsroot/pypgsql/pypgsql In directory usw-pr-cvs1:/tmp/cvs-serv21787 Modified Files: pgversion.c Log Message: 10SEP2001 bga Fixed problem when comparing against a PgVersion object. The wanted behaviour was to convert the string (i.e. '7.1.3') or number (i.e. 70103) to a PgVersion object and compare them. Problems arise if the string or number can't be coerced into a PgVersion object. In this case, Python would ignore any excep- tions raised in ver_coerce and attempt coerce the PgVersion object into a string or number and compare the results. This would invariably be incorrect. In order to get the desired be- haviour, I had to 'trick' Python by having ver_coerce() always succeeded, even if the coerce to a PgVersion object failed. ver_coerce() would create a 'special' PgVersion object that contained the error information when the coercsion failed. PgVersion_cmp() recognizes the 'special' PgVersion object and raises the exception that actually occurred in ver_coerce(). NOTE: Using Python's builtin coerce() funtion to coerce an object to a PgVersion will always seem to succeed. You must check the resulting PgVersion object to see if an error occured. If the post70 attribute is None, then an error occured and the version attribute contains the error message. ---------------------------------------------------------------------- Index: pgversion.c =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pgversion.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** pgversion.c 2001/09/08 16:12:51 1.6 --- pgversion.c 2001/09/10 04:41:32 1.7 *************** *** 32,35 **** --- 32,55 ---- | Date Ini Description | | --------- --- ------------------------------------------------------- | + | 09SEP2001 bga Fixed the broken comparison function. This proved to | + | be a not so easy task since any errors set in the ex- | + | tensions module's coerce() function are ignored (unless | + | called by Python's builtin coerce() function). Python | + | will clear the error and try to convert the PgVersion | + | object to the other type if the coersion to PgVersion | + | fails. I do not want that to happen. If the object | + | can't be coerced to a PgVersion, then the comparison | + | does not make sense, so an exception should occur. To | + | get this behaviour required a bit sneaky-ness. See the | + | comments in the code for details. A concequence of | + | this change is that coerce will always succeed. I can | + | not see any way around this :-( | + | --- Having a __dict__ attribute and calling PyMember_Get() | + | in the PyVersion_getattr function causes dir() to do | + | strange things (like list members twice). I've removed | + | the __dict__ attribute and adding methods to emulate | + | a mapping object to PgVersion. A PgVersion object will | + | now act like a dictionary, so use version[key] instead | + | of version.__dict__[key]. | | 08SEP2001 gh Make PgVersion_New safe for arbitrary input strings. | | --- Make the repr method really return the version string. | *************** *** 74,77 **** --- 94,143 ---- } PgVersion; + /***********************************************************************\ + | Name: parseToken | + | | + | Synopsis: if (parseToken(token, result)) {...error handling...} | + | | + | Description: parseToken will extract an integer from token. If it | + | can't get an integer or if the token contains something | + | other than a number, raise an execption. | + | | + | Returns: 0 if successful, 1 if it failed to parse an integer. | + \***********************************************************************/ + + static int parseToken(char *token, long *result) + { + char *last; + + *result = strtol(token, &last, 0); + + if ((token == (char *)NULL) || + (*token == '\0') || + isspace(*token) || + (*last != 0)) + { + PyErr_SetString(PyExc_ValueError, + "Invalid format for PgVersion construction."); + return (1); + } + + return (0); + } + + /*--------------------------------------------------------------------------*/ + + static void PgVersion_dealloc(PgVersion *self) + { + Py_XDECREF(self->version); + Py_XDECREF(self->major); + Py_XDECREF(self->minor); + Py_XDECREF(self->patch); + Py_XDECREF(self->post70); + Py_XDECREF(self->value); + PyObject_DEL(self); + } + + /*--------------------------------------------------------------------------*/ + PyObject *PgVersion_New(char *version) { *************** *** 95,136 **** PyErr_SetString(PyExc_MemoryError, "Can't allocate memory in PgVersion_New()."); ! PyMem_Free(s); ! Py_XDECREF(self->version); ! Py_XDECREF(self); ! return NULL; } - /***************************************************************\ - | Parse out the version information from the version string. | - | The expected format is 'PostgreSQL M.m.p other information' | - | where M is the major number, m is the minor number and p is | - | the patch level. | - \***************************************************************/ ! (void)strtok_r(s, " \t", &save_ptr); ! vstr = strtok_r((char *)NULL, " \t", &save_ptr); ! /***************************************************************\ ! | We now have the version number (as M.m.p) in vstr. Parse it. | ! | Note: The patch level may not be present. | ! \***************************************************************/ save_ptr = (char *)NULL; ! token = strtok_r(vstr, ".", &save_ptr); ! if ((token == (char *)NULL) || (*token == 0)) ! goto parse_error; ! major = atol(token); ! ! token = strtok_r((char *)NULL, ".", &save_ptr); ! if ((token == (char *)NULL) || (*token == 0)) ! goto parse_error; ! minor = atol(token); ! token = strtok_r((char *)NULL, ".", &save_ptr); ! if ((token == (char *)NULL) || (*token == 0)) ! patch = 0; ! else ! patch = atol(token); value = (((major * 100) + minor) * 100) + patch; --- 161,217 ---- PyErr_SetString(PyExc_MemoryError, "Can't allocate memory in PgVersion_New()."); ! goto new_error; } ! self->major = self->minor = self->patch = (PyObject *)NULL; ! self->value = self->post70 = (PyObject *)NULL; ! /***************************************************************\ ! | Parse out the version information from the version string. | ! | The expected format is 'PostgreSQL M.m.p on ...' where M is | ! | the major number, m is the minor number and p is the patch | ! | level. | ! \***************************************************************/ ! major = minor = patch = value = 0; ! ! token = strtok_r(s, " \t", &save_ptr); ! if (strcmp(token, "PostgreSQL") != 0) ! { ! PyErr_SetString(PyExc_ValueError, ! "Ivalid format for PgVersion construction."); ! goto new_error; ! } ! ! vstr = strtok_r((char *)NULL, " \t", &save_ptr); ! ! token = strtok_r((char *)NULL, " \t", &save_ptr); ! if (strcmp(token, "on") != 0) ! { ! PyErr_SetString(PyExc_ValueError, ! "Ivalid format for PgVersion construction."); ! goto new_error; ! } ! ! /***************************************************************\ ! | We now have the version number (as M.m.p) in vstr. Parse it. | ! | Note: The minor number and patch level may not be present. | ! \***************************************************************/ save_ptr = (char *)NULL; ! token = strtok_r(vstr, ".", &save_ptr); ! if (parseToken(token, &major)) ! goto new_error; ! token = strtok_r((char *)NULL, ".", &save_ptr); ! if ((token != (char *)NULL) && (*token != '\0') && ! (parseToken(token, &minor))) ! goto new_error; ! ! token = strtok_r((char *)NULL, ".", &save_ptr); ! if ((token != (char *)NULL) && (*token != '\0') && ! (parseToken(token, &patch))) ! goto new_error; value = (((major * 100) + minor) * 100) + patch; *************** *** 141,163 **** self->value = Py_BuildValue("i", value); self->post70 = Py_BuildValue("i", ((value >= 70100) ? 1l : 0l)); ! ! PyMem_Free(s); } return (PyObject *)self; ! parse_error: PyMem_Free(s); ! PyErr_SetString(PyExc_ValueError, ! "Illegal format for PgVersion construction."); return (PyObject *)NULL; - } - - static void PgVersion_dealloc(PgVersion *self) - { - PyMem_Free(self->version); - PyMem_Free(self); } static PyObject *PgVersion_repr(PgVersion *self) { --- 222,241 ---- self->value = Py_BuildValue("i", value); self->post70 = Py_BuildValue("i", ((value >= 70100) ? 1l : 0l)); ! if (PyErr_Occurred()) ! goto new_error; } + PyMem_Free(s); + return (PyObject *)self; ! new_error: PyMem_Free(s); ! PgVersion_dealloc(self); return (PyObject *)NULL; } + /*--------------------------------------------------------------------------*/ + static PyObject *PgVersion_repr(PgVersion *self) { *************** *** 166,169 **** --- 244,249 ---- } + /*--------------------------------------------------------------------------*/ + static int ver_coerce(PyObject **l, PyObject **r) { *************** *** 180,184 **** return (1); } ! sprintf(vstr, "PostgreSQL %s Dummy Version", PyString_AsString(*r)); } else --- 260,264 ---- return (1); } ! sprintf(vstr, "PostgreSQL %s on Dummy", PyString_AsString(*r)); } else *************** *** 188,200 **** if ((vstr = PyMem_Malloc(128)) == (char *)NULL) { ! PyErr_SetString(PyExc_MemoryError, ! "Can't allocate memory in PgVersion_coerce()."); return (1); } ! if (PyInt_Check(*r)) { value = PyInt_AsLong(*r); } else if (PyLong_Check(*r)) { --- 268,287 ---- if ((vstr = PyMem_Malloc(128)) == (char *)NULL) { ! PyErr_NoMemory(); return (1); } ! if (PgInt2_Check(*r)) ! { ! value = PgInt2_AsLong((PgInt2Object *)(*r)); ! } ! else if (PyInt_Check(*r)) { value = PyInt_AsLong(*r); } + if (PgInt8_Check(*r)) + { + value = PgInt8_AsLong((PgInt8Object *)(*r)); + } else if (PyLong_Check(*r)) { *************** *** 214,238 **** } ! sprintf(vstr, "PostgreSQL %ld.%ld.%ld Dummy Version", (value / 10000), ((value / 100) % 100), (value % 100)); } s = (PgVersion *)PgVersion_New(vstr); PyMem_Free(vstr); ! if (PyErr_Occurred() != (PyObject *)NULL) { ! if (s != (PgVersion *)NULL) ! PyObject_Del(s); return (1); } *r = (PyObject *)s; ! ! Py_INCREF(*l); return (0); } static int PgVersion_coerce(PyObject **l, PyObject **r) { --- 301,362 ---- } ! if (PyErr_Occurred()) ! goto coerce_error; ! ! sprintf(vstr, "PostgreSQL %ld.%ld.%ld on Dummy", (value / 10000), ((value / 100) % 100), (value % 100)); } s = (PgVersion *)PgVersion_New(vstr); + if (PyErr_Occurred()) + { + Py_XDECREF(s); + goto coerce_error; + } + PyMem_Free(vstr); ! *r = (PyObject *)s; ! Py_XINCREF(*l); ! ! return (0); ! ! coerce_error: ! /*******************************************************************\ ! | A bit of explaination is in order here. | ! | | ! | Python will ignore any exceptions raised from the call to coerce | ! | types. In order to work around this problem, coerce will always | ! | convert the other type to a PgVersion object, but if an error oc- | ! | curs, that object will contain the saved error information. When | ! | the compare function for PgVersion is call, it will re-raise the | ! | saved exception. | ! \*******************************************************************/ ! ! PyMem_Free(vstr); ! ! s = (PgVersion *)PyObject_New(PgVersion, &PgVersion_Type); ! if (s == (PgVersion *)NULL) ! return (1); ! ! PyErr_Fetch(&s->major, &s->version, &s->minor); ! s->value = Py_BuildValue("i", -1); ! s->patch = Py_None; Py_INCREF(Py_None); ! s->post70 = Py_None; Py_INCREF(Py_None); ! ! if (PyErr_Occurred()) { ! PgVersion_dealloc(s); return (1); } *r = (PyObject *)s; ! Py_XINCREF(*l); return (0); } + /*--------------------------------------------------------------------------*/ + static int PgVersion_coerce(PyObject **l, PyObject **r) { *************** *** 243,272 **** } - static PyNumberMethods ver_as_number = { - (binaryfunc)NULL, /* nb_add */ - (binaryfunc)NULL, /* nb_subtract */ - (binaryfunc)NULL, /* nb_multiply */ - (binaryfunc)NULL, /* nb_divide */ - (binaryfunc)NULL, /* nb_remainder */ - (binaryfunc)NULL, /* nb_divmod */ - (ternaryfunc)NULL, /* nb_power */ - (unaryfunc)NULL, /* nb_negative */ - (unaryfunc)NULL, /* nb_positive */ - (unaryfunc)NULL, /* nb_absolute */ - (inquiry)NULL, /* nb_nonzero */ - (unaryfunc)NULL, /* nb_invert */ - (binaryfunc)NULL, /* nb_lshift */ - (binaryfunc)NULL, /* nb_rshift */ - (binaryfunc)NULL, /* nb_and */ - (binaryfunc)NULL, /* nb_xor */ - (binaryfunc)NULL, /* nb_or */ - (coercion)PgVersion_coerce, /* nb_coerce */ - (unaryfunc)NULL, /* nb_int */ - (unaryfunc)NULL, /* nb_long */ - (unaryfunc)NULL, /* nb_float */ - (unaryfunc)NULL, /* nb_oct */ - (unaryfunc)NULL /* nb_hex */ - }; - /*--------------------------------------------------------------------------*/ --- 367,370 ---- *************** *** 282,321 **** }; static PyObject *PgVersion_getattr(PgVersion *self, char *attr) { ! if (!strcmp(attr, "__dict__")) { ! PyObject *dict; ! if ((dict = PyDict_New()) == (PyObject *)NULL) ! return NULL; ! PyDict_SetItemString(dict, "version", self->version); ! PyDict_SetItemString(dict, "major", self->major); ! PyDict_SetItemString(dict, "minor", self->minor); ! PyDict_SetItemString(dict, "level", self->patch); ! PyDict_SetItemString(dict, "post70", self->post70); ! if (PyErr_Occurred() != (PyObject *)NULL) ! { ! Py_XDECREF(dict); ! return (PyObject *)NULL; ! } ! return dict; } ! else ! return PyMember_Get((char *)self, PgVersion_members, attr); } /*--------------------------------------------------------------------------*/ static int PgVersion_cmp(PgVersion *s, PgVersion *o) { ! return (s->value < o->value) ? -1 : (s->value > o->value) ? 1 : 0; } /*--------------------------------------------------------------------------*/ static char PgVersion_Type_Doc[] = "This is the type of PgVersion objects"; --- 380,510 ---- }; + /*--------------------------------------------------------------------------*/ + static PyObject *PgVersion_getattr(PgVersion *self, char *attr) { ! return PyMember_Get((char *)self, PgVersion_members, attr); ! } ! ! /*--------------------------------------------------------------------------*/ ! ! static int PgVersion_setattr(PgVersion *self, char* attr, PyObject *value) ! { ! if (value == NULL) { ! PyErr_SetString(PyExc_AttributeError, ! "can't delete PgVersion attributes"); ! return -1; ! } ! return PyMember_Set((char *)self, PgVersion_members, attr, value); ! } ! /*--------------------------------------------------------------------------*/ ! static int PgVersion_length(PgVersion *self) ! { ! return 5; ! } ! /*--------------------------------------------------------------------------*/ ! static PyObject *PgVersion_getitem(PgVersion *self, PyObject *attr) ! { ! char *key; ! PyObject *value; ! ! if (!PyArg_Parse(attr, "s", &key)) ! { ! return (PyObject *)NULL; } ! ! value = PyMember_Get((char *)self, PgVersion_members, key); ! if (value == (PyObject *)NULL) ! { ! PyErr_SetString(PyExc_KeyError, key); ! } ! ! return value; } + + /*--------------------------------------------------------------------------*/ + static int PgVersion_setitem(PgVersion *self, PyObject *attr, PyObject *value) + { + if (value == NULL) + { + PyErr_SetString(PyExc_AttributeError, + "can't delete PgVersion attributes"); + } + else + { + PyErr_SetString(PyExc_AttributeError, + "PgVersion attributes are read-only"); + } + return -1; + } + /*--------------------------------------------------------------------------*/ static int PgVersion_cmp(PgVersion *s, PgVersion *o) { ! long left = PyInt_AS_LONG(s->value); ! long right = PyInt_AS_LONG(o->value); ! ! /*******************************************************************\ ! | Check to see if one of the PgVersion objects contain error infor- | ! | mation. If it does, restore the error condition. | ! \*******************************************************************/ ! ! if (left < 0 || right < 0) ! { ! PgVersion *t = (left < 0 ? s : o); ! ! PyErr_Restore(t->major, t->version, t->minor); ! Py_XINCREF(t->major); ! Py_XINCREF(t->version); ! Py_XINCREF(t->minor); ! } ! return (left < right) ? -1 : (left > right) ? 1 : 0; } /*--------------------------------------------------------------------------*/ + static PyMappingMethods ver_as_mapping = { + (inquiry)PgVersion_length, /*mp_length*/ + (binaryfunc)PgVersion_getitem, /*mp_subscript*/ + (objobjargproc)PgVersion_setitem, /*mp_ass_subscript*/ + }; + + /*--------------------------------------------------------------------------*/ + + static PyNumberMethods ver_as_number = { + (binaryfunc)NULL, /* nb_add */ + (binaryfunc)NULL, /* nb_subtract */ + (binaryfunc)NULL, /* nb_multiply */ + (binaryfunc)NULL, /* nb_divide */ + (binaryfunc)NULL, /* nb_remainder */ + (binaryfunc)NULL, /* nb_divmod */ + (ternaryfunc)NULL, /* nb_power */ + (unaryfunc)NULL, /* nb_negative */ + (unaryfunc)NULL, /* nb_positive */ + (unaryfunc)NULL, /* nb_absolute */ + (inquiry)NULL, /* nb_nonzero */ + (unaryfunc)NULL, /* nb_invert */ + (binaryfunc)NULL, /* nb_lshift */ + (binaryfunc)NULL, /* nb_rshift */ + (binaryfunc)NULL, /* nb_and */ + (binaryfunc)NULL, /* nb_xor */ + (binaryfunc)NULL, /* nb_or */ + (coercion)PgVersion_coerce, /* nb_coerce */ + (unaryfunc)NULL, /* nb_int */ + (unaryfunc)NULL, /* nb_long */ + (unaryfunc)NULL, /* nb_float */ + (unaryfunc)NULL, /* nb_oct */ + (unaryfunc)NULL /* nb_hex */ + }; + + /*--------------------------------------------------------------------------*/ + static char PgVersion_Type_Doc[] = "This is the type of PgVersion objects"; *************** *** 329,338 **** (printfunc)NULL, /* tp_print */ (getattrfunc)PgVersion_getattr, /* tp_getattr */ ! (setattrfunc)NULL, /* tp_setattr */ (cmpfunc)PgVersion_cmp, /* tp_compare */ (reprfunc)PgVersion_repr, /* tp_repr */ &ver_as_number, /* tp_as_number */ NULL, /* tp_as_sequence */ ! NULL, /* tp_as_mapping */ (hashfunc)NULL, /* tp_hash */ (ternaryfunc)NULL, /* tp_call */ --- 518,527 ---- (printfunc)NULL, /* tp_print */ (getattrfunc)PgVersion_getattr, /* tp_getattr */ ! (setattrfunc)PgVersion_setattr, /* tp_setattr */ (cmpfunc)PgVersion_cmp, /* tp_compare */ (reprfunc)PgVersion_repr, /* tp_repr */ &ver_as_number, /* tp_as_number */ NULL, /* tp_as_sequence */ ! &ver_as_mapping, /* tp_as_mapping */ (hashfunc)NULL, /* tp_hash */ (ternaryfunc)NULL, /* tp_call */ |
From: Gerhard H?r. <gha...@us...> - 2001-09-08 16:12:54
|
Update of /cvsroot/pypgsql/pypgsql In directory usw-pr-cvs1:/tmp/cvs-serv9865 Modified Files: pgversion.c Log Message: 08SEP2001 gh - Made PgVersion_New safe for arbitrary input strings. - Made PgVersion's repr method really return the version string. - Added tests for PgVersion object. Index: pgversion.c =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pgversion.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** pgversion.c 2001/09/06 04:42:21 1.5 --- pgversion.c 2001/09/08 16:12:51 1.6 *************** *** 32,35 **** --- 32,37 ---- | Date Ini Description | | --------- --- ------------------------------------------------------- | + | 08SEP2001 gh Make PgVersion_New safe for arbitrary input strings. | + | --- Make the repr method really return the version string. | | 06SEP2001 bga Initialize a variable (value) in ver_coerce() to quite | | an erroneous gcc warning message. | *************** *** 75,79 **** { PgVersion *self; ! char *v1, *v2, *n1, *n2; long major, minor, patch, value; --- 77,84 ---- { PgVersion *self; ! char *s; /* writeable temporary copy of version string */ ! char *vstr; /* The version number from the version string */ ! char *token; /* parsed token */ ! char *save_ptr; /* saves strtok_r state for subsequent calls */ long major, minor, patch, value; *************** *** 82,105 **** if (self) { ! v1 = v2 = (char *)NULL; ! n1 = n2 = (char *)NULL; self->version = Py_BuildValue("s", version); ! v1 = (char *)PyMem_Strdup(version); ! if ((self->version == (PyObject *)NULL) || (v1 == (char *)NULL)) { PyErr_SetString(PyExc_MemoryError, "Can't allocate memory in PgVersion_New()."); ! PyMem_Free(v1); ! PyMem_Free(self->version); Py_XDECREF(self); return NULL; } ! (void)strtok_r(v1, " \t", &n1); /* "PostgreSQL" */ ! v2 = strtok_r((char *)NULL, " \t", &n1); /* version */ ! major = atol(strtok_r(v2, ".", &n2)); ! minor = atol(strtok_r((char *)NULL, ".", &n2)); ! patch = atol(strtok_r((char *)NULL, ".", &n2)); value = (((major * 100) + minor) * 100) + patch; self->major = Py_BuildValue("i", major); self->minor = Py_BuildValue("i", minor); --- 87,139 ---- if (self) { ! save_ptr = (char *)NULL; self->version = Py_BuildValue("s", version); ! s = (char *)PyMem_Strdup(version); ! if ((self->version == (PyObject *)NULL) || (s == (char *)NULL)) { PyErr_SetString(PyExc_MemoryError, "Can't allocate memory in PgVersion_New()."); ! PyMem_Free(s); ! Py_XDECREF(self->version); Py_XDECREF(self); return NULL; } ! /***************************************************************\ ! | Parse out the version information from the version string. | ! | The expected format is 'PostgreSQL M.m.p other information' | ! | where M is the major number, m is the minor number and p is | ! | the patch level. | ! \***************************************************************/ ! ! (void)strtok_r(s, " \t", &save_ptr); ! ! vstr = strtok_r((char *)NULL, " \t", &save_ptr); ! ! /***************************************************************\ ! | We now have the version number (as M.m.p) in vstr. Parse it. | ! | Note: The patch level may not be present. | ! \***************************************************************/ ! ! save_ptr = (char *)NULL; ! ! token = strtok_r(vstr, ".", &save_ptr); ! if ((token == (char *)NULL) || (*token == 0)) ! goto parse_error; ! major = atol(token); ! ! token = strtok_r((char *)NULL, ".", &save_ptr); ! if ((token == (char *)NULL) || (*token == 0)) ! goto parse_error; ! minor = atol(token); ! ! token = strtok_r((char *)NULL, ".", &save_ptr); ! if ((token == (char *)NULL) || (*token == 0)) ! patch = 0; ! else ! patch = atol(token); ! value = (((major * 100) + minor) * 100) + patch; + self->major = Py_BuildValue("i", major); self->minor = Py_BuildValue("i", minor); *************** *** 107,114 **** self->value = Py_BuildValue("i", value); self->post70 = Py_BuildValue("i", ((value >= 70100) ? 1l : 0l)); ! PyMem_Free(v1); } return (PyObject *)self; } --- 141,155 ---- self->value = Py_BuildValue("i", value); self->post70 = Py_BuildValue("i", ((value >= 70100) ? 1l : 0l)); ! ! PyMem_Free(s); } return (PyObject *)self; + + parse_error: + PyMem_Free(s); + PyErr_SetString(PyExc_ValueError, + "Illegal format for PgVersion construction."); + return (PyObject *)NULL; } *************** *** 121,125 **** static PyObject *PgVersion_repr(PgVersion *self) { ! return Py_BuildValue("s", self->version); } --- 162,167 ---- static PyObject *PgVersion_repr(PgVersion *self) { ! Py_INCREF(self->version); ! return (PyObject *)(self->version); } |
From: Gerhard H?r. <gha...@us...> - 2001-09-08 16:12:54
|
Update of /cvsroot/pypgsql/pypgsql/test In directory usw-pr-cvs1:/tmp/cvs-serv9865/test Modified Files: PgSQLTestCases.py Log Message: 08SEP2001 gh - Made PgVersion_New safe for arbitrary input strings. - Made PgVersion's repr method really return the version string. - Added tests for PgVersion object. Index: PgSQLTestCases.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/test/PgSQLTestCases.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** PgSQLTestCases.py 2001/09/06 03:58:13 1.12 --- PgSQLTestCases.py 2001/09/08 16:12:51 1.13 *************** *** 33,36 **** --- 33,37 ---- # Date Ini Description | # --------- --- ------------------------------------------------------- | + # 08SEP2001 gh Added more tests for PgVersion object. | # 03SEP2001 gh Added more checks for PgMoney methods. | # 29JUL2001 bga Added test to check for correct handling of non-print- | *************** *** 439,443 **** except StandardError, msg: self.fail(msg) ! def CheckExecuteWithSingleton(self): """Test execute() with a singleton string as the parameter.""" --- 440,467 ---- except StandardError, msg: self.fail(msg) ! ! try: ! version = self.cnx.version ! a, b = coerce(version, '7.3.2') ! self.failUnless(type(a) == type(b) == type(version), ! 'Coercion from string to PgVersion failed.') ! a, b = coerce(version, 80205) ! self.failUnless(type(a) == type(b) == type(version), ! 'Coercion from int to PgVersion failed.') ! a, b = coerce(version, 80206L) ! self.failUnless(type(a) == type(b) == type(version), ! 'Coercion from long to PgVersion failed.') ! a, b = coerce(version, 80207.0) ! self.failUnless(type(a) == type(b) == type(version), ! 'Coercion from float to PgVersion failed.') ! except StandardError, msg: ! self.fail(msg) ! try: ! a, b = coerce(version, '') ! self.fail('Coercion from garbage string to PgVersion *should*\ ! have failed.') ! except TypeError, msg: ! pass # expected ! def CheckExecuteWithSingleton(self): """Test execute() with a singleton string as the parameter.""" |