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: Gerhard H?r. <gha...@us...> - 2002-12-01 22:26:01
|
Update of /cvsroot/pypgsql/pypgsql In directory sc8-pr-cvs1:/tmp/cvs-serv24013 Modified Files: pyPgSQL.spec Log Message: 01DEC2002 gh - Changed Vendor field to the pyPgSQL developers list. - Changed Source field to Sourceforge mirror. Index: pyPgSQL.spec =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pyPgSQL.spec,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** pyPgSQL.spec 27 Oct 2002 05:58:14 -0000 1.4 --- pyPgSQL.spec 1 Dec 2002 22:25:58 -0000 1.5 *************** *** 15,24 **** Version: %{version} Release: %{release} ! Source0: pypgsql-%{version}.tar.gz Copyright: BSD Group: Development/Libraries BuildRoot: %{_tmppath}/%{name}-buildroot Prefix: %{_prefix} ! Vendor: Billy G. Allie <bal...@so...> Url: http://pypgsql.sourceforge.net/ Requires: egenix-mx-base --- 15,24 ---- Version: %{version} Release: %{release} ! Source: http://telia.dl.sourceforge.net/sourceforge/pypgsql/pypgsql-%{version}.tar.gz Copyright: BSD Group: Development/Libraries BuildRoot: %{_tmppath}/%{name}-buildroot Prefix: %{_prefix} ! Vendor: pyPgSQL developers <pyp...@li...> Url: http://pypgsql.sourceforge.net/ Requires: egenix-mx-base *************** *** 64,67 **** --- 64,71 ---- %changelog + * Sun Dec 01 2002 Gerhard Häring <ger...@gm...> + - Changed Vendor field to the pyPgSQL developers list. + - Changed Source field to Sourceforge mirror. + * Sun Oct 27 2002 Sean Reifschneider <jaf...@tu...> - Define CFLAGS for gcc 3.x compilers so that the C version of PgInt8 gets |
From: Billy G. A. <bal...@us...> - 2002-12-01 22:20:16
|
Update of /cvsroot/pypgsql/pypgsql In directory sc8-pr-cvs1:/tmp/cvs-serv21854 Modified Files: MANIFEST Log Message: 01DEC2002 bga Updated the manifest file to reflect reality :-) Index: MANIFEST =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/MANIFEST,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** MANIFEST 27 Oct 2002 06:06:01 -0000 1.9 --- MANIFEST 1 Dec 2002 22:20:12 -0000 1.10 *************** *** 28,41 **** examples/demo2a.py examples/demo2b.py pyPgSQL/PgSQL.py pyPgSQL/__init__.py pyPgSQL/libpq/__init__.py test/PgSQLTestCases.py test/regression/pgconnection.py test/regression/pgresult.py test/regression/pgversion.py test/regression/unicode_tests.py - port/strtok.c - port/port.h - port/strtoll.c - port/strtoull.c --- 28,42 ---- examples/demo2a.py examples/demo2b.py + port/port.h + port/strtok.c + port/strtoll.c + port/strtoull.c pyPgSQL/PgSQL.py pyPgSQL/__init__.py pyPgSQL/libpq/__init__.py test/PgSQLTestCases.py + test/regression/array.py test/regression/pgconnection.py test/regression/pgresult.py test/regression/pgversion.py test/regression/unicode_tests.py |
From: Billy G. A. <bal...@us...> - 2002-12-01 22:12:33
|
Update of /cvsroot/pypgsql/pypgsql/pyPgSQL In directory sc8-pr-cvs1:/tmp/cvs-serv18798/pyPgSQL Modified Files: PgSQL.py Log Message: 01DEC2002 bga - Fixed problems with new __setupTransaction function: 1. Made it a method of Connection, not Cursor. 2. inTransaction was only set if TransactionLevel was set. - Fixed instances where method name was incorrect: Connection__gcCursor -> _Connection__gcCursor Connection__closeCursor -> _Connection__closeCursor - Cleaned up code where there was unneeded references to conn in Connection class. Index: PgSQL.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pyPgSQL/PgSQL.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** PgSQL.py 1 Dec 2002 21:45:10 -0000 1.24 --- PgSQL.py 1 Dec 2002 22:12:30 -0000 1.25 *************** *** 30,33 **** --- 30,42 ---- # Date Ini Description | # --------- --- ------------------------------------------------------- | + # 01DEC2002 bga - Fixed problems with new __setupTransaction function: | + # 1. Made it a method of Connection, not Cursor. | + # 2. inTransaction was only set if TransactionLevel was | + # set. | + # - Fixed instances where method name was incorrect: | + # Connection__gcCursor -> _Connection__gcCursor | + # Connection__closeCursor -> _Connection__closeCursor | + # - Cleaned up code where there was unneeded references | + # to conn in Connection class. | # 01DEC2002 gh - Handle the new '__quote__' method for arrays, too. | # - Still handle '_quote' methods for backwards compati- | *************** *** 37,41 **** # and PG_REFCURSOR oids. [Bug #845360] | # - Reference cursors are now type-casted into cursor ob- | ! # jects. # 27NOV2002 bga - Completed the emulation of a String object for the | # PgBytea and PgOther classes. This corrects several | --- 46,50 ---- # and PG_REFCURSOR oids. [Bug #845360] | # - Reference cursors are now type-casted into cursor ob- | ! # jects. | # 27NOV2002 bga - Completed the emulation of a String object for the | # PgBytea and PgOther classes. This corrects several | *************** *** 2289,2293 **** --- 2298,2314 ---- i.close() + def __setupTransaction(self): + """ + __setupTransaction() + Internal routine that will set up a transaction for this connection.\n""" + self.conn.query("BEGIN WORK") + if self.TransactionLevel != "": + self.conn.query('SET TRANSACTION ISOLATION LEVEL %s' % + self.TransactionLevel) + if len(self.notices) != _nl: + raise Warning, self.notices.pop() + self.__dict__["inTransaction"] = 1 + def close(self): """ *************** *** 2304,2309 **** _nl = len(self.conn.notices) self.conn.query("ROLLBACK WORK") ! if len(self.conn.notices) != _nl: ! raise Warning, self.conn.notices.pop() except: pass --- 2325,2330 ---- _nl = len(self.conn.notices) self.conn.query("ROLLBACK WORK") ! if len(self.notices) != _nl: ! raise Warning, self.notices.pop() except: pass *************** *** 2334,2339 **** _nl = len(self.conn.notices) res = self.conn.query("COMMIT WORK") ! if len(self.conn.notices) != _nl: ! raise Warning, self.conn.notices.pop() if res.resultStatus != COMMAND_OK: raise InternalError, "Commit failed - reason unknown." --- 2355,2360 ---- _nl = len(self.conn.notices) res = self.conn.query("COMMIT WORK") ! if len(self.notices) != _nl: ! raise Warning, self.notices.pop() if res.resultStatus != COMMAND_OK: raise InternalError, "Commit failed - reason unknown." *************** *** 2354,2359 **** _nl = len(self.conn.notices) res = self.conn.query("ROLLBACK WORK") ! if len(self.conn.notices) != _nl: ! raise Warning, self.conn.notices.pop() if res.resultStatus != COMMAND_OK: raise InternalError, \ --- 2375,2380 ---- _nl = len(self.conn.notices) res = self.conn.query("ROLLBACK WORK") ! if len(self.notices) != _nl: ! raise Warning, self.notices.pop() if res.resultStatus != COMMAND_OK: raise InternalError, \ *************** *** 2381,2400 **** "Creation of large object failed - Connection is not open." ! _nl = len(self.conn.notices) ! # Ensure that we are in a transaction for working with large objects if not self.inTransaction: ! self.conn.query("BEGIN WORK") ! if self.conn.TransactionLevel != "": ! self.conn.conn.query('SET TRANSACTION ISOLATION LEVEL %s' % ! self.conn.TransactionLevel) ! if len(self.conn.notices) != _nl: ! raise Warning, self.conn.notices.pop() ! self.conn.__dict__["inTransaction"] = 1 _lo = self.conn.lo_creat(INV_READ | INV_WRITE) ! if len(self.conn.notices) != _nl: ! raise Warning, self.__conn.notices.pop() if string: --- 2402,2416 ---- "Creation of large object failed - Connection is not open." ! _nl = len(self.notices) ! _ct = 0 # Ensure that we are in a transaction for working with large objects if not self.inTransaction: ! self.__setupTransaction() ! _ct = 1 _lo = self.conn.lo_creat(INV_READ | INV_WRITE) ! if len(self.notices) != _nl: ! raise Warning, self.notices.pop() if string: *************** *** 2403,2413 **** _lo.close() ! if len(self.conn.notices) != _nl: ! if not self.inTransaction: ! conn.conn.query("ROLLBACK WORK") raise Warning, self.conn.notices.pop() ! if not self.inTransaction: ! self.conn.query("COMMIT WORK") return _lo --- 2419,2430 ---- _lo.close() ! if len(self.notices) != _nl: ! if self.inTransaction: ! self.conn.query("ROLLBACK WORK") raise Warning, self.conn.notices.pop() ! if self.inTransaction: ! if _ct: # Only commit the transaction if we started it. ! self.conn.query("COMMIT WORK") return _lo *************** *** 2433,2438 **** _nl = len(self.conn.notices) res = self.conn.lo_unlink(oid) ! if len(self.conn.notices) != _nl: ! raise Warning, self.conn.notices.pop() return res --- 2450,2455 ---- _nl = len(self.conn.notices) res = self.conn.lo_unlink(oid) ! if len(self.notices) != _nl: ! raise Warning, self.notices.pop() return res *************** *** 2492,2496 **** # Only the first created cursor begins the transaction. if not self.conn.inTransaction: ! self.__setupTransaction() self.__dict__["PgResultSetClass"] = None --- 2509,2513 ---- # Only the first created cursor begins the transaction. if not self.conn.inTransaction: ! self.conn._Connection__setupTransaction() self.__dict__["PgResultSetClass"] = None *************** *** 2505,2519 **** self.__makedesc__() - def __setupTransaction(self): - _nl = len(self.conn.notices) - self.conn.conn.query("BEGIN WORK") - if self.conn.TransactionLevel != "": - self.conn.conn.query('SET TRANSACTION ISOLATION LEVEL %s' % - self.conn.TransactionLevel) - if len(self.conn.notices) != _nl: - raise Warning, self.conn.notices.pop() - self.conn.__dict__["inTransaction"] = 1 - - def __del__(self): # Ensure that the cursor is closed when it is deleted. This takes --- 2522,2525 ---- *************** *** 2737,2741 **** else: if not self.conn.inTransaction: ! self.__setupTransaction() proc = self.__unicodeConvert(proc) --- 2743,2747 ---- else: if not self.conn.inTransaction: ! self.conn._Connection__setupTransaction() proc = self.__unicodeConvert(proc) *************** *** 2777,2781 **** # An internal error occured. Try to get to a sane state. self.conn.__dict__["inTransaction"] = 0 ! self.conn.Connection__closeCursors_() self.conn.close() raise InternalError, msg --- 2783,2787 ---- # An internal error occured. Try to get to a sane state. self.conn.__dict__["inTransaction"] = 0 ! self.conn._Connection__closeCursors_() self.conn.close() raise InternalError, msg *************** *** 2840,2844 **** # so DROP TABLE/INDEX is ok. else: ! self.__setupTransaction() if re_DQL.search(query) and \ --- 2846,2850 ---- # so DROP TABLE/INDEX is ok. else: ! self.conn._Connection__setupTransaction() if re_DQL.search(query) and \ *************** *** 2853,2857 **** pass # not in transaction so DROP TABLE/INDEX is ok. else: ! self.__setupTransaction() _nl = len(self.conn.notices) --- 2859,2863 ---- pass # not in transaction so DROP TABLE/INDEX is ok. else: ! self.conn._Connection__setupTransaction() _nl = len(self.conn.notices) *************** *** 2899,2903 **** # An internal error occured. Try to get to a sane state. self.conn.__dict__["inTransaction"] = 0 ! self.conn.Connection__closeCursors_() self.conn.close() raise InternalError, msg --- 2905,2909 ---- # An internal error occured. Try to get to a sane state. self.conn.__dict__["inTransaction"] = 0 ! self.conn._Connection__closeCursors_() self.conn.close() raise InternalError, msg *************** *** 3063,3067 **** if self.closed == 0: _nl = len(self.conn.notices) ! self.res = self.conn.conn.query("MOVE BACKWARD ALL IN %s" % self.name) self._rows_ = 0 --- 3069,3073 ---- if self.closed == 0: _nl = len(self.conn.notices) ! self.res = self.conn.conn.query('MOVE BACKWARD ALL IN "%s"' % self.name) self._rows_ = 0 |
From: Billy G. A. <bal...@us...> - 2002-12-01 22:10:55
|
Update of /cvsroot/pypgsql/pypgsql In directory sc8-pr-cvs1:/tmp/cvs-serv18537 Modified Files: pgversion.c Log Message: 26NOV2002 bga Allowed for release canidate (rcN) version strings. Index: pgversion.c =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pgversion.c,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** pgversion.c 2 Oct 2002 04:08:38 -0000 1.18 --- pgversion.c 1 Dec 2002 22:10:51 -0000 1.19 *************** *** 32,35 **** --- 32,36 ---- | Date Ini Description | | --------- --- ------------------------------------------------------- | + | 26NOV2002 bga Allowed for release canidate (rcN) version strings. | | 16SEP2002 gh Reflect the change to the unconditionally included | | pg_strtok_r. | *************** *** 183,187 **** if (((*last == 'a') || (*last == 'b')) && isdigit(*(last+1))) return (errno != 0); ! return ((errno != 0) || (*last != (char)0)); } --- 184,192 ---- if (((*last == 'a') || (*last == 'b')) && isdigit(*(last+1))) return (errno != 0); ! ! /* Allow for release canidates */ ! if ((*last == 'r') && (*(last+1) == 'c') && isdigit(*(last+2))) ! return (errno != 0); ! return ((errno != 0) || (*last != (char)0)); } |
From: Gerhard H?r. <gha...@us...> - 2002-12-01 21:45:12
|
Update of /cvsroot/pypgsql/pypgsql/pyPgSQL In directory sc8-pr-cvs1:/tmp/cvs-serv8377/pyPgSQL Modified Files: PgSQL.py Log Message: 01DEC2002 gh - Handle the new '__quote__' method for arrays, too. - Still handle '_quote' methods for backwards compati- bility. This will will avoid complaints by users who have code depending on this. Like me. Index: PgSQL.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pyPgSQL/PgSQL.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** PgSQL.py 1 Dec 2002 04:59:25 -0000 1.23 --- PgSQL.py 1 Dec 2002 21:45:10 -0000 1.24 *************** *** 30,33 **** --- 30,37 ---- # Date Ini Description | # --------- --- ------------------------------------------------------- | + # 01DEC2002 gh - Handle the new '__quote__' method for arrays, too. | + # - Still handle '_quote' methods for backwards compati- | + # bility. This will will avoid complaints by users | + # who have code depending on this. Like me. | # 28NOV2002 bga - Fixed changed PG_TIMESTAMP oid, added PG_TIMESTAMPTZ | # and PG_REFCURSOR oids. [Bug #845360] | *************** *** 2069,2072 **** --- 2073,2078 ---- elif isinstance(_i, PgArray): _j = _j + _handleArray(_i)[1:-1] + ',' + elif hasattr(_i, '__quote__'): + _j = '%s%s,' % (_j, _i.__quote__(1)) elif hasattr(_i, '_quote'): _j = '%s%s,' % (_j, _i._quote(1)) *************** *** 2092,2109 **** if value is None: return 'NULL' ! ! if hasattr(value, '__quote__'): return value.__quote__() ! ! if type(value) in [DateTimeType, DateTimeDeltaType]: return "'%s'" % value ! ! if type(value) is StringType: return PgQuoteString(value) ! ! if type(value) is LongType: return str(value) ! ! return repr(value) def _quoteall(vdict): --- 2098,2113 ---- if value is None: return 'NULL' ! elif hasattr(value, '__quote__'): return value.__quote__() ! elif hasattr(value, '_quote'): ! return value._quote() ! elif type(value) in [DateTimeType, DateTimeDeltaType]: return "'%s'" % value ! elif type(value) is StringType: return PgQuoteString(value) ! elif type(value) is LongType: return str(value) ! else: ! return repr(value) def _quoteall(vdict): |
From: Gerhard H?r. <gha...@us...> - 2002-12-01 20:16:54
|
Update of /cvsroot/pypgsql/pypgsql In directory sc8-pr-cvs1:/tmp/cvs-serv28272 Modified Files: Announce Log Message: 01DEC2002 gh setup.config is gone. Index: Announce =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/Announce,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** Announce 1 Dec 2002 04:59:24 -0000 1.20 --- Announce 1 Dec 2002 20:16:51 -0000 1.21 *************** *** 42,46 **** 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. --- 42,46 ---- If your platform isn't supported out of the box, you can edit a ! setup.py file to configure the build process. Patches for supporting additional platforms are more than welcome. Look into setup.py for how to do it. *************** *** 106,115 **** The following source code files were added to Version 2.3 of pyPgSQL: - - setup.config - Part of the changed distutils-based build process. - If you want to customize the build process (change - include and library directories, for example, you - only need to edit this file; setup.py should not be - edited directly any longer) unicode_tests.py - Test suite for the new Unicode support. Merged from --- 106,109 ---- |
From: Gerhard H?r. <gha...@us...> - 2002-12-01 20:11:15
|
Update of /cvsroot/pypgsql/pypgsql In directory sc8-pr-cvs1:/tmp/cvs-serv24494 Modified Files: README Log Message: 01DEC2002 gh - Changed recommended PostgreSQL version to 7.2, like in Announcement. - Fixed some spelling errors (yay vimaspell!). Index: README =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/README,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** README 1 Dec 2002 04:59:24 -0000 1.28 --- README 1 Dec 2002 20:11:07 -0000 1.29 *************** *** 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. --- 105,117 ---- ---------------- ! These instructions assume you have Python 2.0 (or later) and at least ! PostgreSQL 7.0 (7.2 or later 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 regarding USE_CUSTOM to guide you in customizing this file. c. Execute ``python setup.py build`` to build the extension module. *************** *** 119,122 **** --- 119,125 ---- d. Execute ``python setup.py install`` to install the extension module. + (On many platforms, you can skip step b. as the necessary paths are + automatically detected.) + Note: You may require root access to install the module. Consult your local system administrator. *************** *** 141,148 **** createlang plpgsql pypgsql ! 1.5 Addition information about ... ! ---------------------------------- ! Addition information about the different packages is available at: :Python: http://www.python.org --- 144,151 ---- createlang plpgsql pypgsql ! 1.5 Additional information about ... ! ------------------------------------ ! Additional information about the different packages is available at: :Python: http://www.python.org *************** *** 262,266 **** :PgLargeObject: creates a PgLargeObject from a connection and OID. ! :PgVersion: creates a PgVerion object from a string. :PgQuoteString: Quotes a string, escaping any characters as needed, for use as input to a character/text --- 265,269 ---- :PgLargeObject: creates a PgLargeObject from a connection and OID. ! :PgVersion: creates a PgVersion object from a string. :PgQuoteString: Quotes a string, escaping any characters as needed, for use as input to a character/text *************** *** 269,273 **** characters, so that it can used as an input to a bytea field. ! :PgUnQuoteBytea: Reverses the action of PgQuoteBytes(). 2.1.3.1 PQconnectdb --- 272,276 ---- characters, so that it can used as an input to a bytea field. ! :PgUnQuoteBytea: Reverses the action of PgQuoteBytea(). 2.1.3.1 PQconnectdb *************** *** 383,387 **** *Description*: This method returns a PgInt2 object initialized from the value of the ! string or numberic 'object'. The PgInt2 type uses a 2-byte integer to store it's value. --- 386,390 ---- *Description*: This method returns a PgInt2 object initialized from the value of the ! string or numeric 'object'. The PgInt2 type uses a 2-byte integer to store it's value. *************** *** 397,401 **** *Description*: This method returns a PgInt8 object initialized from the value of the ! string or numberic 'object'. The PgInt8 type uses a 8-byte integer to store it's value. --- 400,404 ---- *Description*: This method returns a PgInt8 object initialized from the value of the ! string or numeric 'object'. The PgInt8 type uses a 8-byte integer to store it's value. *************** *** 469,474 **** escaped as follows:: ! 1. <NUL> characters: '\\000' (Note: with 2 backslahes) ! 2. Non-printable charactes: '\OOO' (Note OOO is the octal representation of the characters ordinal number) 3. Backslashes: '\\\\' (Note: with 4 backslashes) --- 472,477 ---- escaped as follows:: ! 1. <NUL> characters: '\\000' (Note: with 2 backslashes) ! 2. Non-printable characters: '\OOO' (Note OOO is the octal representation of the characters ordinal number) 3. Backslashes: '\\\\' (Note: with 4 backslashes) *************** *** 478,484 **** If forArray is one (1), the escaping is changed as follows: ! 1. <NUL> characters: '\\\\000' (Note: with 4 backslahes) 2. Non-printable characters: '\\\\OOO' ! 3. Backslashes: '\\\\\\\\' (Note: with 8 backslahes) 4. Single quote: "\'" 5. The double quote (as '\\"') --- 481,487 ---- If forArray is one (1), the escaping is changed as follows: ! 1. <NUL> characters: '\\\\000' (Note: with 4 backslashes) 2. Non-printable characters: '\\\\OOO' ! 3. Backslashes: '\\\\\\\\' (Note: with 8 backslashes) 4. Single quote: "\'" 5. The double quote (as '\\"') *************** *** 500,504 **** *Returns*: A copy of the input string with any escaped character returned ! to thier original value. 2.1.4 libpq Classes --- 503,507 ---- *Returns*: A copy of the input string with any escaped character returned ! to their original value. 2.1.4 libpq Classes *************** *** 509,513 **** :PgConnection: the connection class. It handles the connection and all requests to the database. ! :PgResults: handles the query results. :PgLargeObject: handles the access to PostgreSQL large objects. :PgNotify: the notify class. It contains information about a --- 512,516 ---- :PgConnection: the connection class. It handles the connection and all requests to the database. ! :PgResult: handles the query results. :PgLargeObject: handles the access to PostgreSQL large objects. :PgNotify: the notify class. It contains information about a *************** *** 581,585 **** :reset: Reset the communication port with the backend. :notifies: Returns the next notification object (PgNotify) from a list ! of unhandled notifiaction objects. :getline: Read a (newline-terminated) line of characters from the backend. --- 584,588 ---- :reset: Reset the communication port with the backend. :notifies: Returns the next notification object (PgNotify) from a list ! of unhandled notification objects. :getline: Read a (newline-terminated) line of characters from the backend. *************** *** 708,712 **** See the PostgreSQL C API documentation for details. ! 2.1.4.1.7 flush (PostgreSQL 7.x amd above) ------------------------------------------ --- 711,715 ---- See the PostgreSQL C API documentation for details. ! 2.1.4.1.7 flush (PostgreSQL 7.x and above) ------------------------------------------ *************** *** 733,737 **** *Description*: Send a cancel request to the backend. Note that the successful ! dispatching of the request does not mean the request will be cancelled. This method implements the PQrequestCancel function and is used with asynchronous query processing. --- 736,740 ---- *Description*: Send a cancel request to the backend. Note that the successful ! dispatching of the request does not mean the request will be canceled. This method implements the PQrequestCancel function and is used with asynchronous query processing. *************** *** 796,800 **** notifications. This method implements the PQnotifies function. ! Exception InterfaceError, TypeError --- 799,803 ---- notifications. This method implements the PQnotifies function. ! *Exceptions*: InterfaceError, TypeError *************** *** 817,821 **** command.. ! Exception InterfaceError, TypeError, MemoryError, InternalError --- 820,824 ---- command.. ! *Exceptions*: InterfaceError, TypeError, MemoryError, InternalError *************** *** 839,843 **** command.. ! Exception InterfaceError, TypeError, MemoryError, InternalError --- 842,846 ---- command.. ! *Exceptions*: InterfaceError, TypeError, MemoryError, InternalError *************** *** 855,863 **** *Description*: ! The putline method sends a (null-terminated) string tp the backend. This method implements the PQputline function and is used with the PostgreSQL COPY command.. ! Exception InterfaceError, TypeError, InternalError --- 858,866 ---- *Description*: ! The putline method sends a (null-terminated) string to the backend. This method implements the PQputline function and is used with the PostgreSQL COPY command.. ! *Exceptions*: InterfaceError, TypeError, InternalError *************** *** 882,886 **** and is used with the PostgreSQL COPY command.. ! Exception InterfaceError, TypeError, InternalError --- 885,889 ---- and is used with the PostgreSQL COPY command.. ! *Exceptions*: InterfaceError, TypeError, InternalError *************** *** 1171,1180 **** (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. (3) Any escaped characters in the string will be returned ! to thier original value in the returned string. getvalue implements and extends the PQgetvalue function. --- 1174,1183 ---- (1) getvalue() will determine if the OID represents a ! PostgreSQL Large Object and returns the appropriate object. (2) PgInt8 type is only available on system that have long long (64 bit integer) support. (3) Any escaped characters in the string will be returned ! to their original value in the returned string. getvalue implements and extends the PQgetvalue function. *************** *** 1261,1265 **** and the following public, read-write attribute: ! :softspace: Boolean that indicates wether a space character needs to be printed before another value when using the 'print' statement. --- 1264,1268 ---- and the following public, read-write attribute: ! :softspace: Boolean that indicates whether a space character needs to be printed before another value when using the 'print' statement. *************** *** 1299,1303 **** included in the mode string to indicate opening the LO for binary data, but is not really needed since PostgreSQL does not differentiate ! beteewn binary and non-binary data. Note: 'w+' will NOT truncate the large object. --- 1302,1306 ---- included in the mode string to indicate opening the LO for binary data, but is not really needed since PostgreSQL does not differentiate ! between binary and non-binary data. Note: 'w+' will NOT truncate the large object. *************** *** 1335,1340 **** *Returns*: ! 1 if successful, 0 if an OS error occured, < 0 if a database ! error occured. *Description*: --- 1338,1343 ---- *Returns*: ! 1 if successful, 0 if an OS error occurred, < 0 if a database ! error occurred. *Description*: *************** *** 1357,1361 **** ---------------------------- ! The PgVersion object encapulates information about the version of PostgreSQL that a connection object is connected to. It provides the following read-only attribute: --- 1360,1364 ---- ---------------------------- ! The PgVersion object encapsulates information about the version of PostgreSQL that a connection object is connected to. It provides the following read-only attribute: *************** *** 1371,1375 **** 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 --- 1374,1378 ---- For example, for version 6.5.3, the contents of the PgVersion object would be:: ! connection.version == "PostgreSQL 6.5.3 on <system dependent info>" connection.version.major == 6 connection.version.minor == 5 *************** *** 1379,1383 **** 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 --- 1382,1386 ---- For example, for version 7.1.1, the contents of PgVer would be:: ! connection.version == "PostgreSQL 7.1.1 on <system dependent info>" connection.version.major == 7 connection.version.minor == 1 *************** *** 1430,1434 **** ------------------------------------- ! 1. The Binary contructor is a method of the Connection object, not the module. For PostgreSQL, a Large Object can only be created in conjunction with a Connection, it has no meaning outside of the context of a Connection. --- 1433,1437 ---- ------------------------------------- ! 1. The Binary constructor is a method of the Connection object, not the module. For PostgreSQL, a Large Object can only be created in conjunction with a Connection, it has no meaning outside of the context of a Connection. *************** *** 1445,1449 **** :PgNumeric: Supports the PG_NUMERIC data type. It uses a Python Long as ! the base type and provides the following aritmetic operations: addition, subtraction, multiplication, and division. --- 1448,1452 ---- :PgNumeric: Supports the PG_NUMERIC data type. It uses a Python Long as ! the base type and provides the following arithmetic operations: addition, subtraction, multiplication, and division. *************** *** 1454,1458 **** :PgBytea: This class supports the PG_BYTEA data type. It is a wrapper ! arround a Python String that provides for proper escaping of the string when used in a query. --- 1457,1461 ---- :PgBytea: This class supports the PG_BYTEA data type. It is a wrapper ! around a Python String that provides for proper escaping of the string when used in a query. *************** *** 1492,1497 **** Setting this attribute to 1 will cause the fetchXXX methods to return a ! list instead of a PgResultSet. This will provide better performace by ! scarificing the convient access methods provide by a PgResultSet. The default value for fetchReturnsList is 0. --- 1495,1500 ---- Setting this attribute to 1 will cause the fetchXXX methods to return a ! list instead of a PgResultSet. This will provide better performance by ! sacrificing the convenient access methods provide by a PgResultSet. The default value for fetchReturnsList is 0. *************** *** 1503,1507 **** This attribute is a list of notices returned by the pq library. ! Note: Under normal usage, certain (but not all) notices recieved from the libpq C-API library are converted into Warning exceptions. --- 1506,1510 ---- This attribute is a list of notices returned by the pq library. ! Note: Under normal usage, certain (but not all) notices received from the libpq C-API library are converted into Warning exceptions. *************** *** 1519,1523 **** 5. A PgSQL specific Connection attribute, called TransactionLevel, specifies the isolation level to use within a transaction. It can be set to "", ! "READ COMMITED", or "SERIALIZABLE". PgSQL will issue the appropiate "SET TRANSACTION LEVEL" statement whenever a new transaction is started for the connection. Note: The value of this attribute can not be changed if --- 1522,1526 ---- 5. A PgSQL specific Connection attribute, called TransactionLevel, specifies the isolation level to use within a transaction. It can be set to "", ! "READ COMMITED", or "SERIALIZABLE". PgSQL will issue the appropriate "SET TRANSACTION LEVEL" statement whenever a new transaction is started for the connection. Note: The value of this attribute can not be changed if *************** *** 1557,1562 **** 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. --- 1560,1565 ---- 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 substituted, even for integers, floats and other non-string variables. ! The execute method will convert all the parameters to a string, applying any quoting that may be necessary before sending the query to the back-end. *************** *** 1583,1592 **** The PostgreSQL database system has no auto-commit setting. It is always in ! 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(). ---------- ! 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 --- 1586,1595 ---- The PostgreSQL database system has no auto-commit setting. It is always in ! auto-commit mode unless a transaction is started. To achieve 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(). ---------- ! PostgreSQL arrays are no longer (directly) represented by Python lists. This means that lists and tuples are not longer treated specially by Cursor.execute(). This resolves a problem of using the IN SQL syntax with *************** *** 1609,1613 **** ---------- 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.) --- 1612,1616 ---- ---------- When working with PostgreSQL large object, you MUST be in a transaction. ! The code will try to ensure that a transaction 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.) *************** *** 1616,1620 **** 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 --- 1619,1623 ---- 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 cursor): $ python |
From: Gerhard H?r. <gha...@us...> - 2002-12-01 19:34:12
|
Update of /cvsroot/pypgsql/pypgsql/pyPgSQL In directory sc8-pr-cvs1:/tmp/cvs-serv2711/pyPgSQL Modified Files: __init__.py Log Message: 01DEC2002 gh Brought version number up to 2.3. Index: __init__.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pyPgSQL/__init__.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** __init__.py 27 Oct 2002 03:47:27 -0000 1.3 --- __init__.py 1 Dec 2002 19:34:08 -0000 1.4 *************** *** 32,34 **** """ ! __version__ = "2.3b1" --- 32,34 ---- """ ! __version__ = "2.3" |
From: Gerhard H?r. <gha...@us...> - 2002-12-01 19:31:02
|
Update of /cvsroot/pypgsql/pypgsql In directory sc8-pr-cvs1:/tmp/cvs-serv420 Modified Files: README.win32 Log Message: 01DEC2002 gh Updates for changed build process. Index: README.win32 =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/README.win32,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** README.win32 2 Oct 2002 03:59:05 -0000 1.3 --- README.win32 1 Dec 2002 19:30:56 -0000 1.4 *************** *** 23,28 **** project or from Cygwin. ! I maintain Makefiles for compiling libpq with mingw32. You can look at my ! home page for them (http://www.cs.fhm.edu/~ifw00065/) or ask me via email. --- 23,28 ---- project or from Cygwin. ! I maintain patches to add Makefiles for compiling libpq with mingw32. They're ! available at http://pypgsql.sourceforge.net/misc/postgresql.html *************** *** 30,64 **** =================== ! 2.1 Adjust setup.py ! ------------------- ! 2.1.1 For Visual C++ ! - Adjust win_pg_build_root to point to your PostgreSQL source tree ! - Change library_dirs to ! library_dirs = [win_pg_build_root + "src/interfaces/libpq/Release"] ! - Change this line: ! optional_libs += ["pqdll"] ! to: ! optional_libs += ["libpqdll"] ! - copy the libpq.dll file from the PostgreSQL source tree to the pyPgSQL root ! directory ! 2.1.2 For gcc (mingw32) ! - Adjust win_pg_build_root to point to your PostgreSQL source tree ! - Change this line: ! optional_libs += ["pqdll"] ! to: ! optional_libs += ["pq"] ! if you want to link against PostgreSQL's libpq statically ! - copy the libpq.dll file from the PostgreSQL source tree to the pyPgSQL root ! directory, but if you want to link statically against PostgreSQL's libpq, ! change the following line instead: ! data_files = ["libpq.dll"] ! to: ! data_files = [] ! 2.2 Building ------------ --- 30,48 ---- =================== ! 2.1 Environment settings ! ------------------------ ! - Set the PG_SRC environment variable to your PostgreSQL source tree, if you ! need to override the default setting of "../postgresql". ! 2.2 Adjusting setup.py ! ---------------------- ! If you're using gcc, you can skip this step. ! For Visual C++, see the comments in the win32 section of setup.py, and ! (un)comment the various lines appropriately. ! 2.3 Building ------------ *************** *** 76,80 **** Remarks: - The "install" and bdist_wininst commands imply "build" ! - If you have installed Cygwin's Python, you need to provide the full path to ! the native win32 Python you want to use; I prefer to have a copy of the win32 ! Python under an alternative name like ntpython in my PATH --- 60,62 ---- Remarks: - The "install" and bdist_wininst commands imply "build" ! - If you have also installed Cygwin's Python, be sure to invoke the win32 Python. |
From: Billy G. A. <bal...@us...> - 2002-12-01 18:30:31
|
Update of /cvsroot/pypgsql/pypgsql In directory sc8-pr-cvs1:/tmp/cvs-serv26252 Modified Files: ChangeLog Log Message: 01DEC2002 bga Updated ChangeLog for release 2.3. CVS Index: ChangeLog =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/ChangeLog,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** ChangeLog 27 Oct 2002 04:27:35 -0000 1.17 --- ChangeLog 1 Dec 2002 18:30:23 -0000 1.18 *************** *** 4,31 **** ================================= ! 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. ! If you want to customize the build process (change ! include and library directories, for example, you ! only need to edit this file; setup.py should not be ! edited directly any longer) ! unicode_tests.py - Test suite for the new Unicode support. Merged from ! the Unicode patch. Changes to setup.py ------------------- ! * This file was rewritten entirely so that pyPgSQL now builds out of the box ! on Windows, Cygwin, Debian Linux, Redhat Linux, SuSE Linux, FreeBSD, ! UnixWare 7 and OpenUNIX 8. These are the platforms the new build process has ! been tested on. Untested support is available for Mandrake Linux, NetBSD, ! OpenBSD and MacOS X. 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/). Changes to README.win32 --- 4,32 ---- ================================= ! The following source code files were added to Version 2.3 of pyPgSQL: setup.config - Part of the changed distutils-based build process. ! If you want to customize the build process ! (change include and library directories, for ! example, you only need to edit this file; ! setup.py should not be edited directly any ! longer) ! unicode_tests.py - Test suite for the new Unicode support. Merged ! from the Unicode patch. Changes to setup.py ------------------- ! * This file was rewritten entirely so that pyPgSQL now builds out of the ! box on Windows, Cygwin, Debian Linux, Redhat Linux, SuSE Linux, FreeBSD, ! UnixWare 7 and OpenUNIX 8. These are the platforms the new build process ! has been tested on. Untested support is available for Mandrake Linux, ! NetBSD, OpenBSD and MacOS X. Changes to README ----------------- ! * Updates for 2.3. ! * Converted the whole document into reStructuredText, so we can easily ! built a HTML version using docutils (http://docutils.sf.net/). Changes to README.win32 *************** *** 36,39 **** --- 37,52 ---- 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. *************** *** 57,72 **** 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 --- 70,91 ---- 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 |
From: Gerhard H?r. <gha...@us...> - 2002-12-01 16:18:15
|
Update of /cvsroot/pypgsql/pypgsql In directory sc8-pr-cvs1:/tmp/cvs-serv7132 Modified Files: setup.py Removed Files: setup.config Log Message: 01DEC2002 gh Simplified build process and got rid of setup.config. setup.config prevented the bdist_rpm command of dist- utils to work and generally wasn't such a good idea as it looked first. Pretty much the same effect is now reached by the USE_CUSTOM variable with which users can override the platform detection. Index: setup.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/setup.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** setup.py 27 Oct 2002 03:47:27 -0000 1.19 --- setup.py 1 Dec 2002 16:14:11 -0000 1.20 *************** *** 1,4 **** --- 1,5 ---- #!/usr/bin/env python #ident "@(#) $Id$" + # vi:set sw=4 ts=8 showmode ai: #-----------------------------------------------------------------------+ # Name: setup.py | *************** *** 44,53 **** # Date Ini Description | # --------- --- ------------------------------------------------------- | # 06OCT2002 bga Added support for UnixWare7 and OpenUNIX 8. | # 16SEP2002 gh Total rework to make setup.py work out of the box for | ! # most popular platforms, while still allowing flexibi- | ! # lity through setup.config. | # 29AUG2001 gh Reflected changed PostgreSQL win32 build process (Post- | ! # greSQL now built with mingw32) | # 28AUG2001 bga Add include_dirs and lib_dirs for building on cygwin. | # This change should allow pyPgSQL to build 'out of the | --- 45,60 ---- # Date Ini Description | # --------- --- ------------------------------------------------------- | + # 01DEC2002 gh Simplified build process and got rid of setup.config. | + # setup.config prevented the bdist_rpm command of dist- | + # utils to work and generally wasn't such a good idea as | + # it looked first. Pretty much the same effect is now | + # reached by the USE_CUSTOM variable with which users | + # can override the platform detection. | # 06OCT2002 bga Added support for UnixWare7 and OpenUNIX 8. | # 16SEP2002 gh Total rework to make setup.py work out of the box for | ! # most popular platforms, while still allowing flexibi- | ! # lity through setup.config. | # 29AUG2001 gh Reflected changed PostgreSQL win32 build process (Post- | ! # greSQL now built with mingw32) | # 28AUG2001 bga Add include_dirs and lib_dirs for building on cygwin. | # This change should allow pyPgSQL to build 'out of the | *************** *** 68,174 **** from distutils.extension import Extension ! __version__ = "2.3b1" # Define the runtime library path for this module. It starts out as None. ! class UnknownPlatformError(Exception): ! pass ! ! def getLinuxDistribution(): ! f = open("/etc/issue") ! issue = f.read() ! f.close() ! if issue.find("Debian GNU") >= 0: ! return "Debian" ! elif issue.find("Red Hat Linux") >= 0: ! return "Redhat" ! elif issue.find("SuSE Linux") >= 0: ! return "SuSE" ! elif issue.find("Mandrake") >= 0: ! return "Mandrake" ! else: ! return "unknown" ! ! class Config: ! def __init__(self): ! # Default settings, may be overriden for specific platforms ! self.pypgsql_rt_dirs = None ! self.optional_libs = ["pq"] ! self.modname = "pyPgSQL.libpq.libpqmodule" ! ! self.sources = ["libpqmodule.c", "pgboolean.c", ! "pgint2object.c", "pgint8object.c", ! "pgversion.c", "pglargeobject.c", ! "pgnotify.c", "pgconnection.c", ! "pgresult.c", "pymemstrdup.c", ! "port/strtoll.c", "port/strtoull.c", ! "port/strtok.c"] ! imported_locals = {} ! execfile("setup.config", {}, imported_locals) ! self.use_custom = len(imported_locals) > 0 ! if self.use_custom: ! for k, v in imported_locals.items(): ! self.__dict__[k] = v ! def main(): ! cfg = Config() ! if cfg.use_custom: ! pass elif sys.platform == "linux2": ! distribution = getLinuxDistribution() ! if distribution == "Redhat": ! cfg.include_dirs = ["/usr/include"] ! cfg.library_dirs = ["/usr/lib"] ! elif distribution == "Debian": ! cfg.include_dirs = ["/usr/include/postgresql"] ! cfg.library_dirs = ["/usr/lib"] ! elif distribution in ("SuSE", "Mandrake"): ! cfg.include_dirs = ["/usr/include/pgsql"] ! cfg.library_dirs = ["/usr/lib"] ! else: ! raise UnknownPlatformError, "Unknown Linux distribution." # XXX: This is an ugly hack to make bdist_rpm find the include files. ! cfg.include_dirs.append("../" * 5) elif sys.platform[:8] == "unixware": LOCALBASE = os.environ.get('LOCALBASE', '/usr/local/pgsql') ! cfg.include_dirs = ['%s/include' % LOCALBASE] ! cfg.library_dirs = ['%s/lib' % LOCALBASE] ! cfg.pypgsql_rt_dirs = cfg.library_dirs elif sys.platform == "freebsd4": LOCALBASE = os.environ.get('LOCALBASE', '/usr/local') ! cfg.include_dirs = ['%s/include' % LOCALBASE] ! cfg.library_dirs = ['%s/lib' % LOCALBASE] elif sys.platform == "openbsd3": LOCALBASE = os.environ.get('LOCALBASE', '/usr/local') ! cfg.include_dirs = ['%s/include/postgresql' % LOCALBASE] ! cfg.library_dirs = ['%s/lib' % LOCALBASE] elif sys.platform == "netbsd1": LOCALBASE = os.environ.get('LOCALBASE', '/usr/pkg') ! cfg.include_dirs = ['%s/include/pgsql' % LOCALBASE] ! cfg.library_dirs = ['%s/lib' % LOCALBASE] elif sys.platform == "cygwin": ! cfg.include_dirs = ["/usr/include/postgresql"] ! cfg.library_dirs = ["/usr/lib"] elif sys.platform == "darwin": # Mac OS X ! cfg.include_dirs = ["/usr/local/pgsql/include"] ! cfg.library_dirs = ["/usr/local/pgsql/lib"] ! cfg.optional_libs += ["ssl", "crypto"] elif sys.platform == "win32": # This works with the PostgreSQL source tree, so it's a bit ugly ... win_pg_build_root = os.getenv("PG_SRC", "../postgresql") ! cfg.include_dirs = [os.path.join(win_pg_build_root, p) for p in ! ["src/include", ! "src/include/libpq", ! "src", ! "src/interfaces/libpq"]] ! cfg.library_dirs = [win_pg_build_root + "/src/interfaces/libpq/"] ! cfg.optional_libs += ["wsock32", "advapi32"] ! cfg.modname="pyPgSQL.libpq.libpq" else: ! raise UnknownPlatformError, "Unknown platform." setup ( --- 75,153 ---- from distutils.extension import Extension ! __version__ = "2.3" # Define the runtime library path for this module. It starts out as None. ! def main(): ! # Set this to 1 if you need to use your own settings ! USE_CUSTOM = 0 ! # Default settings, may be overriden for specific platforms ! pypgsql_rt_dirs = None ! optional_libs = ["pq"] ! modname = "pyPgSQL.libpq.libpqmodule" ! sources = ["libpqmodule.c", "pgboolean.c", ! "pgint2object.c", "pgint8object.c", ! "pgversion.c", "pglargeobject.c", ! "pgnotify.c", "pgconnection.c", ! "pgresult.c", "pymemstrdup.c", ! "port/strtoll.c", "port/strtoull.c", ! "port/strtok.c"] ! if USE_CUSTOM: ! include_dirs = YOUR_LIST_HERE ! library_dirs = YOUR_LIST_HERE elif sys.platform == "linux2": ! include_dirs = ["/usr/include", "/usr/include/postgresql", ! "/usr/include/pgsql"] ! library_dirs = ["/usr/lib"] ! # XXX: This is an ugly hack to make bdist_rpm find the include files. ! include_dirs.append("../" * 5) elif sys.platform[:8] == "unixware": LOCALBASE = os.environ.get('LOCALBASE', '/usr/local/pgsql') ! include_dirs = ['%s/include' % LOCALBASE] ! library_dirs = ['%s/lib' % LOCALBASE] ! pypgsql_rt_dirs = library_dirs elif sys.platform == "freebsd4": LOCALBASE = os.environ.get('LOCALBASE', '/usr/local') ! include_dirs = ['%s/include' % LOCALBASE] ! library_dirs = ['%s/lib' % LOCALBASE] elif sys.platform == "openbsd3": LOCALBASE = os.environ.get('LOCALBASE', '/usr/local') ! include_dirs = ['%s/include/postgresql' % LOCALBASE] ! library_dirs = ['%s/lib' % LOCALBASE] elif sys.platform == "netbsd1": LOCALBASE = os.environ.get('LOCALBASE', '/usr/pkg') ! include_dirs = ['%s/include/pgsql' % LOCALBASE] ! library_dirs = ['%s/lib' % LOCALBASE] elif sys.platform == "cygwin": ! include_dirs = ["/usr/include/postgresql"] ! library_dirs = ["/usr/lib"] elif sys.platform == "darwin": # Mac OS X ! include_dirs = ["/usr/local/pgsql/include"] ! library_dirs = ["/usr/local/pgsql/lib"] ! optional_libs += ["ssl", "crypto"] elif sys.platform == "win32": # This works with the PostgreSQL source tree, so it's a bit ugly ... + # Lines commented out are for using MSVC instead of mingw win_pg_build_root = os.getenv("PG_SRC", "../postgresql") ! include_dirs = [os.path.join(win_pg_build_root, p) for p in ! ["src/include", ! "src/include/libpq", ! "src", ! "src/interfaces/libpq"]] ! library_dirs = [win_pg_build_root + "/src/interfaces/libpq"] ! #library_dirs = [win_pg_build_root + "/src/interfaces/libpq/Release"] ! optional_libs += ["wsock32", "advapi32"] ! #optional_libs = ["libpq", "wsock32", "advapi32"] ! modname="pyPgSQL.libpq.libpq" else: ! # Assume a Unixish system ! include_dirs = ["/usr/local/include"] ! library_dirs = ["/usr/local/lib"] setup ( *************** *** 177,207 **** description = \ "pyPgSQL - A Python DB-API 2.0 compliant interface to PostgreSQL.", ! author = "Billy G. Allie", ! author_email = "bal...@so...", url = "http://pypgsql.sourceforge.net/", licence = "Python", packages = ["pyPgSQL", "pyPgSQL.libpq"], ext_modules = [Extension( ! name=cfg.modname, ! sources = cfg.sources, ! include_dirs = cfg.include_dirs, ! library_dirs = cfg.library_dirs, ! runtime_library_dirs = cfg.pypgsql_rt_dirs, ! libraries = cfg.optional_libs )] ) if __name__ == "__main__": ! try: ! main() ! except UnknownPlatformError, reason: ! print "Cannot build pyPgSQL:", reason ! print ! print "setup.py can't guess the correct settings for your platform." ! print ! print "Please manually edit setup.conf appropriately for your platform." ! print "If you have any problems, please ask on the pypgsql-users mailing list." ! print ! print "Once you've managed to build pyPgSQL on your platform, please submit a" ! print "patch to setup.py so that we can support your platform by default in" ! print "the future. The pyPgSQL developers are happy to assist you in doing so." --- 156,174 ---- description = \ "pyPgSQL - A Python DB-API 2.0 compliant interface to PostgreSQL.", ! maintainer = "pyPgSQL developers", ! maintainer_email = "pyp...@li...", url = "http://pypgsql.sourceforge.net/", licence = "Python", packages = ["pyPgSQL", "pyPgSQL.libpq"], ext_modules = [Extension( ! name=modname, ! sources = sources, ! include_dirs = include_dirs, ! library_dirs = library_dirs, ! runtime_library_dirs = pypgsql_rt_dirs, ! libraries = optional_libs )] ) if __name__ == "__main__": ! main() --- setup.config DELETED --- |
From: Billy G. A. <bal...@us...> - 2002-12-01 04:59:31
|
Update of /cvsroot/pypgsql/pypgsql/pyPgSQL In directory sc8-pr-cvs1:/tmp/cvs-serv16107/pyPgSQL Modified Files: PgSQL.py 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: PgSQL.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pyPgSQL/PgSQL.py,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** PgSQL.py 11 Nov 2002 03:56:42 -0000 1.22 --- PgSQL.py 1 Dec 2002 04:59:25 -0000 1.23 *************** *** 30,33 **** --- 30,41 ---- # Date Ini Description | # --------- --- ------------------------------------------------------- | + # 28NOV2002 bga - Fixed changed PG_TIMESTAMP oid, added PG_TIMESTAMPTZ | + # and PG_REFCURSOR oids. [Bug #845360] | + # - Reference cursors are now type-casted into cursor ob- | + # jects. + # 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. | # 10NOV2002 bga - Added the __hash__ function to the PgNumeric class. | # Cleaned up the code in PgNumeric class and made some | *************** *** 85,199 **** # operand. This is no longer the case all precision is | # retained for the +, -, and * operations. | ! # 03AUG2002 gh Fixed problem that occurs when a query on an OID field | ! # doesn't return any rows. [Bug #589370]. | ! # 29JUL2002 gh Applied patch #569203 and also added __pos__ and | ! # __abs__ special methods to PgNumeric. | ! # 15MAY2002 gh Got rid of redundant building and storing of the | ! # mapping of column names to column positions in the | ! # PgResultSet class. Now, rows of the same query are | ! # instances of a dynamically created class, which has | ! # this mapping as a class attribute instead of an attri- | ! # bute of the instance. This saves a lot of space, and | ! # also slightly increases performance of cursor fetches. | ! # 21APR2002 gh Improved the array parsing, so that it now passes all | ! # the new mean testcases. Added support for parsing | ! # multidimensional arrays. Eventually, the array parsing | ! # code should go as a support function into libpq. | ! # --- Replaced all typechecks with "is" operators instead | ! # of equals. Mark McEahern had a problem with using | ! # pyPgSQL in combination with a FixedPoint class where | ! # the reason was that the FixedPoint class was not com- | ! # parable to None. The consensus on python-list was that | ! # None and all types are singletons, so they should be | ! # checked using "is", which is also faster, because it | ! # only checks for object identity. | ! # 16APR2002 gh Fix the array parsing so it also works with PostgreSQL | ! # versions 7.2.x. The PostgreSQL developers changed the | ! # quoting in the string representation of arrays in 7.2 | ! # beta cycle: strings are now only quoted when otherwise | ! # the array representation would be ambiguous. The new | ! # parseArray() method should handle the old and new way | ! # of quoting in arrays. [Bug #539769]. | ! # 01FEB2002 bga Fixed a couple of problems found by Steven D. Arnold: | ! # 1. A undefined variable was used in a few places where | ! # notices were popped from the notice list. | ! # 2. Comparisons between 2 PgNumerics gave the wrong re- | ! # sult. | ! # 18JAN2002 bga Fixed problem that occurs when the sum() aggregate re- | ! # turns a NULL. [Bug #505162]. | ! # 04DEC2001 bga Added code to implement support for setting PostgreSQL | ! # transaction levels. [Feature Request #481727]. | ! # 03NOV2001 bga It appears that under certain circumstances, PostgreSQL | ! # will not return a precision/scale value for a numeric | ! # column when no result rows are returned [Bug #477792]. | ! # The problem is fixed by using a precision of (30,6) in | ! # case this condition occurs. | ! # 21OCT2001 gh Change the import of DateTime to avoid conflicts with | ! # ZOPE's builtin DateTime module. | ! # 17OCT2001 bga Added code to ensure that creation of a binary object | ! # via the binary() method always occurs within the con- | ! # text of a transaction. | ! # 27SEP2001 bga Change code so that the escaping/quoting is different | ! # if the result is to be used to build PostgreSQL arrays. | ! # --- Modified all the Object._quote methods so that they now | ! # accept an option argument, forArray, which if set to 1 | ! # will cause escaping/quoting for PostgreSQL array use. | ! # --- Re-organized the code use to build PostgreSQL arrays. | ! # 26SEP2001 bga Added additional PostgreSQL types to BINARY, ROWID, etc | ! # --- Fixed problems associated with type casting. | ! # 24SEP2001 bga Changed the method used to quote strings. This new way | ! # does not require the services of pgFixEsc, which was | ! # removed from pgconnection.c. | ! # --- Added support for the PostgreSQL type BYTEA. | ! # --- Improved support for the BYTEA type. | ! # 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 | ! # 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. | ! # 30AUG2001 bga Previously, I was not building up the description | ! # attibute if no rows were returned. The description | ! # 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. | ! # --- Added code that will, if weak references are not avail- | ! # able, remove any cursors that are only referenced from | ! # the connection.cursors list. This is in effect garbage | ! # collection for deleted cursors. The gabage collection | ! # of orphaned cursor will occur at the following points: | ! # 1. After a new cursor is created. | ! # 2. When a cursor is closed. | ! # 3. When the connection.autocommit value is changed. | ! # --- Changed cursor.isClosed to cursor.closed. Why, closed | ! # is used in other object (file and PgLargeObject, for | ! # example) and I thought I would follow the trend (i.e. | ! # for no good reason). | ! # --- Change from the use of hash() to generate the portal | ! # name to the use of id(). | ! # 10AUG2001 bga [Bug #449743]Added code to trap a failure to connect to | ! # a database and delete the Connection object on failure. | ! # This resolves the problem reported by Adam Buraczewski. | ! # --- Fixed a bug in fetchmany() that could return more than | ! # the requested rows if PostgreSQL Portals aren't used in | ! # the query. | ! # 03AUG2001 bga The PgVer object is now implemented in C (as PgVersion) | ! # and been moved to the libpq module. This was done to | ! # support handling of large objects in libpq based on the | ! # PostgreSQL version. | ! # 01AUG2001 bga Changed the code so that execute will not attempt to do | ! # 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-)-----------------------------------------------------------------+ """ --- 93,122 ---- # operand. This is no longer the case all precision is | # retained for the +, -, and * operations. | ! # 03AUG2002 gh - Fixed problem that occurs when a query on an OID | ! # field doesn't return any rows. [Bug #589370]. | ! # 29JUL2002 gh - Applied patch #569203 and also added __pos__ and | ! # __abs__ special methods to PgNumeric. | ! # 15MAY2002 gh - Got rid of redundant building and storing of the | ! # mapping of column names to column positions in the | ! # PgResultSet class. Now, rows of the same query are | ! # instances of a dynamically created class, which has | ! # this mapping as a class attribute instead of an at- | ! # tribute of the instance. This saves a lot of space, | ! # and also slightly increases performance of cursor | ! # fetches. | ! # 21APR2002 gh - Improved the array parsing, so that it now passes all | ! # the new mean testcases. Added support for parsing | ! # multidimensional arrays. Eventually, the array par- | ! # sing code should go as a support function into libpq. | ! # - Replaced all typechecks with "is" operators instead | ! # of equals. Mark McEahern had a problem with using | ! # pyPgSQL in combination with a FixedPoint class where | ! # the reason was that the FixedPoint class was not com- | ! # parable to None. The consensus on python-list was | ! # that None and all types are singletons, so they | ! # should be checked using "is", which is also faster, | ! # because it only checks for object identity. | # --------- bga Remove prior comments to reduce the size of the flower | ! # box. See revision 1.22 for earlier comments. | #--(H-)-----------------------------------------------------------------+ """ *************** *** 478,483 **** DATETIME = DBAPITypeObject('DATETIME', PG_DATE, PG_TIME, PG_TIMESTAMP, ! PG_ABSTIME, PG_RELTIME, PG_INTERVAL, ! PG_TINTERVAL) NUMBER = DBAPITypeObject('NUMBER', PG_INT8, PG_INT2, PG_INT4, PG_FLOAT4, --- 401,406 ---- DATETIME = DBAPITypeObject('DATETIME', PG_DATE, PG_TIME, PG_TIMESTAMP, ! PG_TIMESTAMPTZ, PG_ABSTIME, PG_RELTIME, ! PG_INTERVAL, PG_TINTERVAL) NUMBER = DBAPITypeObject('NUMBER', PG_INT8, PG_INT2, PG_INT4, PG_FLOAT4, *************** *** 497,501 **** OTHER = DBAPITypeObject('OTHER', PG_POINT, PG_LSEG, PG_PATH, PG_BOX, PG_POLYGON, PG_LINE, PG_CIDR, PG_CIRCLE, ! PG_INET, PG_MACADDR, PG_ACLITEM) #-----------------------------------------------------------------------+ --- 420,425 ---- OTHER = DBAPITypeObject('OTHER', PG_POINT, PG_LSEG, PG_PATH, PG_BOX, PG_POLYGON, PG_LINE, PG_CIDR, PG_CIRCLE, ! PG_INET, PG_MACADDR, PG_ACLITEM, ! PG_REFCURSOR) #-----------------------------------------------------------------------+ *************** *** 790,793 **** --- 714,719 ---- else: return PgBytea(value) + elif _ftv == PG_REFCURSOR: + return self.__conn.cursor(value, isRefCursor=PG_True) elif _ftv == OTHER: if isinstance(value, PgOther): *************** *** 898,901 **** --- 824,856 ---- return (self, other) + def __getitem__(self, index): + if type(index) is SliceType: + if index.step is None: + return PgOther(self.value[index.start:index.stop]) + else: + return PgOther(self.value[index.start:index.stop:index.step]) + + return self.value[index]; + + def __setitem__(self, index, item): + raise TypeError, "object doesn't support slice assignment" + + def __delitem__(self, index): + raise TypeError, "object doesn't support slice deletion" + + def __contains__(self, item): + return (item in self.value) + + if sys.version_info < (2, 0): + # They won't be defined if version is at least 2.0 final + def __getslice__(self, i, j): + return PgOther(self.value[max(0, i):max(0, j)]) + + def __setslice__(self, i, j, seq): + raise TypeError, "object doesn't support slice assignment" + + def __delslice__(self, i, j): + raise TypeError, "object doesn't support slice deletion" + # NOTE: A string is being concatenated to a PgOther, so the result type # is a PgOther *************** *** 920,923 **** --- 875,905 ---- return str(self.value) + def __hash__(self): + return hash(self.value) + + def __cmp__(self, other): + return cmp(self.value, other) + + def __rcmp__(self, other): + return cmp(other, self.value) + + def __lt__(self, other): + return self.value < other + + def __le__(self, other): + return self.value <= other + + def __eq__(self, other): + return self.value == other + + def __ne__(self, other): + return self.value != other + + def __gt__(self, other): + return self.value > other + + def __ge__(self, other): + return self.value >= other + # NOTE: A PgOther object will use the PgQuoteString() function in libpq. def __quote__(self, forArray=0): *************** *** 1116,1119 **** --- 1098,1130 ---- return (self, other) + def __getitem__(self, index): + if type(index) is SliceType: + if index.step is None: + return PgBytea(self.value[index.start:index.stop]) + else: + return PgBytea(self.value[index.start:index.stop:index.step]) + + return self.value[index]; + + def __setitem__(self, index, item): + raise TypeError, "object doesn't support slice assignment" + + def __delitem__(self, index): + raise TypeError, "object doesn't support slice deletion" + + def __contains__(self, item): + return (item in self.value) + + if sys.version_info < (2, 0): + # They won't be defined if version is at least 2.0 final + def __getslice__(self, i, j): + return PgBytea(self.value[max(0, i):max(0, j)]) + + def __setslice__(self, i, j, seq): + raise TypeError, "object doesn't support slice assignment" + + def __delslice__(self, i, j): + raise TypeError, "object doesn't support slice deletion" + def __add__(self, other): return PgBytea((self.value + other)) *************** *** 1134,1137 **** --- 1145,1175 ---- return str(self.value) + def __hash__(self): + return hash(self.value) + + def __cmp__(self, other): + return cmp(self.value, other) + + def __rcmp__(self, other): + return cmp(other, self.value) + + def __lt__(self, other): + return self.value < other + + def __le__(self, other): + return self.value <= other + + def __eq__(self, other): + return self.value == other + + def __ne__(self, other): + return self.value != other + + def __gt__(self, other): + return self.value > other + + def __ge__(self, other): + return self.value >= other + # NOTE: A PgBytea object will use the PgQuoteBytea() function in libpq def __quote__(self, forArray=0): *************** *** 2318,2322 **** "Rollback failed - %s" % res.resultErrorMessage ! def cursor(self, name=None): """ cursor([name]) --- 2356,2360 ---- "Rollback failed - %s" % res.resultErrorMessage ! def cursor(self, name=None, isRefCursor=PG_False): """ cursor([name]) *************** *** 2327,2331 **** "Create cursor failed - Connection is not open." ! return Cursor(self, name) def binary(self, string=None): --- 2365,2369 ---- "Create cursor failed - Connection is not open." ! return Cursor(self, name, isRefCursor) def binary(self, string=None): *************** *** 2396,2400 **** return res - #-----------------------------------------------------------------------+ # Name: Cursor | --- 2434,2437 ---- *************** *** 2407,2411 **** """Python DB-API 2.0 Cursor Object.""" ! def __init__(self, conn, name): if not isinstance(conn, Connection): raise TypeError, "Cursor requires a connection." --- 2444,2448 ---- """Python DB-API 2.0 Cursor Object.""" ! def __init__(self, conn, name, isRefCursor=PG_False): if not isinstance(conn, Connection): raise TypeError, "Cursor requires a connection." *************** *** 2413,2416 **** --- 2450,2455 ---- # Generate a unique name for the cursor is one is not given. if name is None: + if isRefCursor: + raise TypeError, "Reference cursor requires a name." name = "PgSQL_%08X" % id(self) elif type(name) is not StringType: *************** *** 2429,2435 **** # This needs to be defined here sot that the initial call to __reset() # will work. ! self.__dict__["closed"] = None ! ! self.__reset() # _varhdrsz is the length (in bytes) of the header for variable --- 2468,2473 ---- # This needs to be defined here sot that the initial call to __reset() # will work. ! self.__dict__["closed"] = None ! self.__reset() # _varhdrsz is the length (in bytes) of the header for variable *************** *** 2450,2464 **** # Only the first created cursor begins the transaction. if not self.conn.inTransaction: ! _nl = len(self.conn.notices) ! conn.conn.query("BEGIN WORK") ! if self.conn.TransactionLevel != "": ! self.conn.conn.query('SET TRANSACTION ISOLATION LEVEL %s' % ! self.conn.TransactionLevel) ! if len(self.conn.notices) != _nl: ! raise Warning, self.conn.notices.pop() ! self.conn.__dict__["inTransaction"] = 1 self.__dict__["PgResultSetClass"] = None ! def __del__(self): # Ensure that the cursor is closed when it is deleted. This takes --- 2488,2515 ---- # Only the first created cursor begins the transaction. if not self.conn.inTransaction: ! self.__setupTransaction() self.__dict__["PgResultSetClass"] = None + + if isRefCursor: + # Ok -- we've created a cursor, we will pre-fetch the first row in + # order to make the description array. Note: the first call to + # fetchXXX will return the pre-fetched record. + self.__dict__["closed"] = 0 + self.res = self.conn.conn.query('FETCH 1 FROM "%s"' % self.name) + self._rows_ = self.res.ntuples + self._idx_ = 0 + self.__makedesc__() ! def __setupTransaction(self): ! _nl = len(self.conn.notices) ! self.conn.conn.query("BEGIN WORK") ! if self.conn.TransactionLevel != "": ! self.conn.conn.query('SET TRANSACTION ISOLATION LEVEL %s' % ! self.conn.TransactionLevel) ! if len(self.conn.notices) != _nl: ! raise Warning, self.conn.notices.pop() ! self.conn.__dict__["inTransaction"] = 1 ! ! def __del__(self): # Ensure that the cursor is closed when it is deleted. This takes *************** *** 2682,2693 **** else: if not self.conn.inTransaction: ! _nl = len(self.conn.notices) ! self.conn.conn.query('BEGIN WORK') ! if self.conn.TransactionLevel != "": ! self.conn.conn.query('SET TRANSACTION ISOLATION LEVEL %s' % ! self.conn.TransactionLevel) ! if len(self.conn.notices) != _nl: ! raise Warning, self.conn.notices.pop() ! self.conn.__dict__["inTransaction"] = 1 proc = self.__unicodeConvert(proc) --- 2733,2737 ---- else: if not self.conn.inTransaction: ! self.__setupTransaction() proc = self.__unicodeConvert(proc) *************** *** 2792,2808 **** # so DROP TABLE/INDEX is ok. else: ! _nl = len(self.conn.notices) ! self.conn.conn.query('BEGIN WORK') ! if self.conn.TransactionLevel != "": ! self.conn.conn.query( ! 'SET TRANSACTION ISOLATION LEVEL %s' % ! self.conn.TransactionLevel) ! if len(self.conn.notices) != _nl: ! raise Warning, self.conn.notices.pop() ! self.conn.__dict__["inTransaction"] = 1 if re_DQL.search(query) and \ not (noPostgresCursor or re_4UP.search(query)): ! _qstr = "DECLARE %s CURSOR FOR %s" % (self.name, query) self.closed = 0 elif _badQuery and self.conn.inTransaction: --- 2836,2844 ---- # so DROP TABLE/INDEX is ok. else: ! self.__setupTransaction() if re_DQL.search(query) and \ not (noPostgresCursor or re_4UP.search(query)): ! _qstr = 'DECLARE "%s" CURSOR FOR %s' % (self.name, query) self.closed = 0 elif _badQuery and self.conn.inTransaction: *************** *** 2813,2825 **** pass # not in transaction so DROP TABLE/INDEX is ok. else: ! _nl = len(self.conn.notices) ! self.conn.conn.query('BEGIN WORK') ! if self.conn.TransactionLevel != "": ! self.conn.conn.query( ! 'SET TRANSACTION ISOLATION LEVEL %s' % ! self.conn.TransactionLevel) ! if len(self.conn.notices) != _nl: ! raise Warning, self.conn.notices.pop() ! self.conn.__dict__["inTransaction"] = 1 _nl = len(self.conn.notices) --- 2849,2853 ---- pass # not in transaction so DROP TABLE/INDEX is ok. else: ! self.__setupTransaction() _nl = len(self.conn.notices) *************** *** 2882,2886 **** # order to make the description array. Note: the first call to # fetchXXX will return the pre-fetched record. ! self.res = self.conn.conn.query("FETCH 1 FROM %s" % self.name) self._rows_ = self.res.ntuples self._idx_ = 0 --- 2910,2914 ---- # order to make the description array. Note: the first call to # fetchXXX will return the pre-fetched record. ! self.res = self.conn.conn.query('FETCH 1 FROM "%s"' % self.name) self._rows_ = self.res.ntuples self._idx_ = 0 *************** *** 2921,2925 **** elif self.closed == 0: _nl = len(self.conn.notices) ! self.res = self.conn.conn.query("FETCH 1 FROM %s" % self.name) self._rows_ = self.res.ntuples self._idx_ = 0 --- 2949,2953 ---- elif self.closed == 0: _nl = len(self.conn.notices) ! self.res = self.conn.conn.query('FETCH 1 FROM "%s"' % self.name) self._rows_ = self.res.ntuples self._idx_ = 0 *************** *** 2967,2971 **** if self.closed == 0 and sz > 0: _nl = len(self.conn.notices) ! self.res = self.conn.conn.query("FETCH %d FROM %s" % (sz, self.name)) self._rows_ = self.res.ntuples --- 2995,2999 ---- if self.closed == 0 and sz > 0: _nl = len(self.conn.notices) ! self.res = self.conn.conn.query('FETCH %d FROM "%s"' % (sz, self.name)) self._rows_ = self.res.ntuples *************** *** 3004,3008 **** if self.closed == 0: _nl = len(self.conn.notices) ! self.res = self.conn.conn.query("FETCH ALL FROM %s" % self.name) self._rows_ = self.res.ntuples self._idx_ = 0 --- 3032,3036 ---- if self.closed == 0: _nl = len(self.conn.notices) ! self.res = self.conn.conn.query('FETCH ALL FROM "%s"' % self.name) self._rows_ = self.res.ntuples self._idx_ = 0 |
From: Billy G. A. <bal...@us...> - 2002-12-01 04:59:31
|
Update of /cvsroot/pypgsql/pypgsql/test/regression In directory sc8-pr-cvs1:/tmp/cvs-serv16107/test/regression Modified Files: pgconnection.py pgresult.py pgversion.py 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: pgconnection.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/test/regression/pgconnection.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** pgconnection.py 17 Apr 2002 00:25:19 -0000 1.5 --- pgconnection.py 1 Dec 2002 04:59:25 -0000 1.6 *************** *** 35,38 **** --- 35,39 ---- # Date Ini Description | # --------- --- ------------------------------------------------------- | + # 30NOV2002 bga Updated tests for PostgreSQL 7.3. | # 17OCT2001 bga Added tests for lo_export(). | # 30SEP2001 bga Fixed a problem with the PgVersion object test related | *************** *** 206,210 **** Test sendQuery, consumeInput, and getResult. """ ! if self.vstr.startswith("7.2"): flen = 9 elif self.vstr.startswith("7.1"): --- 207,213 ---- Test sendQuery, consumeInput, and getResult. """ ! if self.vstr.startswith("7.3"): ! flen = 11 ! elif self.vstr.startswith("7.2"): flen = 9 elif self.vstr.startswith("7.1"): Index: pgresult.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/test/regression/pgresult.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** pgresult.py 17 Apr 2002 00:25:19 -0000 1.9 --- pgresult.py 1 Dec 2002 04:59:25 -0000 1.10 *************** *** 35,38 **** --- 35,39 ---- # Date Ini Description | # --------- --- ------------------------------------------------------- | + # 30NOV2002 bga Updated tests for PostgreSQL 7.3. | # 24SEP2001 bga Updated test case to use new string quoting method. | # 21SEP2001 bga Added check of the member types in certain test cases. | *************** *** 98,101 **** --- 99,104 ---- self.CheckForMethods(res) expected = [0, 'DROP', None, 0, 0, None, 1, 2 ] + if self.cnx.version >= '7.3': + expected[1] = 'DROP TABLE' self.CheckMemberValues(res, expected) # Try to drop the table again. This should raise an execption. *************** *** 114,117 **** --- 117,122 ---- self.CheckForMethods(res) expected = [0, 'CLOSE', None, 0, 0, None, 1, 2 ] + if self.cnx.version >= '7.3': + expected[1] = 'CLOSE CURSOR' self.CheckMemberValues(res, expected) *************** *** 123,133 **** self.CheckForMethods(res) expected = [0, 'FETCH', None, 0, 0, None, 1, 2 ] ! self.CheckMemberValues(res, expected) self.assertEquals(len(self.cnx.notices), 1, "A notice should of been generated, none was!") n = self.cnx.notices.pop() e = 'NOTICE: PerformPortalFetch: portal "pgres_cursor" not found\n' self.assertEquals(n, e, "The notice did not match expected results"); ! def CheckClosePgResult(self): res = self.cnx.query("CLOSE pgres_cursor") --- 128,142 ---- self.CheckForMethods(res) expected = [0, 'FETCH', None, 0, 0, None, 1, 2 ] ! if self.cnx.version >= '7.3': ! expected[1] = 'FETCH 0' ! self.CheckMemberValues(res, expected) self.assertEquals(len(self.cnx.notices), 1, "A notice should of been generated, none was!") n = self.cnx.notices.pop() e = 'NOTICE: PerformPortalFetch: portal "pgres_cursor" not found\n' + if self.cnx.version >= '7.3': + e = 'WARNING: PerformPortalFetch: portal "pgres_cursor" not found\n' self.assertEquals(n, e, "The notice did not match expected results"); ! def CheckClosePgResult(self): res = self.cnx.query("CLOSE pgres_cursor") *************** *** 135,138 **** --- 144,149 ---- self.CheckForMethods(res) expected = [0, 'CLOSE', None, 0, 0, None, 1, 2 ] + if self.cnx.version >= '7.3': + expected[1] = 'CLOSE CURSOR' self.CheckMemberValues(res, expected) *************** *** 142,145 **** --- 153,158 ---- self.CheckForMethods(res) expected = [1, 'FETCH', None, 2, 3, None, 2, 1 ] + if self.cnx.version >= '7.3': + expected[1] = 'FETCH 3' self.CheckMemberValues(res, expected) *************** *** 150,153 **** --- 163,168 ---- self.CheckForMethods(res) expected = [0, 'SELECT', None, 0, 0, None, 1, 2 ] + if self.cnx.version >= '7.3': + expected[1] = 'DECLARE CURSOR' self.CheckMemberValues(res, expected) *************** *** 157,163 **** --- 172,182 ---- self.CheckForMethods(res) expected = [0, 'MOVE', None, 0, 0, None, 1, 2 ] + if self.cnx.version >= '7.3': + expected[1] = 'MOVE 1' self.CheckMemberValues(res, expected) res = self.cnx.query("FETCH ALL FROM pgres_cursor") expected = [0, 'FETCH', None, 2, 4, None, 2, 1 ] + if self.cnx.version >= '7.3': + expected[1] = 'FETCH 4' self.CheckMemberValues(res, expected) *************** *** 167,170 **** --- 186,191 ---- self.CheckForMethods(res) expected = [0, 'FETCH', None, 2, 2, None, 2, 1 ] + if self.cnx.version >= '7.3': + expected[1] = 'FETCH 2' self.CheckMemberValues(res, expected) *************** *** 175,178 **** --- 196,201 ---- self.CheckForMethods(res) expected = [0, 'SELECT', None, 0, 0, None, 1, 2 ] + if self.cnx.version >= '7.3': + expected[1] = 'DECLARE CURSOR' self.CheckMemberValues(res, expected) *************** *** 226,229 **** --- 249,254 ---- self.CheckForMethods(res) expected = [0, 'CREATE', None, 0, 0, None, 1, 2 ] + if self.cnx.version >= '7.3': + expected[1] = 'CREATE TABLE' self.CheckMemberValues(res, expected) # Try to create the table again. This should raise an execption. *************** *** 231,235 **** def CheckPgResult(self): ! if self.vstr.startswith("7.2"): flen = 9 elif self.vstr.startswith("7.1"): --- 256,262 ---- def CheckPgResult(self): ! if self.vstr.startswith("7.3"): ! flen = 11 ! elif self.vstr.startswith("7.2"): flen = 9 elif self.vstr.startswith("7.1"): *************** *** 274,277 **** --- 301,306 ---- res = self.cnx.query("DROP TABLE pgresult_test") expected = [0, 'DROP', None, 0, 0, None, 1, 2 ] + if self.cnx.version >= '7.3': + expected[1] = 'DROP TABLE' self.CheckMemberValues(res, expected) self.failUnlessRaises(libpq.InterfaceError, res.fmod, 0) *************** *** 300,303 **** --- 329,334 ---- res = self.cnx.query("CLOSE pgres_cursor") expected = [0, 'CLOSE', None, 0, 0, None, 1, 2 ] + if self.cnx.version >= '7.3': + expected[1] = 'CLOSE CURSOR' self.CheckMemberValues(res, expected) self.failUnlessRaises(libpq.InterfaceError, res.fmod, 0) *************** *** 326,329 **** --- 357,362 ---- res = self.cnx.query("FETCH 2 FROM pgres_cursor") expected = [0, 'FETCH', None, 2, 2, None, 2, 1 ] + if self.cnx.version >= '7.3': + expected[1] = 'FETCH 2' self.CheckMemberValues(res, expected) self.assertEquals(res.fmod(0), -1, *************** *** 356,359 **** --- 389,394 ---- ORDER BY f1""") expected = [0, 'SELECT', None, 0, 0, None, 1, 2 ] + if self.cnx.version >= '7.3': + expected[1] = 'DECLARE CURSOR' self.CheckMemberValues(res, expected) self.failUnlessRaises(libpq.InterfaceError, res.fmod, 0) *************** *** 459,462 **** --- 494,499 ---- res = self.cnx.query(query) expected = [0, 'CREATE', None, 0, 0, None, 1, 2 ] + if self.cnx.version >= '7.3': + expected[1] = 'CREATE TABLE' self.CheckMemberValues(res, expected) self.failUnlessRaises(libpq.InterfaceError, res.fmod, 0) *************** *** 470,474 **** def CheckPgResult(self): ! if self.vstr.startswith("7.2"): flen = 9 elif self.vstr.startswith("7.1"): --- 507,513 ---- def CheckPgResult(self): ! if self.vstr.startswith("7.3"): ! flen = 11 ! elif self.vstr.startswith("7.2"): flen = 9 elif self.vstr.startswith("7.1"): Index: pgversion.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/test/regression/pgversion.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** pgversion.py 12 Jan 2002 23:20:14 -0000 1.5 --- pgversion.py 1 Dec 2002 04:59:25 -0000 1.6 *************** *** 34,37 **** --- 34,39 ---- # Date Ini Description | # --------- --- ------------------------------------------------------- | + # 30NOV2002 bga Added tests for alpha, beta, and relase canidate vers. | + # --- Updated tests for PostgreSQL 7.3. | # 12JAN2001 bga Added test to check for correct operation of the fix | # for bug #486151. | *************** *** 165,168 **** --- 167,197 ---- try: + if version < 20100: + a, b = coerce(vers, '7.3rc2') + vers == b + else: + vers == '7.3rc2' + except ValueError, msg: + self.fail('Comparison to release canidate version failed.') + + try: + if version < 20100: + a, b = coerce(vers, '7.3b3') + vers == b + else: + vers == '7.3b3' + except ValueError, msg: + self.fail('Comparison to release canidate version failed.') + + try: + if version < 20100: + a, b = coerce(vers, '7.3a3') + vers == b + else: + vers == '7.3a3' + except ValueError, msg: + self.fail('Comparison to release canidate version failed.') + + try: vers == 4294967296L self.fail('Comparison to large valued long succeeded.') *************** *** 257,261 **** major = int(a[0]) minor = int(a[1]) ! if len(a[2]) == 0: level = 0 else: --- 286,290 ---- major = int(a[0]) minor = int(a[1]) ! if len(a) < 3: level = 0 else: |
From: Billy G. A. <bal...@us...> - 2002-12-01 04:59:31
|
Update of /cvsroot/pypgsql/pypgsql/test In directory sc8-pr-cvs1:/tmp/cvs-serv16107/test Modified Files: PgSQLTestCases.py 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: PgSQLTestCases.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/test/PgSQLTestCases.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** PgSQLTestCases.py 11 Nov 2002 04:02:30 -0000 1.24 --- PgSQLTestCases.py 1 Dec 2002 04:59:25 -0000 1.25 *************** *** 33,36 **** --- 33,37 ---- # Date Ini Description | # --------- --- ------------------------------------------------------- | + # 30NOV2002 bga Updated tests for PostgreSQL 7.3. | # 10NOV2002 bga Added an additional PgNumeric class check. | # 27OCT2002 gh Don't check for the obsolete displaysize field in | *************** *** 401,404 **** --- 402,415 ---- self.cur = self.cnx.cursor() self.vstr = "%(major)d.%(minor)d" % self.cnx.version + if self.cnx.version < '7.3': + self.expd = [['datname',PgSQL.PG_NAME,32,32,None,None,None,0], + ['datdba',PgSQL.PG_INT4,4,4,None,None,None,0], + ['encoding',PgSQL.PG_INT4,4,4,None,None,None,0], + ['datpath',PgSQL.PG_TEXT,-5,-1,None,None,None,0]] + else: + self.expd = [['datname',PgSQL.PG_NAME,64,64,None,None,None,0], + ['datdba',PgSQL.PG_INT4,4,4,None,None,None,0], + ['encoding',PgSQL.PG_INT4,4,4,None,None,None,0], + ['datacl',PgSQL.PG_ACLITEM,-5,-1,None,None,None,1]] def tearDown(self): *************** *** 605,611 **** """Test execute() with a singleton string as the parameter.""" ! if self.vstr == "7.2": flen = 9 ! elif self.vstr == "7.1": flen = 7 else: --- 616,624 ---- """Test execute() with a singleton string as the parameter.""" ! if self.vstr.startswith("7.3"): ! flen = 11 ! elif self.vstr.startswith("7.2"): flen = 9 ! elif self.vstr.startswith("7.1"): flen = 7 else: *************** *** 635,646 **** len(self.cur.description[0])) ! ! self.failUnless(self.cur.description[0][0] == "datname" and ! self.cur.description[0][1] == PgSQL.PG_NAME and ! self.cur.description[0][3] == 32 and ! self.cur.description[0][4] == None and ! self.cur.description[0][5] == None and ! self.cur.description[0][6] == None and ! self.cur.description[0][7] == 0, "cur.description[0] does not match the query.") self.cur.close() --- 648,658 ---- len(self.cur.description[0])) ! self.failUnless(self.cur.description[0][0] == self.expd[0][0] and ! self.cur.description[0][1] == self.expd[0][1] and ! self.cur.description[0][3] == self.expd[0][3] and ! self.cur.description[0][4] == self.expd[0][4] and ! self.cur.description[0][5] == self.expd[0][5] and ! self.cur.description[0][6] == self.expd[0][6] and ! self.cur.description[0][7] == self.expd[0][7], "cur.description[0] does not match the query.") self.cur.close() *************** *** 655,665 **** self.fail(msg) ! self.failUnless(self.cur.description[0][0] == "datname" and ! self.cur.description[0][1] == PgSQL.PG_NAME and ! self.cur.description[0][3] == 32 and ! self.cur.description[0][4] == None and ! self.cur.description[0][5] == None and ! self.cur.description[0][6] == None and ! self.cur.description[0][7] == 0, "cur.description[0] does not match the query.") self.cur.close() --- 667,677 ---- self.fail(msg) ! self.failUnless(self.cur.description[0][0] == self.expd[0][0] and ! self.cur.description[0][1] == self.expd[0][1] and ! self.cur.description[0][3] == self.expd[0][3] and ! self.cur.description[0][4] == self.expd[0][4] and ! self.cur.description[0][5] == self.expd[0][5] and ! self.cur.description[0][6] == self.expd[0][6] and ! self.cur.description[0][7] == self.expd[0][7], "cur.description[0] does not match the query.") self.cur.close() *************** *** 674,712 **** self.fail(msg) ! self.failUnless(self.cur.description[0][0] == "datname" and ! self.cur.description[0][1] == PgSQL.PG_NAME and ! self.cur.description[0][3] == 32 and ! self.cur.description[0][4] == None and ! self.cur.description[0][5] == None and ! self.cur.description[0][6] == None and ! self.cur.description[0][7] == 0, "cur.description[0] does not match the query.") ! self.failUnless(self.cur.description[1][0] == "datdba" and ! self.cur.description[1][1] == PgSQL.PG_INT4 and ! self.cur.description[1][3] == 4 and ! self.cur.description[1][4] == None and ! self.cur.description[1][5] == None and ! self.cur.description[1][6] == None and ! self.cur.description[1][7] == 0, "cur.description[1] does not match the query.") ! self.failUnless(self.cur.description[2][0] == "encoding" and ! self.cur.description[2][1] == PgSQL.PG_INT4 and ! self.cur.description[2][3] == 4 and ! self.cur.description[2][4] == None and ! self.cur.description[2][5] == None and ! self.cur.description[2][6] == None and ! self.cur.description[2][7] == 0, "cur.description[2] does not match the query.") ! clen = len(self.cur.description) ! self.failUnless(self.cur.description[clen - 1][0] == "datpath" and ! self.cur.description[clen - 1][1] == PgSQL.PG_TEXT and ! self.cur.description[clen - 1][3] == -1 and ! self.cur.description[clen - 1][4] == None and ! self.cur.description[clen - 1][5] == None and ! self.cur.description[clen - 1][6] == None and ! self.cur.description[clen - 1][7] == 0, "cur.description[3] does not match the query.") --- 686,724 ---- self.fail(msg) ! self.failUnless(self.cur.description[0][0] == self.expd[0][0] and ! self.cur.description[0][1] == self.expd[0][1] and ! self.cur.description[0][3] == self.expd[0][3] and ! self.cur.description[0][4] == self.expd[0][4] and ! self.cur.description[0][5] == self.expd[0][5] and ! self.cur.description[0][6] == self.expd[0][6] and ! self.cur.description[0][7] == self.expd[0][7], "cur.description[0] does not match the query.") ! self.failUnless(self.cur.description[1][0] == self.expd[1][0] and ! self.cur.description[1][1] == self.expd[1][1] and ! self.cur.description[1][3] == self.expd[1][3] and ! self.cur.description[1][4] == self.expd[1][4] and ! self.cur.description[1][5] == self.expd[1][5] and ! self.cur.description[1][6] == self.expd[1][6] and ! self.cur.description[1][7] == self.expd[1][7], "cur.description[1] does not match the query.") ! self.failUnless(self.cur.description[2][0] == self.expd[2][0] and ! self.cur.description[2][1] == self.expd[2][1] and ! self.cur.description[2][3] == self.expd[2][3] and ! self.cur.description[2][4] == self.expd[2][4] and ! self.cur.description[2][5] == self.expd[2][5] and ! self.cur.description[2][6] == self.expd[2][6] and ! self.cur.description[2][7] == self.expd[2][7], "cur.description[2] does not match the query.") ! clen = len(self.cur.description) - 1 ! self.failUnless(self.cur.description[clen][0] == self.expd[3][0] and ! self.cur.description[clen][1] == self.expd[3][1] and ! self.cur.description[clen][3] == self.expd[3][3] and ! self.cur.description[clen][4] == self.expd[3][4] and ! self.cur.description[clen][5] == self.expd[3][5] and ! self.cur.description[clen][6] == self.expd[3][6] and ! self.cur.description[clen][7] == self.expd[3][7], "cur.description[3] does not match the query.") *************** *** 787,791 **** # Note: We only have to check for the minor version number in order # to determine the needed row counts. ! rc = { '7.2':101, '7.1':80, '7.0':65, '6.5':47 } v = self.vstr --- 799,803 ---- # Note: We only have to check for the minor version number in order # to determine the needed row counts. ! rc = { '7.3':124, '7.2':101, '7.1':80, '7.0':65, '6.5':47 } v = self.vstr |
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 |
From: Billy G. A. <bal...@us...> - 2002-11-11 04:02:34
|
Update of /cvsroot/pypgsql/pypgsql/test In directory usw-pr-cvs1:/tmp/cvs-serv3426/test Modified Files: PgSQLTestCases.py Log Message: 10NOV2002 bga Added an additional PgNumeric class check. Index: PgSQLTestCases.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/test/PgSQLTestCases.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** PgSQLTestCases.py 27 Oct 2002 04:07:50 -0000 1.23 --- PgSQLTestCases.py 11 Nov 2002 04:02:30 -0000 1.24 *************** *** 33,36 **** --- 33,37 ---- # Date Ini Description | # --------- --- ------------------------------------------------------- | + # 10NOV2002 bga Added an additional PgNumeric class check. | # 27OCT2002 gh Don't check for the obsolete displaysize field in | # cursor.description. Also don't check the backend enco- | *************** *** 383,386 **** --- 384,396 ---- self.failUnless(str(c) == '100.000', 'PgNumeric divisioncast failed.') + + # Check for correct precision after a carry in the high-order digit + a = PgSQL.PgNumeric('999999.99') + c = a + b + self.failUnless(c.getPrecision() == 14, 'PgNumeric addition failed') + self.failUnless(c.getScale() == 7, 'PgNumeric addition failed') + self.failUnless(str(c) == '1000012.3356789', + 'PgNumeric addition failed.') + except StandardError, msg: self.fail(msg) |
From: Billy G. A. <bal...@us...> - 2002-11-11 03:56:46
|
Update of /cvsroot/pypgsql/pypgsql/pyPgSQL In directory usw-pr-cvs1:/tmp/cvs-serv1419/pyPgSQL Modified Files: PgSQL.py Log Message: 10NOV2002 bga - Added the __hash__ function to the PgNumeric class. - Cleaned up the code in PgNumeric class and made some small improvments to it. Index: PgSQL.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pyPgSQL/PgSQL.py,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** PgSQL.py 3 Nov 2002 19:48:48 -0000 1.21 --- PgSQL.py 11 Nov 2002 03:56:42 -0000 1.22 *************** *** 30,33 **** --- 30,36 ---- # Date Ini Description | # --------- --- ------------------------------------------------------- | + # 10NOV2002 bga - Added the __hash__ function to the PgNumeric class. | + # Cleaned up the code in PgNumeric class and made some | + # small improvments to it. | # 02NOV2002 bga - Added the PgArray class. This is a wrapper around a | # Python list and is used for all PostgreSQL arrays. | *************** *** 1270,1273 **** --- 1273,1281 ---- raise TypeError, "value can not be converted to a PgNumeric." + # The value (10L ** self.__s) is used a lot. Save it as a constant + # to save a (small) bit of time. + + self.__sf = 10L ** self.__s + def __fmtNumeric(self, value=None): # Check to see if the string representation of the python long has *************** *** 1330,1352 **** self, other = _c if self.__s < other.__s: ! _sc = other.__s ! _ds = other.__s - self.__s ! _s = self.__v * (10L ** _ds) _o = other.__v elif self.__s > other.__s: - _sc = self.__s - _ds = self.__s - other.__s _s = self.__v ! _o = other.__v * (10L ** _ds) else: - _sc = self.__s _s = self.__v _o = other.__v - if (self.__p - self.__s) >= (other.__p - other.__s): - _pr = self.__p - self.__s + _sc - else: - _pr = other.__p - other.__s + sc ! return PgNumeric((_s + _o), _pr, _sc) def __radd__(self, other): --- 1338,1359 ---- self, other = _c if self.__s < other.__s: ! _s = self.__v * (other.__sf / self.__sf) _o = other.__v elif self.__s > other.__s: _s = self.__v ! _o = other.__v * (self.__sf / other.__sf) else: _s = self.__v _o = other.__v ! mp = max(self.__p - self.__s, other.__p - other.__s) ! ms = max(self.__s, other.__s) ! v = _s + _o ! # Check to see if the addition caused an increase in the precision ! # due to a carry. If so, compensate for it. ! if (v / (10L ** (mp + ms))) > 0: ! mp = mp + 1 ! ! return PgNumeric((_s + _o), (mp + ms), ms) def __radd__(self, other): *************** *** 1357,1363 **** if _r is None: return None ! self.__v = _r.__v ! self.__p = _r.__p ! self.__s = _r.__s return self --- 1364,1371 ---- if _r is None: return None ! self.__v = _r.__v ! self.__p = _r.__p ! self.__s = _r.__s ! self.__sf = _r.__sf return self *************** *** 1368,1412 **** self, other = _c if self.__s < other.__s: ! _sc = other.__s ! _ds = other.__s - self.__s ! _s = self.__v * (10L ** _ds) _o = other.__v elif self.__s > other.__s: - _sc = self.__s - _ds = self.__s - other.__s _s = self.__v ! _o = other.__v * (10L ** _ds) else: - _sc = self.__s _s = self.__v _o = other.__v - if (self.__p - self.__s) >= (other.__p - other.__s): - _pr = self.__p - self.__s + _sc - else: - _pr = other.__p - other.__s + sc ! return PgNumeric((_s - _o), _pr, _sc) def __rsub__(self, other): ! if self.__s < other.__s: ! _sc = other.__s ! _ds = other.__s - self.__s ! _s = self.__v * (10L ** _ds) ! _o = other.__v ! elif self.__s > other.__s: ! _sc = self.__s ! _ds = self.__s - other.__s ! _s = self.__v ! _o = other.__v * (10L ** _ds) ! else: ! _sc = self.__s ! _s = self.__v ! _o = other.__v ! if (self.__p - self.__s) >= (other.__p - other.__s): ! _pr = self.__p - self.__s + _sc ! else: ! _pr = other.__p - other.__s + sc ! ! return PgNumeric((_o - _s), _pr, _sc) def __isub__(self, other): --- 1376,1394 ---- self, other = _c if self.__s < other.__s: ! _s = self.__v * (other.__sf / self.__sf) _o = other.__v elif self.__s > other.__s: _s = self.__v ! _o = other.__v * (self.__sf / other.__sf) else: _s = self.__v _o = other.__v ! mp = max(self.__p - self.__s, other.__p - other.__s) ! ms = max(self.__s, other.__s) ! return PgNumeric((_s - _o), (mp + ms), ms) def __rsub__(self, other): ! return self.__sub__(other, self) def __isub__(self, other): *************** *** 1414,1420 **** if _r is None: return None ! self.__v = _r.__v ! self.__p = _r.__p ! self.__s = _r.__s return self --- 1396,1403 ---- if _r is None: return None ! self.__v = _r.__v ! self.__p = _r.__p ! self.__s = _r.__s ! self.__sf = _r.__sf return self *************** *** 1434,1440 **** if _r is None: return None ! self.__v = _r.__v ! self.__p = _r.__p ! self.__s = _r.__s return self --- 1417,1424 ---- if _r is None: return None ! self.__v = _r.__v ! self.__p = _r.__p ! self.__s = _r.__s ! self.__sf = _r.__sf return self *************** *** 1444,1461 **** return None self, other = _c ! _n = (self.__v * (10L ** (other.__s + 1))) _d = other.__v ! _q = (_n / _d) ! return PgNumeric(self._round(_q, 1), self.__p, self.__s) def __rdiv__(self, other): ! _c = self.__coerce__(other) ! if _c is None: ! return None ! self, other = _c ! _n = (other.__v * (10L ** (self.__s + 1))) ! _d = self.__v ! _q = (_n / _d) ! return PgNumeric(self._round(_q, 1), other.__p, other.__s) def __idiv__(self, other): --- 1428,1438 ---- return None self, other = _c ! _n = self.__v * other.__sf * self.__sf _d = other.__v ! _q = self._round((_n / _d), self.__s) ! return PgNumeric(_q, self.__p, self.__s) def __rdiv__(self, other): ! return self.__div__(other, self) def __idiv__(self, other): *************** *** 1463,1469 **** if _r is None: return None ! self.__v = _r.__v ! self.__p = _r.__p ! self.__s = _r.__s return self --- 1440,1447 ---- if _r is None: return None ! self.__v = _r.__v ! self.__p = _r.__p ! self.__s = _r.__s ! self.__sf = _r.__sf return self *************** *** 1476,1486 **** self, other = _c if self.__s < other.__s: ! _d = other.__s - self.__s ! _s = (self.__v * (10L ** _d)) _o = other.__v elif self.__s > other.__s: - _d = self.__s - other.__s _s = self.__v ! _o = (other.__v * (10L ** _d)) else: _s = self.__v --- 1454,1462 ---- self, other = _c if self.__s < other.__s: ! _s = self.__v * (other.__sf / self.__sf) _o = other.__v elif self.__s > other.__s: _s = self.__v ! _o = other.__v * (self.__sf / other.__sf) else: _s = self.__v *************** *** 1495,1505 **** def __pos__(self): ! return self def __abs__(self): if self.__v >= 0: ! return self else: ! return -self def __quote__(self, forArray=0): --- 1471,1481 ---- def __pos__(self): ! return PgNumeric(self.__v, self.__p, self.__s) def __abs__(self): if self.__v >= 0: ! return PgNumeric(self.__v, self.__p, self.__s) else: ! return PgNumeric(-self.__v, self.__p, self.__s) def __quote__(self, forArray=0): *************** *** 1512,1527 **** def __int__(self): ! return int(self.__v / (10L ** self.__s)) def __long__(self): ! return self.__v / (10L ** self.__s) def __float__(self): v = self.__v ! s = 10L ** self.__s return (float(v / s) + (float(v % s) / float(s))) def __complex__(self): return complex(self.__float__()) #-----------------------------------------------------------------------+ --- 1488,1511 ---- def __int__(self): ! return int(self.__v / self.__sf) def __long__(self): ! return self.__v / self.__sf def __float__(self): v = self.__v ! s = self.__sf return (float(v / s) + (float(v % s) / float(s))) def __complex__(self): return complex(self.__float__()) + + def __hash__(self): + if self.__s == 0: + return hash(self.__v) + v = self.__v / self.__sf + if (v * self.__sf) == self.__v: + return hash(v) + return hash(float(self)) #-----------------------------------------------------------------------+ |
From: Billy G. A. <bal...@us...> - 2002-11-03 20:39:59
|
Update of /cvsroot/pypgsql/pypgsql In directory usw-pr-cvs1:/tmp/cvs-serv14948 Modified Files: README Log Message: 03NOV2002 bga Added information about the new PgArray class. Index: README =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/README,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** README 27 Oct 2002 03:43:07 -0000 1.26 --- README 3 Nov 2002 20:39:55 -0000 1.27 *************** *** 1460,1463 **** --- 1460,1467 ---- that fall within this class. + :PgArray: This class provide support for PostgreSQL arrays. It is a + wrapper around a Python list that supports all the methods of + a list plus adds a __quote__ method for quoting arrays. + 3. The following class is defined: *************** *** 1576,1585 **** a new transaction is created on the next call to execute(). ! If a PostgreSQL array (represented by a Python list) is the only parameter to ! a query, then it must be passed in a singleton tuple. For example:: ! cnx.query('insert into table values(%s)', (list,)) When working with PostgreSQL large object, you MUST be in a transaction. --- 1580,1602 ---- 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),)) ! It will generate the following SQL statement: ! ! select * from table where column1 in (1, 3, 4) + It also means that to insert an PostgreSQL array, you must pass a PgArray + instance to Cursor.execute(). For example, if you have a list that you + want to insert into a table as a PostgreSQL array, you would use: + + cursor.execute('insert in sometable values (%s)', PgArray(yourlist)) + + 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. |
From: Billy G. A. <bal...@us...> - 2002-11-03 19:54:35
|
Update of /cvsroot/pypgsql/pypgsql In directory usw-pr-cvs1:/tmp/cvs-serv614 Modified Files: pgboolean.c pglargeobject.c Log Message: 02NOV2002 bga Change the name of the quoting function to __quote__. Index: pgboolean.c =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pgboolean.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** pgboolean.c 26 Sep 2001 05:45:30 -0000 1.10 --- pgboolean.c 3 Nov 2002 19:54:32 -0000 1.11 *************** *** 33,36 **** --- 33,37 ---- | Date Ini Description | | --------- --- ------------------------------------------------------- | + | 02NOV2002 bga Change the name of the quoting function to __quote__. | | 26SEP2001 bga Change the constructors so that they return PyObject * | | instead of PgBooleanObject *. | *************** *** 250,254 **** static PyMethodDef bool_methods[] = { ! { "_quote", (PyCFunction)bool_quote, 1 }, { NULL, NULL } }; --- 251,255 ---- static PyMethodDef bool_methods[] = { ! { "__quote__", (PyCFunction)bool_quote, 1 }, { NULL, NULL } }; Index: pglargeobject.c =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pglargeobject.c,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** pglargeobject.c 19 Oct 2002 14:34:55 -0000 1.13 --- pglargeobject.c 3 Nov 2002 19:54:32 -0000 1.14 *************** *** 30,33 **** --- 30,34 ---- | Date Ini Description | | --------- --- ------------------------------------------------------- | + | 02NOV2002 bga Change the name of the quoting function to __quote__. | | 19OCT2002 gh Made the 'closed' attribute of PgLargeObject an int | | instead of a long. | *************** *** 1273,1277 **** { "writelines", (PyCFunction)PgLo_writelines, 1, PgLo_writelines_Doc}, { "export", (PyCFunction)PgLo_export, 1, PgLo_export_Doc}, ! { "_quote", (PyCFunction)PgLo_quote, 1}, { "_pickle", (PyCFunction)PgLo_pickle, 1}, { NULL, NULL } --- 1274,1278 ---- { "writelines", (PyCFunction)PgLo_writelines, 1, PgLo_writelines_Doc}, { "export", (PyCFunction)PgLo_export, 1, PgLo_export_Doc}, ! { "__quote__", (PyCFunction)PgLo_quote, 1}, { "_pickle", (PyCFunction)PgLo_pickle, 1}, { NULL, NULL } |
From: Billy G. A. <bal...@us...> - 2002-11-03 19:53:25
|
Update of /cvsroot/pypgsql/pypgsql/test/regression In directory usw-pr-cvs1:/tmp/cvs-serv31831/test/regression Modified Files: array.py Log Message: 02NOV2002 bga Modified code to use the PgArray class for PostgreSQL arrays. Index: array.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/test/regression/array.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** array.py 21 Apr 2002 21:05:43 -0000 1.2 --- array.py 3 Nov 2002 19:53:22 -0000 1.3 *************** *** 35,38 **** --- 35,40 ---- # Date Ini Description | # --------- --- ------------------------------------------------------- | + # 02NOV2002 bga Modified code to use the PgArray class for PostgreSQL | + # arrays. | # 21APR2002 gh Added some more mean testcases, which test for control | # characters and other special characters inside strings, | *************** *** 43,46 **** --- 45,49 ---- import sys from pyPgSQL import PgSQL + PgArray = PgSQL.PgArray class ArrayTestCases(unittest.TestCase): *************** *** 50,58 **** def checkEqual(self, real, planned): ! self.failUnlessEqual(real, planned, \ "Received %s, should have been %s" % (repr(real), repr(planned))) def CheckForIntegerInsert(self): ! ivalues = [3,4,5] cursor = self.conn.cursor() try: --- 53,61 ---- def checkEqual(self, real, planned): ! self.failUnlessEqual(real.value, planned.value, \ "Received %s, should have been %s" % (repr(real), repr(planned))) def CheckForIntegerInsert(self): ! ivalues = PgArray([3,4,5]) cursor = self.conn.cursor() try: *************** *** 61,73 **** pass cursor.execute("create table test (ia int[])") ! cursor.execute("insert into test(ia) values (%s)", (ivalues,)) cursor.execute("select ia from test") result = cursor.fetchone() ! self.failUnlessEqual(type(result.ia), types.ListType, \ ! "the integer array isn't returned as a list") self.checkEqual(result.ia, ivalues) def CheckForNumericInsert(self): ! numlist = map(PgSQL.PgNumeric, ['4.7', '-3.2', '23.17']) cursor = self.conn.cursor() --- 64,76 ---- pass cursor.execute("create table test (ia int[])") ! cursor.execute("insert into test(ia) values (%s)", ivalues) cursor.execute("select ia from test") result = cursor.fetchone() ! self.failUnless(isinstance(result.ia, PgArray), \ ! "the integer array isn't returned as a PgArray") self.checkEqual(result.ia, ivalues) def CheckForNumericInsert(self): ! numlist = PgArray(map(PgSQL.PgNumeric, ['4.7', '-3.2', '23.17'])) cursor = self.conn.cursor() *************** *** 77,85 **** pass cursor.execute("create table test(na numeric[])") ! cursor.execute("insert into test(na) values (%s)", (numlist,)) cursor.execute("select na from test") result = cursor.fetchone() ! self.failUnlessEqual(type(result.na), types.ListType, \ ! "the numeric array isn't returned as a list") self.checkEqual(result.na, numlist) --- 80,88 ---- pass cursor.execute("create table test(na numeric[])") ! cursor.execute("insert into test(na) values (%s)", numlist) cursor.execute("select na from test") result = cursor.fetchone() ! self.failUnless(isinstance(result.na, PgArray), \ ! "the numeric array isn't returned as a PgArray") self.checkEqual(result.na, numlist) *************** *** 87,98 **** cursor = self.conn.cursor() ! stringlists = [['hey', 'you', 'there'], ! ['fancy', ',', '{chars}', '"'], ! ['what about', 'some \\backslashes'], ! ['some more \\', '\\ and \\ etc'], ! ['aa', '%s\n%s' % (chr(10), chr(29))], ! ['what about backslashes', 'at the end\\'], ! ['interesting', '"', '\\"', '\\"\\'], ! ['{}\\', '"\\}}\\\'"']] for stringlist in stringlists: --- 90,101 ---- cursor = self.conn.cursor() ! stringlists = PgArray([['hey', 'you', 'there'], ! ['fancy', ',', '{chars}', '"'], ! ['what about', 'some \\backslashes'], ! ['some more \\', '\\ and \\ etc'], ! ['aa', '%s\n%s' % (chr(10), chr(29))], ! ['what about backslashes', 'at the end\\'], ! ['interesting', '"', '\\"', '\\"\\'], ! ['{}\\', '"\\}}\\\'"']]) for stringlist in stringlists: *************** *** 102,110 **** pass cursor.execute("create table test(va varchar[])") ! cursor.execute("insert into test(va) values (%s)", (stringlist,)) cursor.execute("select va from test") result = cursor.fetchone() ! self.failUnlessEqual(type(result.va), types.ListType, \ ! "the varchar array isn't returned as a list") self.checkEqual(result.va, stringlist) --- 105,113 ---- pass cursor.execute("create table test(va varchar[])") ! cursor.execute("insert into test(va) values (%s)", stringlist) cursor.execute("select va from test") result = cursor.fetchone() ! self.failUnless(isinstance(result.va, PgArray), \ ! "the varchar array isn't returned as a PgArray") self.checkEqual(result.va, stringlist) *************** *** 123,131 **** for j in chars: for k in chars: ! cursor.execute("insert into test(va) values (%s)", ([i+j+k],)) cursor.execute("select va from test where oid=%s", cursor.oidValue) result = cursor.fetchone() ! self.failUnlessEqual(type(result.va), types.ListType, \ ! "the varchar array isn't returned as a list") self.checkEqual(result.va, [i+j+k]) --- 126,134 ---- for j in chars: for k in chars: ! cursor.execute("insert into test(va) values (%s)", PgArray([i+j+k])) cursor.execute("select va from test where oid=%s", cursor.oidValue) result = cursor.fetchone() ! self.failUnless(isinstance(result.va, PgArray), \ ! "the varchar array isn't returned as a PgArray") self.checkEqual(result.va, [i+j+k]) *************** *** 133,140 **** cursor = self.conn.cursor() ! stringlists = [[["a", "b"], ["c", "d"]], ! [[["a", "b"], ["c", "d"]], [["e", None], ["g", "h"]]], ! [[["{}", "\005{}\\'"], ["'asf'", "[\\{]"]], [["e", "f"], ["g", "h"]]], ! [["a", "b"], ["c", "d"]]] for stringlist in stringlists: --- 136,145 ---- cursor = self.conn.cursor() ! stringlists = PgArray([[["a", "b"], ["c", "d"]], ! [[["a", "b"], ["c", "d"]], ! [["e", None], ["g", "h"]]], ! [[["{}", "\005{}\\'"], ["'asf'", "[\\{]"]], ! [["e", "f"], ["g", "h"]]], ! [["a", "b"], ["c", "d"]]]) for stringlist in stringlists: *************** *** 144,152 **** pass cursor.execute("create table test(va varchar[])") ! cursor.execute("insert into test(va) values (%s)", (stringlist,)) cursor.execute("select va from test") result = cursor.fetchone() ! self.failUnlessEqual(type(result.va), types.ListType, \ ! "the varchar array isn't returned as a list") expected = stringlist[:] --- 149,157 ---- pass cursor.execute("create table test(va varchar[])") ! cursor.execute("insert into test(va) values (%s)", stringlist) cursor.execute("select va from test") result = cursor.fetchone() ! self.failUnless(isinstance(result.va, PgArray), \ ! "the varchar array isn't returned as a PgArray") expected = stringlist[:] *************** *** 162,170 **** cursor = self.conn.cursor() ! intlists = [[[1,2], [3,4]], ! [[-5,3,4], [2, None, 10]]] ! excpected_intlists = [[[1,2], [3,4]], ! [[-5,3,4], [2, 0, 10]]] for intlist, expected in zip(intlists, excpected_intlists): --- 167,175 ---- cursor = self.conn.cursor() ! intlists = PgArray([[[1,2], [3,4]], ! [[-5,3,4], [2, None, 10]]]) ! excpected_intlists = PgArray([[[1,2], [3,4]], ! [[-5,3,4], [2, 0, 10]]]) for intlist, expected in zip(intlists, excpected_intlists): *************** *** 174,182 **** pass cursor.execute("create table test(ia int[])") ! cursor.execute("insert into test(ia) values (%s)", (intlist,)) cursor.execute("select ia from test") result = cursor.fetchone() ! self.failUnlessEqual(type(result.ia), types.ListType, \ ! "the int array isn't returned as a list") self.checkEqual(result.ia, expected) --- 179,187 ---- pass cursor.execute("create table test(ia int[])") ! cursor.execute("insert into test(ia) values (%s)", intlist) cursor.execute("select ia from test") result = cursor.fetchone() ! self.failUnless(isinstance(result.ia, PgArray), \ ! "the int array isn't returned as a PgArray") self.checkEqual(result.ia, expected) |
From: Billy G. A. <bal...@us...> - 2002-11-03 19:48:52
|
Update of /cvsroot/pypgsql/pypgsql/pyPgSQL In directory usw-pr-cvs1:/tmp/cvs-serv30692/pyPgSQL Modified Files: PgSQL.py Log Message: 02NOV2002 bga - 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 mean- ing in the Cursor.execute() method. - Changed the quoting methods defined in the various classes defining PostgreSQL support types to __quote__. Index: PgSQL.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pyPgSQL/PgSQL.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** PgSQL.py 1 Nov 2002 04:34:16 -0000 1.20 --- PgSQL.py 3 Nov 2002 19:48:48 -0000 1.21 *************** *** 30,33 **** --- 30,40 ---- # Date Ini Description | # --------- --- ------------------------------------------------------- | + # 02NOV2002 bga - 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__| # 27OCT2002 gh - Merged the Unicode patch. Closes #484468. | # - Convert ROWID to PgInt8 instead of PgInt4 (the origi- | *************** *** 374,377 **** --- 381,385 ---- from types import * from sys import getrefcount, getdefaultencoding + import sys import copy import string *************** *** 574,578 **** class LeaveLoopException(Exception): pass ! lst = [] s = s[1:-1] # drop '{' and '}' at start/end --- 582,621 ---- class LeaveLoopException(Exception): pass ! # Get rid of the escaping in the array string ! def convertEscapes(s): ! # If we're called with a list in a multi-dimensional ! # array, simply return the list. We only convert the ! # elements of the multi-dimensional array. ! if type(s) is ListType: ! return s ! ! schars = [] ! escape = 0 ! octdigits = [] ! ! for char in s: ! if char == '\\': ! escape += 1 ! if escape == 2: ! schars.append(char) ! escape = 0 ! else: ! if escape: ! if char in string.digits: ! octdigits.append(char) ! else: ! if octdigits != []: ! curchar = chr(int(octdigits[0]) * 64) + \ ! chr(int(octdigits[1]) * 8) + \ ! chr(int(octdigits[2])) ! schars.append(curchar) ! octdigits = [] ! schars.append(char) ! else: ! schars.append(char) ! escape = 0 ! return "".join(schars) ! ! lst = PgArray() s = s[1:-1] # drop '{' and '}' at start/end *************** *** 599,603 **** escape = 0 end_quote_pos += 1 ! lst.append(s[pos + 1:end_quote_pos]) # Skip quote char and next comma --- 642,646 ---- escape = 0 end_quote_pos += 1 ! lst.append(convertEscapes(s[pos + 1:end_quote_pos])) # Skip quote char and next comma *************** *** 618,622 **** if next_comma_pos >= len(s): # This is the last array element. ! lst.append(s[pos:]) raise LeaveLoopException --- 661,665 ---- if next_comma_pos >= len(s): # This is the last array element. ! lst.append(convertEscapes(s[pos:])) raise LeaveLoopException *************** *** 635,639 **** lst.append(self.parseArray(curelem[1:-1])) else: ! lst.append(curelem) pos = next_comma_pos + 1 if s[pos] == ',': --- 678,682 ---- lst.append(self.parseArray(curelem[1:-1])) else: ! lst.append(convertEscapes(curelem)) pos = next_comma_pos + 1 if s[pos] == ',': *************** *** 680,719 **** pass ! # Get rid of the escaping in the array string ! def convertEscapes(s): ! # If we're called with a list in a multi-dimensional ! # array, simply return the list. We only convert the ! # elements of the multi-dimensional array. ! if type(s) is ListType: ! return s ! ! schars = [] ! escape = 0 ! octdigits = [] ! ! for char in s: ! if char == '\\': ! escape += 1 ! if escape == 2: ! schars.append(char) ! escape = 0 ! else: ! if escape: ! if char in string.digits: ! octdigits.append(char) ! else: ! if octdigits != []: ! curchar = chr(int(octdigits[0]) * 64) + \ ! chr(int(octdigits[1]) * 8) + \ ! chr(int(octdigits[2])) ! schars.append(curchar) ! octdigits = [] ! schars.append(char) ! else: ! schars.append(char) ! escape = 0 ! return "".join(schars) ! ! lst = map(convertEscapes, lst) return lst --- 723,727 ---- pass ! #lst = map(convertEscapes, lst) return lst *************** *** 732,736 **** if _ia: ! # Convert string representation of the array into list. _list = self.parseArray(value) return self.handleArray(colinfo, _list) --- 740,744 ---- if _ia: ! # Convert string representation of the array into PgArray object. _list = self.parseArray(value) return self.handleArray(colinfo, _list) *************** *** 794,797 **** --- 802,806 ---- def handleArray(self, colinfo, lst): # If the list is empty, just return the empty list. + if len(lst) == 0: return lst *************** *** 802,806 **** for _i in range(len(lst)): ! if type(lst[_i]) is ListType: lst[_i] = self.handleArray(colinfo, lst[_i]) elif _ftv == PG_INT4 or _ftv == ROWID: --- 811,815 ---- for _i in range(len(lst)): ! if isinstance(lst[_i], PgArray): lst[_i] = self.handleArray(colinfo, lst[_i]) elif _ftv == PG_INT4 or _ftv == ROWID: *************** *** 909,913 **** # NOTE: A PgOther object will use the PgQuoteString() function in libpq. ! def _quote(self, forArray=0): if self.value: return PgQuoteString(self.value, forArray) --- 918,922 ---- # NOTE: A PgOther object will use the PgQuoteString() function in libpq. ! def __quote__(self, forArray=0): if self.value: return PgQuoteString(self.value, forArray) *************** *** 915,918 **** --- 924,1091 ---- #-----------------------------------------------------------------------+ + # Name: PgArray | + # | + # Description: A Python wrapper class for PostgreSQL arrays. | + # It is used so that the list type can be used as an arg- | + # ument to Connection.execute() without being treated as | + # a PostgreSQL array. | + #-----------------------------------------------------------------------+ + + class PgArray: + def __init__(self, value=None): + if value is None: + self.value = [] + return + + if type(value) is not ListType and not isinstance(value, PgArray): + raise TypeError, "argument must be a list or a PgArray." + + # We have to insure that nested mutable sequences (list and PgArray) + # get copied. + for i in range(len(value)): + if type(value[i]) is ListType or isinstance(value[i], PgArray): + value[i] = PgArray(value[i][:]) + + self.value = value + + # Define the methods used + def append(self, item): + if type(item) is ListType: + item = PgArray(item) + self.value.append(item) + + def count(self, item): + return self.value.count(item) + + def extend(self, item): + if type(item) is ListType: + item = PgArray(item) + self.value.extend(item) + + def index(self, item): + return self.value.index(item) + + def insert(self, key, item): + if type(item) is ListType: + item = PgArray(item) + self.value.insert(key, item) + + def pop(self, key=-1): + return self.value.pop(key) + + def remove(self, item): + self.value.remove(item) + + def reverse(self): + self.value.reverse() + + def sort(self, compfunc=None): + if compfunc is None: + self.value.sort() + else: + self.value.sort(compfunc) + + def __cmp__(self, other): + if not isinstance(other, PgArray): + return cmp(id(self), id(other)) + + # PgArray objects are considered equal if: + # 1. The lengh of the PgArray objects are equal and + # 2. Each item[k] in the PgArray objects are equal. + + res = cmp(len(self), len(other)) + if res != 0: + return res + + for i in range(len(self.value)): + res = cmp(self.value[i], other.value[i]) + if res != 0: + return res + + return 0 + + def __len__(self): + return len(self.value) + + def __getitem__(self, index): + if type(index) is SliceType: + if index.step is None: + return PgArray(self.value[index.start:index.stop]) + else: + return PgArray(self.value[index.start:index.stop:index.step]) + + return self.value[index]; + + def __setitem__(self, index, item): + if type(item) is ListType: + item = PgArray(item) + + if type(index) is SliceType: + if index.step is None: + self.value[index.start:index.stop] = item + else: + self.value[index.start:index.stop:index.step] = item + else: + self.value[index] = item + + def __delitem__(self, index): + if type(index) is SliceType: + if index.step is None: + del self.value[index.start:index.stop] + else: + del self.value[index.start:index.stop:index.step] + else: + del self.value[index]; + + def __contains__(self, item): + return (item in self.value) + + if sys.version_info < (2, 0): + # They won't be defined if version is at least 2.0 final + def __getslice__(self, i, j): + return PgArray(self.value[max(0, i):max(0, j)]) + + def __setslice__(self, i, j, seq): + if type(seq) is ListType: + seq = PgArray(seq) + self.value[max(0, i):max(0, j)] = seq.value + + def __delslice__(self, i, j): + del self.value[max(0, i):max(0, j)] + + def __add__(self, other): + return PgArray((self.value + other)) + + def __radd__(self, other): + return PgArray(other + self.value) + + def __iadd__(self, other): + value = value + other + return self + + def __mul__(self, other): + return PgArray((self.value * other)) + + def __rmul__(self, other): + return PgArray((self.value * other)) + + def __imul__(self, other): + value = value * other + return self + + def __repr__(self): + return repr(self.value) + + def __str__(self): + return str(self.value) + + # NOTE: A PgArray object will use the _handleArray() function to quote + # itself. + def __quote__(self, forArray=0): + if self.value: + return _handleArray(self.value) + return 'NULL' + + #-----------------------------------------------------------------------+ # Name: PgBytea | # | *************** *** 959,963 **** # NOTE: A PgBytea object will use the PgQuoteBytea() function in libpq ! def _quote(self, forArray=0): if self.value: return PgQuoteBytea(self.value, forArray) --- 1132,1136 ---- # NOTE: A PgBytea object will use the PgQuoteBytea() function in libpq ! def __quote__(self, forArray=0): if self.value: return PgQuoteBytea(self.value, forArray) *************** *** 1330,1334 **** return -self ! def _quote(self, forArray=0): if self.__v: if forArray: --- 1503,1507 ---- return -self ! def __quote__(self, forArray=0): if self.__v: if forArray: *************** *** 1468,1472 **** return '$%s' % _s ! def _quote(self, forArray=0): if self.value: if forArray: --- 1641,1645 ---- return '$%s' % _s ! def __quote__(self, forArray=0): if self.value: if forArray: *************** *** 1631,1635 **** return str(self.value) ! def _quote(self, forArray=0): if self.value is not None: s = str(self.value) --- 1804,1808 ---- return str(self.value) ! def __quote__(self, forArray=0): if self.value is not None: s = str(self.value) *************** *** 1797,1802 **** # | # connect() -- connect to a PostgreSQL database. | ! # _handleArray() -- Transform a Python list into a string repre- | ! # senting a PostgreSQL array. | # _quote() -- Transform a Python object representing a | # PostgreSQL type into a appropiately quoted | --- 1970,1975 ---- # | # connect() -- connect to a PostgreSQL database. | ! # _handleArray() -- Transform a PgArray class into a string rep- | ! # resenting a PostgreSQL array. | # _quote() -- Transform a Python object representing a | # PostgreSQL type into a appropiately quoted | *************** *** 1872,1878 **** if _i is None: _j += "," ! elif type(_i) in [ListType, TupleType]: ! _v = list(_i) ! _j = _j + _handleArray(_v)[1:-1] + ',' elif hasattr(_i, '_quote'): _j = '%s%s,' % (_j, _i._quote(1)) --- 2045,2050 ---- if _i is None: _j += "," ! elif isinstance(_i, PgArray): ! _j = _j + _handleArray(_i)[1:-1] + ',' elif hasattr(_i, '_quote'): _j = '%s%s,' % (_j, _i._quote(1)) *************** *** 1899,1907 **** return 'NULL' ! if type(value) in [ListType, TupleType]: ! return _handleArray(list(value)) ! ! if hasattr(value, '_quote'): ! return value._quote() if type(value) in [DateTimeType, DateTimeDeltaType]: --- 2071,2076 ---- return 'NULL' ! if hasattr(value, '__quote__'): ! return value.__quote__() if type(value) in [DateTimeType, DateTimeDeltaType]: |
From: Billy G. A. <bal...@us...> - 2002-11-01 04:34:20
|
Update of /cvsroot/pypgsql/pypgsql/pyPgSQL In directory usw-pr-cvs1:/tmp/cvs-serv15058/pyPgSQL Modified Files: PgSQL.py Log Message: 26OCT2002 bga Column access by name (attribute and dictionary) now supports mixed-case column name. Be aware that if you define mixed-case column names in the database, you have to use the mixed-case name to access the column or it will not be found. For column names that were not defined with mixed-case in the database, the column access by name is case insensitive. Index: PgSQL.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pyPgSQL/PgSQL.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** PgSQL.py 27 Oct 2002 04:14:52 -0000 1.19 --- PgSQL.py 1 Nov 2002 04:34:16 -0000 1.20 *************** *** 38,41 **** --- 38,48 ---- # useless nowadays that we've mostly left line printers | # beyond us. | + # 26OCT2002 bga - Column access by name (attribute and dictionary) now | + # supports mixed-case column name. Be aware that if | + # you define mixed-case column names in the database, | + # you have to use the mixed-case name to access the co- | + # lumn or it will not be found. For column names that | + # were not defined with mixed-case in the database, the | + # column access by name is case insensitive. | # 02OCT2002 gh - Only support mxDateTime 2.x and give useful error | # message if import fails. | *************** *** 1663,1669 **** def __getattr__(self, key): ! key = key.upper() if self._xlatkey.has_key(key): return self.baseObj[self._xlatkey[key]] raise AttributeError, key --- 1670,1685 ---- def __getattr__(self, key): ! # When retrieving column data by name as an attribute, we must be ! # aware that a column name can be defiend with mixed-case within the ! # database. Because of this we must first check for an exact match ! # with the given key. If that fails, then we match with the key that ! # has been changed to lower case. Note: we are relying on the fact ! # that PostgreSQL sends column names that are not defined with mixed- ! # case to the client as lower-case names. ! keyl = key.lower() if self._xlatkey.has_key(key): return self.baseObj[self._xlatkey[key]] + if self._xlatkey.has_key(keyl): + return self.baseObj[self._xlatkey[keyl]] raise AttributeError, key *************** *** 1674,1680 **** raise AttributeError, "%s is read-only." % key ! key = key.upper() if self._xlatkey.has_key(key): self.__dict__['baseObj'][self._xlatkey[key]] = value else: raise AttributeError, key --- 1690,1700 ---- raise AttributeError, "%s is read-only." % key ! # Try an exact match first, then the case-insensitive match. ! # See comment in __getattr__ for details. ! keyl = key.lower() if self._xlatkey.has_key(key): self.__dict__['baseObj'][self._xlatkey[key]] = value + elif self._xlatkey.has_key(keyl): + self.__dict__['baseObj'][self._xlatkey[keyl]] = value else: raise AttributeError, key *************** *** 1685,1694 **** def __getitem__(self, key): if isinstance(key, StringType): ! key = self._xlatkey[key.upper()] return self.baseObj[key] def __setitem__(self, key, value): if isinstance(key, StringType): ! key = self._xlatkey[key.upper()] self.baseObj[key] = value --- 1705,1724 ---- def __getitem__(self, key): if isinstance(key, StringType): ! # Try an exact match first, then the case-insensitive match. ! # See comment in __getattr__ for details. ! try: ! key = self._xlatkey[key] ! except: ! key = self._xlatkey[key.lower()] return self.baseObj[key] def __setitem__(self, key, value): if isinstance(key, StringType): ! # Try an exact match first, then the case-insensitive match. ! # See comment in __getattr__ for details. ! try: ! key = self._xlatkey[key] ! except: ! key = self._xlatkey[key.lower()] self.baseObj[key] = value *************** *** 1729,1738 **** def has_key(self, key): ! return self._xlatkey.has_key(key.upper()) def get(self, key, defaultval=None): ! if self.has_key(key): ! return self[key] ! else: return defaultval --- 1759,1779 ---- def has_key(self, key): ! # Try an exact match first, then the case-insensitive match. ! # See comment in __getattr__ for details. ! if not self._xlatkey.has_key(key): ! key = key.lower() ! return self._xlatkey.has_key(key) def get(self, key, defaultval=None): ! try: ! if isinstance(key, StringType): ! # Try an exact match first, then the case-insensitive match. ! # See comment in __getattr__ for details. ! try: ! key = self._xlatkey[key] ! except: ! key = self._xlatkey[key.lower()] ! return self[key] ! except: return defaultval *************** *** 1745,1752 **** if mapname is None: for _i in range(len(description)): ! klass.__dict__['_xlatkey'][description[_i][0].upper()] = _i else: for k, v in mapname.items(): ! klass.__dict__['_xlatkey'][k.upper()] = v return klass --- 1786,1793 ---- if mapname is None: for _i in range(len(description)): ! klass.__dict__['_xlatkey'][description[_i][0]] = _i else: for k, v in mapname.items(): ! klass.__dict__['_xlatkey'][k] = v return klass |
From: Gerhard H?r. <gha...@us...> - 2002-10-27 06:06:05
|
Update of /cvsroot/pypgsql/pypgsql In directory usw-pr-cvs1:/tmp/cvs-serv9525 Modified Files: MANIFEST Log Message: 27OCT2002 gh Reflect the change from windows/ to port/ and the addition of the Unicode test suite in the MANIFEST file. Index: MANIFEST =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/MANIFEST,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** MANIFEST 4 Nov 2001 05:03:57 -0000 1.8 --- MANIFEST 27 Oct 2002 06:06:01 -0000 1.9 *************** *** 35,40 **** test/regression/pgresult.py test/regression/pgversion.py ! windows/llsupport.h ! windows/strtok.c ! windows/strtoll.c ! windows/strtoull.c --- 35,41 ---- test/regression/pgresult.py test/regression/pgversion.py ! test/regression/unicode_tests.py ! port/strtok.c ! port/port.h ! port/strtoll.c ! port/strtoull.c |
From: Gerhard H?r. <gha...@us...> - 2002-10-27 06:01:16
|
Update of /cvsroot/pypgsql/pypgsql/test/regression In directory usw-pr-cvs1:/tmp/cvs-serv6550/test/regression Modified Files: unicode_tests.py Log Message: 27OCT2002 gh Corrected copyright statement. Copyright owner is Gerhard Häring, year is 2002. Index: unicode_tests.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/test/regression/unicode_tests.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** unicode_tests.py 27 Oct 2002 03:52:34 -0000 1.1 --- unicode_tests.py 27 Oct 2002 06:01:13 -0000 1.2 *************** *** 8,12 **** # Description: Tests for the Unicode support in pyPgSQL. | #=======================================================================| ! # Copyright 2000 by Billy G. Allie. | # All rights reserved. | # | --- 8,12 ---- # Description: Tests for the Unicode support in pyPgSQL. | #=======================================================================| ! # Copyright 2002 by Gerhard Häring. | # All rights reserved. | # | *************** *** 31,35 **** # Date Ini Description | # --------- --- ------------------------------------------------------- | ! # 27OCT2002 gh Initial release by Gerhard Häring | #-----------------------------------------------------------------------+ import types --- 31,36 ---- # Date Ini Description | # --------- --- ------------------------------------------------------- | ! # 27OCT2002 gh Corrected coypright statement. | ! # 27OCT2002 gh Initial release by Gerhard Häring. | #-----------------------------------------------------------------------+ import types |
From: Gerhard H?r. <gha...@us...> - 2002-10-27 05:58:18
|
Update of /cvsroot/pypgsql/pypgsql In directory usw-pr-cvs1:/tmp/cvs-serv4917 Modified Files: pyPgSQL.spec Log Message: 27OCT2002 gh Integrated patch of Sean Reifschneider that makes the C version of PgInt8 be built when the compiler is a GNU C compiler version 3.x on Linux systems. Index: pyPgSQL.spec =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pyPgSQL.spec,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** pyPgSQL.spec 27 Oct 2002 04:05:42 -0000 1.3 --- pyPgSQL.spec 27 Oct 2002 05:58:14 -0000 1.4 *************** *** 3,6 **** --- 3,14 ---- %define release 1 + # automatically set GCC flags based on version + %{expand:%%define gccmajorvers %(gcc -v 2>&1 | tail -1 | awk '{ print $3 }' | awk -F. '{ print $1 }')} + %if %{gccmajorvers} >= 3 + %define cflags -std=c99 $RPM_OPT_FLAGS + %else + %define cflags $RPM_OPT_FLAGS + %endif + Summary: pyPgSQL - A Python DB-API 2.0 compliant interface to PostgreSQL. Name: %{name} *************** *** 33,37 **** %build ! env CFLAGS="$RPM_OPT_FLAGS" /usr/bin/python2 setup.py build # change the path in the test/examples --- 41,45 ---- %build ! env CFLAGS="%{cflags}" /usr/bin/python2 setup.py build # change the path in the test/examples *************** *** 56,59 **** --- 64,71 ---- %changelog + * Sun Oct 27 2002 Sean Reifschneider <jaf...@tu...> + - Define CFLAGS for gcc 3.x compilers so that the C version of PgInt8 gets + built. + * Sat Oct 19 2002 Gerhard Häring <ger...@gm...> - Updated to version 2.3. |