From: Billy G. A. <bal...@us...> - 2002-12-01 04:59:31
|
Update of /cvsroot/pypgsql/pypgsql In directory sc8-pr-cvs1:/tmp/cvs-serv16107 Modified Files: Announce README libpqmodule.c pg_types.h Log Message: 30NOV2002 bga Updated the test cases to account for changes in PostgreSQL 7.3. 28NOV2002 bga Fixed changed PG_TIMESTAMP oid, added PG_TIMESTAMPTZ and PG_REFCURSOR oids. [Bug #845360] | --- Reference cursors are now type-casted into cursor objects. 27NOV2002 bga Completed the emulation of a String object for the PgBytea and PgOther classes. This corrects several problems with PgBytea concerning comparisons, using PgBytea types as keys in dictionaries, etc. Index: Announce =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/Announce,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** Announce 27 Oct 2002 05:10:43 -0000 1.19 --- Announce 1 Dec 2002 04:59:24 -0000 1.20 *************** *** 1,6 **** ! Announce: pyPgSQL - Version 2.3 beta 1 is released. =========================================================================== ! pyPgSQL v2.3 beta 1 has been released. It is available at http://pypgsql.sourceforge.net. --- 1,6 ---- ! Announce: pyPgSQL - Version 2.3 is released. =========================================================================== ! pyPgSQL v2.3 has been released. It is available at http://pypgsql.sourceforge.net. *************** *** 14,23 **** 2.0 or later. ! It was tested with PostgreSQL 7.0.3, 7.1.3, 7.2.2, 7.3 beta 2, Python 2.0.1, ! 2.1.3 and 2.2.2. ! Note: It is highly recommended that you use PostgreSQL 7.1 or later and Python ! 2.1 or later. If you want to use PostgreSQL Large Objects under Python 2.2.x, ! you *must* use Python 2.2.2, because of a bug in earlier 2.2 versions. Project homepages: --- 14,24 ---- 2.0 or later. ! It was tested with PostgreSQL 7.0.3, 7.1.3, 7.2.2, 7.3, Python 2.0.1, 2.1.3 ! and 2.2.2. ! Note: It is highly recommended that you use PostgreSQL 7.2 or later and ! Python 2.1 or later. If you want to use PostgreSQL Large Objects ! under Python 2.2.x, you *must* use Python 2.2.2, because of a bug in ! earlier 2.2 versions. Project homepages: *************** *** 26,51 **** Python: http://www.python.org/ ! This is the first time we release a beta of pyPgSQL. While there didn't change ! much under the hood, the build process was completely rewritten, so pyPgSQL ! should now build out of the box on most popular platforms. For you, this means ! that a "python setup.py build" will now hopefully just work. And for us, this ! means we'll have to answer less boring support questions :-) ! These platforms were tested and will build out of the box (of course, more ! testing won't hurt): UnixWare 7/OpenUNIX 8, Windows native, Cgwin, FreeBSD ! 4.7, Redhat Linux 7.3, SuSE Linux 7.3, Debian Linux 3.0. ! The build process is also designed to work with these platforms, but they ! could not be tested in real life (please do so, if you can!): Mandrake ! Linux, NetBSD, OpenBSD, MacOS X. If your platform isn't supported out of the box, you can edit a ! setup.config file to configure the build process. Patches for supporting ! additional platforms are more than welcome. Look into setup.py for how to ! do it. ! The other big change is that Gerhard finally gave up on getting more feedback ! on his Unicode patch and merged it into the pyPgSQL 2.x line. Hey, if it did ! work for Linux 2.4, it can work for us, too <0.7 wink>. Using Unicode works like this: --- 27,52 ---- Python: http://www.python.org/ ! While there didn't change much under the hood, the build process was ! completely rewritten, so pyPgSQL should now build out of the box on most ! popular platforms. For you, this means that a "python setup.py build" will ! now hopefully just work. And for us, this means we'll have to answer less ! boring support questions :-) ! These platforms were tested and will build out of the box (of course, ! more testing won't hurt): UnixWare 7/OpenUNIX 8, Windows native, Cgwin, ! FreeBSD 4.7, Redhat Linux 7.3, SuSE Linux 7.3, Debian Linux 3.0. ! The build process is also designed to work with these platforms, but ! they could not be tested in real life (please do so, if you can!): ! Mandrake Linux, NetBSD, OpenBSD, MacOS X. If your platform isn't supported out of the box, you can edit a ! setup.config file to configure the build process. Patches for ! supporting additional platforms are more than welcome. Look into ! setup.py for how to do it. ! The other big change is that Gerhard finally gave up on getting more ! feedback on his Unicode patch and merged it into the pyPgSQL 2.x line. ! Hey, if it did work for Linux 2.4, it can work for us, too <0.7 wink>. Using Unicode works like this: *************** *** 67,70 **** --- 68,101 ---- # doing it in code. + Support for reference cursors was added. Since PostgreSQL 7.2, you could + create cursors in PL/pgSQL and pass a reference to the open cursor back to + the client. PgSQL will now cast those referenced cursors into a Cursor + object that can be used to fetch the results in the cursor. For example + (assuming that mmYearInfo() returns a reference curosr): + + $ python + Python 2.2.2 (#7, Nov 27 2002, 17:10:05) [C] on openunix8 + Type "help", "copyright", "credits" or "license" for more information. + >>> from pyPgSQL import PgSQL + >>> cx = PgSQL.connect(database='esi') + >>> cu = cx.cursor() + >>> cu.callproc('mmYearInfo') + >>> rs = cu.fetchone() + >>> rs + [<pyPgSQL.PgSQL.Cursor instance at 0x818495c>] + >>> c = rs[0] + >>> for i in c.description: + ... print i + ... + ['model_year', varchar, 4, 8, None, None, None, 0] + ['mktg_div_name', varchar, 50, 54, None, None, None, 0] + ['model_desc', varchar, 50, 54, None, None, None, 0] + ['book_types', varchar, 50, 54, None, None, None, 0] + ['vehicle_syskey', integer, 4, 4, None, None, None, 0] + >>> r = c.fetchone() + >>> r + ['2003', 'Buick', 'Century', '1;8;9', 2211] + >>> + --------------------------------------------------------------------------- ChangeLog: *************** *** 74,78 **** ================================= ! The following source code files were added to Version 2.3 beta 1 of pyPgSQL: setup.config - Part of the changed distutils-based build process. --- 105,109 ---- ================================= ! The following source code files were added to Version 2.3 of pyPgSQL: setup.config - Part of the changed distutils-based build process. *************** *** 95,99 **** Changes to README ----------------- ! * Updates for 2.3b1. * Converted the whole document into reStructuredText, so we can easily built a HTML version using docutils (http://docutils.sf.net/). --- 126,130 ---- Changes to README ----------------- ! * Updates for 2.3rc1. * Converted the whole document into reStructuredText, so we can easily built a HTML version using docutils (http://docutils.sf.net/). *************** *** 106,109 **** --- 137,152 ---- Changes to PgSQL.py ------------------- + * Fixed changed PG_TIMESTAMP oid, added PG_TIMESTAMPTZ and PG_REFCURSOR oids. + * Reference cursors are now type-casted into cursor objects. + * Completed the emulation of a String object for the PgBytea and PgOther + classes. This corrects several problems with PgBytea concerning compari- + sons, using PgBytea types as keys in dictionaries, etc. + * Added the __hash__ function to the PgNumeric class. Cleaned up the code + in PgNumeric class and made some small improvments to it. + * Added the PgArray class. This is a wrapper around a Python list and is + used for all PostgreSQL arrays. This change was made so that lists and + tuples no longer have a special meaning in the Cursor.execute() method. + * Changed the quoting methods defined in the various classes defining + PostgreSQL support types to __quote__. * Merged the Unicode patch. pyPgSQL now has full Unicode support. * Added support for the INTERVAL type. *************** *** 127,142 **** Changes to pglargeobject.c -------------------------- ! * Made the 'closed' attribute of PgLargeObject an int instead of a ! long. Changes to libpqmodule.c: ------------------------- * Fixed the format string of ParseTuple in libPQbool_FromInt. This closes a bug that appeared on Linux/Alpha (#625121). ! ! Changes to PgSQLTestcases: ! -------------------------- ! * Don't check for the obsolete displaysize field in ! cursor.description. Also don't check the backend encoding. Multiple files --- 170,191 ---- Changes to pglargeobject.c -------------------------- ! * Made the 'closed' attribute of PgLargeObject an int instead of a long. Changes to libpqmodule.c: ------------------------- + * Fixed the changed PG_TIMESTAMP oid, added PG_TIMESTAMPTZ and PG_REFCURSOR + oids. [Bug #845360] * Fixed the format string of ParseTuple in libPQbool_FromInt. This closes a bug that appeared on Linux/Alpha (#625121). ! ! Changes to pgversion.c: ! ----------------------- ! * Changed pgversion to recognize release canidate versions of PostgreSQL. ! ! Changes to PgSQL test cases: ! ---------------------------- ! * Updated test cases to allow for changes in PostgreSQL 7.3. ! * Don't check for the obsolete displaysize field in cursor.description. ! Also don't check the backend encoding. Multiple files Index: README =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/README,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** README 3 Nov 2002 20:39:55 -0000 1.27 --- README 1 Dec 2002 04:59:24 -0000 1.28 *************** *** 203,208 **** Temporal Types: ! PG_DATE, PG_TIME, PG_TIMESTAMP, PG_INTERVAL, PG_ABSTIME, ! PG_RELTIME, PG_TINTERVAL Logical (boolean) Type: --- 203,208 ---- Temporal Types: ! PG_DATE, PG_TIME, PG_TIMESTAMP, PG_TIMESTAMPTX, PG_INTERVAL, ! PG_ABSTIME, PG_RELTIME, PG_TINTERVAL Logical (boolean) Type: *************** *** 219,222 **** --- 219,226 ---- PG_INET, PG_CIDR + Misc. Types: + + PG_REFCURSOR + The following constants are defined for use by the libpq module and have no direct relationship to constants in PostgreSQL's C API: *************** *** 1547,1550 **** --- 1551,1558 ---- result set (or nothing). + NOTE: Beginning with PostgreSQL 7.2, it is possible to return a refer- + ence to a cursor from PL/pgSQL. PgSQL will create a new Cursor + object for the referenced cursor that is returned. + 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 *************** *** 1579,1587 **** 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(). ! PostgreSQL arrays are no longer (directly) represented by Python lists. Ths means that lists and tuples are not longer treated specially by ! Cursor.execute(). This resolve a problem of using the IN SQL syntax with ! Cursor.execute(). For example, the following statement will now work: Cursor.execute('select * from table where column1 in %s', ((1, 3, 4),)) --- 1587,1595 ---- 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(). ! ---------- PostgreSQL arrays are no longer (directly) represented by Python lists. Ths means that lists and tuples are not longer treated specially by ! Cursor.execute(). This resolves a problem of using the IN SQL syntax with ! Cursor.execute(). For example, the following statement will now work: Cursor.execute('select * from table where column1 in %s', ((1, 3, 4),)) *************** *** 1599,1605 **** You can also build a PostgreSQL array by creating an empty PgArray instance and populating it using the various list methods (.append(), .insert(), etc.). ! When working with PostgreSQL large object, you MUST be in a transaction. The code will try to ensure that a transcation is active while working with large object (i.e. lo_open will start a transaction if necessary. lo_close will end the transaction if it determines that lo_open started one.) --- 1607,1643 ---- You can also build a PostgreSQL array by creating an empty PgArray instance and populating it using the various list methods (.append(), .insert(), etc.). ! ---------- When working with PostgreSQL large object, you MUST be in a transaction. The code will try to ensure that a transcation is active while working with large object (i.e. lo_open will start a transaction if necessary. lo_close will end the transaction if it determines that lo_open started one.) + ---------- + Beginning with PostgreSQL 7.2, you can now create a cursor in PL/pgSQL and + return a reference to that cursor. PgSQL will transform the reference to the + created cursor into a Cursor object that can be used to fetch the results of + the cursor. For example (assuming that mmYearInfo returns a reference curosr): + + $ python + Python 2.2.2 (#7, Nov 27 2002, 17:10:05) [C] on openunix8 + Type "help", "copyright", "credits" or "license" for more information. + >>> from pyPgSQL import PgSQL + >>> cx = PgSQL.connect(database='esi') + >>> cu = cx.cursor() + >>> cu.callproc('mmYearInfo') + >>> rs = cu.fetchone() + >>> rs + [<pyPgSQL.PgSQL.Cursor instance at 0x818495c>] + >>> c = rs[0] + >>> for i in c.description: + ... print i + ... + ['model_year', varchar, 4, 8, None, None, None, 0] + ['mktg_div_name', varchar, 50, 54, None, None, None, 0] + ['model_desc', varchar, 50, 54, None, None, None, 0] + ['book_types', varchar, 50, 54, None, None, None, 0] + ['vehicle_syskey', integer, 4, 4, None, None, None, 0] + >>> r = c.fetchone() + >>> r + ['2003', 'Buick', 'Century', '1;8;9', 2211] + >>> + Index: libpqmodule.c =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/libpqmodule.c,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** libpqmodule.c 19 Oct 2002 14:30:00 -0000 1.25 --- libpqmodule.c 1 Dec 2002 04:59:24 -0000 1.26 *************** *** 32,35 **** --- 32,37 ---- | Date Ini Description | | --------- --- ------------------------------------------------------- | + | 28NOV2002 bga Fixed changed PG_TIMESTAMP oid, added PG_TIMESTAMPTZ | + | and PG_REFCURSOR oids. [Bug #845360] | | 19OCT2002 gh Fixed the format string of ParseTuple in | | libPQbool_FromInt. This closes a bug that appeared on | *************** *** 41,119 **** | numbers [Bug #510244]. | | 21JAN2002 bga Applied patch by Chris Bainbridge [Patch #505941]. | ! | 13OCT2001 bga Added support for the pickling of libpq objects. In | ! | particular, for PgVersion and PgConnection objects. | ! | --- Added a cntructor method for PgVersion objects. | ! | 01OCT2001 bga Changed all new style comments to original style. | ! | 30SEP2001 bga Change PgQuoteString and PgQuoteByta so that unsigned | ! | char pointers are used instead of signed char pointers. | ! | 27SEP2001 bga Added different quoting/escaping if the result is to be | ! | used as part of a PostgreSQL array. | ! | 26SEP2001 bga Change the quoting/escaping helper routines so that | ! | they also escape the double quote character. | ! | --- Added a PgLargeObject constructor. | ! | 24SEP2001 bga Added support routines to: | ! | 1. quote strings (PgQuoteString). | ! | 2. quote bytea strings (PgQuoteBytea). | ! | 3. un-quote bytea strings (PgUnQuoteBytea). | ! | Bytea strings can have embedded NUL values. | ! | 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. | ! | 11AUG2001 bga Moved code for PgLargeObject, PgNotify, PgConnection, | ! | and PgResult to there own files. This was done to make | ! | maintenance easier. | ! | 03AUG2001 bga Added code to correctly identify large object in Post- | ! | greSQL 7.1.x and above. [Bug# 444563] | ! | --- Re-implemented the PgVer object in C (as PgVersion) and | ! | moved it the PgConnection object in libpq. This allows | ! | PostgreSQL version specific code (i.e. different large | ! | object handling in PostgreSQL 7.1 and above) to be used | ! | without compiling for a specific version. | ! | --- Change code so that memory used to duplicate strings is | ! | allocated from Python's heap. | ! | --- Fixed some possible memory leaks. | ! | 29JUL2001 bga Added code that will fixup the escapes seqenced sent | ! | from Python for non-printable characters into a form | ! | that PostgreSQL will accept. This fixes a bug reported | ! | by Greg Brauer <gr...@wi...>. | ! | 06JUN2001 bga To the extent possible, I pick out the "lint" from the | ! | code. In the process, I discovered some nasty little | ! | bugs in little used (or tested) routines. | ! | 04JUN2001 bga Changed PyObject_HEAD_INIT(&PyType_Type) to | ! | PyObject_HEAD_INIT(NULL) to silence error produced by | ! | some compilers. | ! | 02JUN2001 bga Modified code to use C implementation of PgInt2 type. | ! | 01JUN2001 bga Modified code to use C implementation of PgInt8 type. | ! | This code will only be used if LONG_LONG is defined. | ! | 20APR2001 bga Changed all useages of PyObject_NEW to PyObject_New. | ! | 08OCT2000 bga Added a wrapper around Pg_{BEGIN|END}_ALLOW_THREADS so | ! | they only allow/disallow threads in PostgreSQL v7.0 or | ! | later. | ! | 22SEP2000 bga Changed all memory allocations to use the Python calls. | ! | 21SEP2000 bga Added Py_{BEGIN|END}_ALLOW_THREADS wrappers arround the | ! | blocking libpq function calls. | ! | --- Added Pg_{BEGIN|END}_ALLOW_THREADS that check for a | ! | blocking connection before allowing/disallowing threads | ! | and wrapped libpq function calls that could block if | ! | the connection is in blocking mode. | ! | 09SEP2000 bga Added code to implement the remaining PosgreSQL 7.x C | ! | API functionality. | ! | 24AUG2000 bga Added code to implement the PQnotifies function. | ! | 23AUG2000 bga Added code to detect and set the appropiate exception | ! | for referential integrity violations. | ! | 21AUG2000 bga Added the 'name' attribute to the PgLargeObject class. | ! | 17AUG2000 bga Cleaned up comments and inconsistancies in function and | ! | variable naming. | ! | --- Corrected problem where each call to PQconnectdb method | ! | created two (2) PQconn objects and left one hanging. | ! | 15AUG2000 bga Fixed the code so that it will compile against the | ! | PostgreSQL 6.5.2 header and libraries. The changed are | ! | enabled by including '-DPGSQL_6X' on the compiler com- | ! | mand line. | ! | --- Cleaned up some warnings generated by gcc. | ! | --- Corrected problem where PG_INT8 values were returned as | ! | a Python Float instead of a Python Long. | ! | 29JUN2000 bga Initial release by Billy G. Allie. | \*(H-)******************************************************************/ --- 43,48 ---- | numbers [Bug #510244]. | | 21JAN2002 bga Applied patch by Chris Bainbridge [Patch #505941]. | ! | --------- bga Remove prior comments to reduce the size of the flower | ! | box. See revision 1.25 for earlier comments. | \*(H-)******************************************************************/ *************** *** 759,762 **** --- 688,692 ---- case PG_POINT: desc = "point"; break; case PG_POLYGON: desc = "polygon"; break; + case PG_REFCURSOR: desc = "refcursor"; break; case PG_REGPROC: desc = "regproc"; break; case PG_RELTIME: desc = "reltime"; break; *************** *** 766,769 **** --- 696,700 ---- case PG_TIME: desc = "time"; break; case PG_TIMESTAMP: desc = "timestamp"; break; + case PG_TIMESTAMPTZ: desc = "timestamptz"; break; case PG_TINTERVAL: desc = "tinterval"; break; case PG_UNKNOWN: desc = "unknown"; break; *************** *** 1108,1111 **** --- 1039,1043 ---- PyDict_SetItemString(d, "PG_POINT", Py_BuildValue("i", PG_POINT)); PyDict_SetItemString(d, "PG_POLYGON", Py_BuildValue("i", PG_POLYGON)); + PyDict_SetItemString(d, "PG_REFCURSOR", Py_BuildValue("i", PG_REFCURSOR)); PyDict_SetItemString(d, "PG_REGPROC", Py_BuildValue("i", PG_REGPROC)); PyDict_SetItemString(d, "PG_RELTIME", Py_BuildValue("i", PG_RELTIME)); *************** *** 1116,1119 **** --- 1048,1052 ---- PyDict_SetItemString(d, "PG_TIME", Py_BuildValue("i", PG_TIME)); PyDict_SetItemString(d, "PG_TIMESTAMP", Py_BuildValue("i", PG_TIMESTAMP)); + PyDict_SetItemString(d, "PG_TIMESTAMPTZ", Py_BuildValue("i", PG_TIMESTAMPTZ)); PyDict_SetItemString(d, "PG_TINTERVAL", Py_BuildValue("i", PG_TINTERVAL)); PyDict_SetItemString(d, "PG_UNKNOWN", Py_BuildValue("i", PG_UNKNOWN)); Index: pg_types.h =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pg_types.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** pg_types.h 4 Feb 2002 02:09:52 -0000 1.4 --- pg_types.h 1 Dec 2002 04:59:25 -0000 1.5 *************** *** 59,63 **** #define PG_DATE 1082 #define PG_TIME 1083 ! #define PG_TIMESTAMP 1184 #define PG_INTERVAL 1186 --- 59,64 ---- #define PG_DATE 1082 #define PG_TIME 1083 ! #define PG_TIMESTAMP 1114 ! #define PG_TIMESTAMPTZ 1184 #define PG_INTERVAL 1186 *************** *** 95,98 **** --- 96,100 ---- #define PG_UNKNOWN 705 #define PG_ACLITEM 1033 + #define PG_REFCURSOR 1790 #ifdef __cplusplus |