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: <loe...@ko...> - 2006-11-22 07:55:58
|
I want to join the list... |
From: <gha...@us...> - 2006-06-07 18:06:57
|
Update of /cvsroot/pypgsql/pypgsql In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4455 Modified Files: ChangeLog libpqmodule.c setup.py Log Message: Patch for a security hole in PostgreSQL (CVE-2006-2314): escaping quotes with backslashes is insecure. The change is to escape single quotes with another single quote: \' => ''. Thanks to Martin Pitt for the patch. Index: ChangeLog =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/ChangeLog,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** ChangeLog 3 Jun 2006 00:13:34 -0000 1.22 --- ChangeLog 7 Jun 2006 17:21:28 -0000 1.23 *************** *** 1,4 **** --- 1,12 ---- #ident "$Id$" + Changes since pyPgSQL Version 2.5 + ================================= + + Patch for a security hole in PostgreSQL (CVE-2006-2314): escaping quotes with + backslashes is insecure. The change is to escape single quotes with + another single quote: \' => ''. Thanks to Martin Pitt for the patch. + + Changes since pyPgSQL Version 2.4 ================================= Index: libpqmodule.c =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/libpqmodule.c,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** libpqmodule.c 9 Apr 2005 02:19:41 -0000 1.32 --- libpqmodule.c 7 Jun 2006 17:21:28 -0000 1.33 *************** *** 32,35 **** --- 32,39 ---- | Date Ini Description | | --------- --- ------------------------------------------------------- | + | 07JUN2006 gh Patch for a security hole in PostgreSQL (CVE-2006-2314):| + | escaping quotes with backslashes is insecure. The | + | change is to escape single quotes with another single | + | quote: \' => ''. | | 08APR2005 bga Un-did one of the fixes put in on 01MAR2005. It wasn't | | broke until I 'fixed' it. | *************** *** 132,136 **** | 2. The backslash is quoted as \\. | | | ! | 3. The single quote is quoted as \'. | | | | 4. All other characters are unchanged. | --- 136,140 ---- | 2. The backslash is quoted as \\. | | | ! | 3. The single quote is quoted as ''. | | | | 4. All other characters are unchanged. | *************** *** 151,155 **** | | | 2. The backslash is escpaed as \\\\. | ! | 3. The single quote is escaped as \'. | | 4. The double quote is escaped as \\". | | 5. All other characters are unchanged. | --- 155,159 ---- | | | 2. The backslash is escpaed as \\\\. | ! | 3. The single quote is escaped as ''. | | 4. The double quote is escaped as \\". | | 5. All other characters are unchanged. | *************** *** 190,194 **** case '\'': ! sout[j++] = '\\'; sout[j++] = sin[i]; break; --- 194,198 ---- case '\'': ! sout[j++] = '\''; sout[j++] = sin[i]; break; *************** *** 272,276 **** | 3. The backslash is escaped as \\\\. | | | ! | 4. The single quote is escaped as \'. | | | | 5. All other characters are unchanged. | --- 276,280 ---- | 3. The backslash is escaped as \\\\. | | | ! | 4. The single quote is escaped as ''. | | | | 5. All other characters are unchanged. | *************** *** 281,285 **** | 2. Non-printable characters are escapes as \\\\OOO. | | 3. The backslash is escpaed as \\\\\\\\. | ! | 4. The single quote is escaped as \'. | | 5. The double quote is escaped as \\". | | 6. All other characters are unchanged. | --- 285,289 ---- | 2. Non-printable characters are escapes as \\\\OOO. | | 3. The backslash is escpaed as \\\\\\\\. | ! | 4. The single quote is escaped as ''. | | 5. The double quote is escaped as \\". | | 6. All other characters are unchanged. | *************** *** 319,323 **** case '\'': ! sout[j++] = '\\'; sout[j++] = sin[i]; break; --- 323,327 ---- case '\'': ! sout[j++] = '\''; sout[j++] = sin[i]; break; Index: setup.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/setup.py,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** setup.py 2 Jun 2006 13:47:25 -0000 1.27 --- setup.py 7 Jun 2006 17:21:28 -0000 1.28 *************** *** 85,89 **** from distutils.extension import Extension ! __version__ = "2.5" # Define the runtime library path for this module. It starts out as None. --- 85,89 ---- from distutils.extension import Extension ! __version__ = "2.5.1" # Define the runtime library path for this module. It starts out as None. |
From: <gha...@us...> - 2006-06-07 18:06:14
|
Update of /cvsroot/pypgsql/pypgsql/pyPgSQL In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4455/pyPgSQL Modified Files: __init__.py Log Message: Patch for a security hole in PostgreSQL (CVE-2006-2314): escaping quotes with backslashes is insecure. The change is to escape single quotes with another single quote: \' => ''. Thanks to Martin Pitt for the patch. Index: __init__.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pyPgSQL/__init__.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** __init__.py 1 Jun 2006 14:42:51 -0000 1.6 --- __init__.py 7 Jun 2006 17:21:28 -0000 1.7 *************** *** 32,34 **** """ ! __version__ = "2.5" --- 32,34 ---- """ ! __version__ = "2.5.1" |
From: <gha...@us...> - 2006-06-03 00:13:37
|
Update of /cvsroot/pypgsql/pypgsql In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7606 Modified Files: ChangeLog Log Message: Updated ChangeLog for version 2.5. Index: ChangeLog =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/ChangeLog,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** ChangeLog 16 Jul 2003 04:28:49 -0000 1.21 --- ChangeLog 3 Jun 2006 00:13:34 -0000 1.22 *************** *** 1,4 **** --- 1,65 ---- #ident "$Id$" + Changes since pyPgSQL Version 2.4 + ================================= + + Changes to README + ----------------- + * Updates for 2.5. + + Changes to PgSQL.py + ------------------- + * Additional attribute cursor.debug: + + Setting this attribute to 'text' will cause the query that will + be executed to be displayed to STDOUT. If it is set to 'pre' or + 'div', the query will be displayed to STDOUT within a <pre> or + <dif> HTML block. If it is set to None (the default), the query + will not be displayed. + + * New module-level variable useUTCtimeValue: + + Setting this variable to 1 will cause the datatime instance returned from + the result set for a timestame with timezone to reference the corresponding + UTC time value (not the value expressed in the clients time zone). + + * mxDateTime's RelativeDateTime instead of DateTimeDelta is now used for + PostgreSQL INTERVALs. + + * Several other fixes in the PostgreSQL interval code + + * Several bugfixes in the PgNumeric type + + * PgInt2 and PgInt8 used to be custom number types that checked for overflows + in their specific ranges. In order to make them work across current Python + versions we got rid of them and replaced them with int and long. + + * Many changes in parameter quoting to make them work in more cases like + * PostgreSQL procedures + + Changes to libpqmodule.c + ------------------------ + * Bugfix for quoting Bytea types + + Changes to pgconnection.c + ------------------------- + * Fixed compatibility problems with PostgreSQL 8.x. + * Added debug support + + Changes to pgresult.c + --------------------- + * Integrated patch #1224272. Use PyOS_ascii_strtod instead of strtod in order + to be locale-agnostic. + + Changes to pgversion.c + ---------------------- + * Applied patch #882032. Vendor-extensions to version + number should not create problems any longer. + + * Fixed Bug #786712 & #816729: Allowed for a version string + containing the words "alpha" and "beta". + + + Changes since pyPgSQL Version 2.3 ================================= |
From: <gha...@us...> - 2006-06-03 00:12:32
|
Update of /cvsroot/pypgsql/pypgsql In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7071 Modified Files: Announce Log Message: Announcement for pyPgSQL 2.5. Index: Announce =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/Announce,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** Announce 16 Jul 2003 04:28:49 -0000 1.24 --- Announce 3 Jun 2006 00:12:25 -0000 1.25 *************** *** 1,6 **** ! Announce: pyPgSQL - Version 2.4 is released. =========================================================================== ! pyPgSQL v2.4 has been released. It is available at http://pypgsql.sourceforge.net. --- 1,6 ---- ! Announce: pyPgSQL - Version 2.5 is released. =========================================================================== ! pyPgSQL v2.5 has been released. It is available at http://pypgsql.sourceforge.net. *************** *** 14,19 **** 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 --- 14,19 ---- 2.0 or later. ! It was tested with PostgreSQL 8.1.4 and the latest patchlevels of Python 2.1, ! 2.2, 2.3 and 2.4. Note: It is highly recommended that you use PostgreSQL 7.2 or later and *************** *** 31,119 **** =========================================================================== ! Changes since pyPgSQL Version 2.3 ================================= - =-=-=-=-=-=-=-=-=-=-=-=-=- ** IMPORTANT NOTE ** =-=-=-=-=-=-=-=-=-=-=-=-=-= - NOTE: There is a change to the Connection.binary() function that *could* - cause existing code to break. Connection.binary() no longer commits - the transaction used to create the large object. The application - developer is now responsible for commiting (or rolling back) the - transaction. - -=-=-=-=-=-=-=-=-=-=-=-=-= ** IMPORTANT NOTE ** -=-=-=-=-=-=-=-=-=-=-=-=-=- - Changes to README ----------------- ! * Updates for 2.4. ! Changes to PgSQL.py ------------------- ! * Applied patch from Laurent Pinchart to allow _quote to correctly process ! objects that are sub-classed from String and Long types. ! * Change the name of the quoting function back to _quote. Variables named ! like __*__ should be restrict to system names. ! * PgTypes is now hashable. repr() of a PgType will now return the repr() ! of the underlying OID. ! * Connection.binary() will now fail if autocommit is enabled. ! * Connection.binary() will no longer commit the transaction after creating ! the large object. The application developer is now responsible for ! commiting (or for rolling back) the transaction [Bug #747525]. ! * Added PG_TIMETZ to the mix [Patch #708013]. ! * Pg_Money will now accept a string as a parameter. ! * PostgreSQL int2, int, int4 will now be cast into Python ints. Int8 will ! be cast into a Python long. Float4, float8, and money types will be ! cast into a Python float. ! * Correct problem with the PgNumeric.__radd__ method. [Bug #694358] ! * Correct problem with conversion of negitive integers (with a given scale ! and precision) to PgNumerics. [Bug #694358] ! * Work around a problem where the precision and scale of a query result ! can be different from the first result in the result set. [Bug #697221] ! * Change the code so that the display length in the cursor.description ! attribute is always None instead of '-1'. ! * Fixed another problem with interval <-> DateTimeDelta casting. ! * Corrected a problem that caused the close of a portal (ie. PostgreSQL ! cursor) to fail. ! * Corrected a problem with interval <-> DateTimeDelta casting. [Bug #653044] ! * Corrected problem found by Adam Buraczewski in the __setupTransaction ! function. ! * Allow both 'e' and 'E' to signify an exponent in the PgNumeric constructor. ! * Correct some problems that were missed in yesterday's fixes (Thanks, ! Adam, for the help with the problems) Changes to libpqmodule.c ------------------------ ! * On win32, we usually statically link against libpq. Because of ! fortunate circumstances, a problem didn't show up until now: we need to ! call WSAStartup() to initialize the socket stuff from Windows *in our ! module* in order for the statically linked libpq to work. I just took ! the relevant DllMain function from the libpq sources and put it here. ! * Modified some comments to reflect reality. ! * Applied patch from Laurent Pinchart: In libPQquoteString, bytea are ! quoted using as much as 5 bytes per input byte (0x00 is quoted '\\000'), ! so allocating (slen * 4) + 3 is not enough for data that contain lots of ! 0x00 bytes. ! * Added PG_TIMETZ to the mix [Patch #708013]. ! ! Changes to pgboolean.c ! ---------------------- ! * Change the name of the quoting function back to _quote. __*__ type ! names should be restricted to system names. Changes to pgconnection.c ------------------------- ! * Applied patch by Laurent Pinchart to correct a problem lo_import, ! lo_export, lo_unlink. ! * In case PQgetResult returns NULL, let libPQgetResult return a Python ! None, like the docstring says. This is necessary in order to be able ! to cancel queries, as after cancelling a query with PQrequestCancel, ! we need to read results until PQgetResult returns NULL. ! ! Changes to pglargeobject.c ! -------------------------- ! * Change the name of the quoting function back to _quote. __*__ type ! names should be restricted to system names. ! Changes to pgnotify.c --------------------- ! * Fixed a bug in the code. The code in question use to work, but doesn't ! anymore (possible change to libpq?). --- 31,91 ---- =========================================================================== ! Changes since pyPgSQL Version 2.4 ================================= Changes to README ----------------- ! * Updates for 2.5. ! Changes to PgSQL.py ------------------- ! * Additional attribute cursor.debug: ! ! Setting this attribute to 'text' will cause the query that will ! be executed to be displayed to STDOUT. If it is set to 'pre' or ! 'div', the query will be displayed to STDOUT within a <pre> or ! <dif> HTML block. If it is set to None (the default), the query ! will not be displayed. ! ! * New module-level variable useUTCtimeValue: ! ! Setting this variable to 1 will cause the datatime instance returned from ! the result set for a timestame with timezone to reference the corresponding ! UTC time value (not the value expressed in the clients time zone). ! ! * mxDateTime's RelativeDateTime instead of DateTimeDelta is now used for ! PostgreSQL INTERVALs. ! ! * Several other fixes in the PostgreSQL interval code ! ! * Several bugfixes in the PgNumeric type ! ! * PgInt2 and PgInt8 used to be custom number types that checked for overflows ! in their specific ranges. In order to make them work across current Python ! versions we got rid of them and replaced them with int and long. ! ! * Many changes in parameter quoting to make them work in more cases like ! * PostgreSQL procedures Changes to libpqmodule.c ------------------------ ! * Bugfix for quoting Bytea types Changes to pgconnection.c ------------------------- ! * Fixed compatibility problems with PostgreSQL 8.x. ! * Added debug support ! Changes to pgresult.c --------------------- ! * Integrated patch #1224272. Use PyOS_ascii_strtod instead of strtod in order ! to be locale-agnostic. ! ! Changes to pgversion.c ! ---------------------- ! * Applied patch #882032. Vendor-extensions to version ! number should not create problems any longer. ! ! * Fixed Bug #786712 & #816729: Allowed for a version string ! containing the words "alpha" and "beta". |
From: <gha...@us...> - 2006-06-02 14:27:48
|
Update of /cvsroot/pypgsql/pypgsql In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11767 Modified Files: pgversion.c Log Message: 02JUN2006 gh Applied patch #882032. Vendor-extensions to version number should not create problems any longer. Index: pgversion.c =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pgversion.c,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** pgversion.c 26 Sep 2005 08:08:17 -0000 1.23 --- pgversion.c 2 Jun 2006 14:27:45 -0000 1.24 *************** *** 32,35 **** --- 32,37 ---- | Date Ini Description | | --------- --- ------------------------------------------------------- | + | 02JUN2006 gh Applied patch #882032. Vendor-extensions to version | + | number should not create problems any longer. | | 26SEP2005 gh Minor fix for stricter C compilers (move variable | | declaration to start of function). | *************** *** 280,283 **** --- 282,293 ---- save_ptr = (char *)NULL; + /***************************************************************\ + | Vendor releases e.g. from dbexperts get forgotten. | + | We strip that away here. | + \***************************************************************/ + + vstr = pg_strtok_r(vstr, "-", &save_ptr); + save_ptr = (char *)NULL; + token = pg_strtok_r(vstr, ".", &save_ptr); if (parseToken(token, &major)) |
From: <gha...@us...> - 2006-06-02 14:27:08
|
Update of /cvsroot/pypgsql/pypgsql/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11348/test Modified Files: PgSQLTestCases.py Log Message: 02JUN2006 gh Adjusted test suite to patch #882032. Index: PgSQLTestCases.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/test/PgSQLTestCases.py,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** PgSQLTestCases.py 1 Jun 2006 13:40:36 -0000 1.28 --- PgSQLTestCases.py 2 Jun 2006 14:27:03 -0000 1.29 *************** *** 33,36 **** --- 33,37 ---- # Date Ini Description | # --------- --- ------------------------------------------------------- | + # 02JUN2006 gh Adjusted test suite to patch #882032. | # 01JUN2006 gh Slimmed down tests to make them work with recent Python | # and PostgreSQL releases. | *************** *** 572,576 **** try: self.cur.callproc("version") ! v = string.split(self.cur.fetchone()[0])[1] self.cur.close() vstr = "%(major)d.%(minor)d" % self.cnx.version --- 573,577 ---- try: self.cur.callproc("version") ! v = string.split(self.cur.fetchone()[0])[1].split("-")[0] self.cur.close() vstr = "%(major)d.%(minor)d" % self.cnx.version |
From: <gha...@us...> - 2006-06-02 13:47:36
|
Update of /cvsroot/pypgsql/pypgsql In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25909 Modified Files: setup.py Log Message: Use pg_config on *all* platforms, not just win32. Index: setup.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/setup.py,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** setup.py 1 Jun 2006 14:38:18 -0000 1.26 --- setup.py 2 Jun 2006 13:47:25 -0000 1.27 *************** *** 45,48 **** --- 45,49 ---- # Date Ini Description | # --------- --- ------------------------------------------------------- | + # 02JUN2006 gh Use pg_config on all platforms. | # 01JUN2006 gh Removed RPM-specific hack. Use pg_config on win32. | # 26SEP2005 gh Changed win32 build process to use MSVC.NET (needed | *************** *** 89,95 **** 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 --- 90,93 ---- *************** *** 105,153 **** "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/local/pgsql/include", "/usr/include/postgresql"] ! library_dirs = ["/usr/lib"] ! 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[:8] == "openunix": ! 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": ! include_dirs = [os.popen("pg_config --includedir").read().strip()] ! library_dirs = [os.popen("pg_config --libdir").read().strip() + "/ms"] ! #optional_libs += ["wsock32", "advapi32"] ! optional_libs = ["libpq", "wsock32", "advapi32"] # , "shfolder"] modname="pyPgSQL.libpq.libpq" - else: - # Assume a Unixish system - include_dirs = ["/usr/local/include", "/usr/local/pgsql/include"] - library_dirs = ["/usr/local/lib", "/usr/local/pgsql/lib"] # patch distutils if it can't cope with the "classifiers" keyword --- 103,115 ---- "port/strtok.c"] ! include_dirs = [os.popen("pg_config --includedir").read().strip()] ! library_dirs = [os.popen("pg_config --libdir").read().strip()] ! ! if sys.platform == "darwin": # Mac OS X optional_libs += ["ssl", "crypto"] elif sys.platform == "win32": ! library_dirs[0] = library_dirs[0] + "/ms" ! optional_libs = ["libpq", "wsock32", "advapi32"] modname="pyPgSQL.libpq.libpq" # patch distutils if it can't cope with the "classifiers" keyword |
From: <gha...@us...> - 2006-06-01 14:43:00
|
Update of /cvsroot/pypgsql/pypgsql/pyPgSQL In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18409/pyPgSQL Modified Files: PgSQL.py __init__.py Log Message: 01JUN2006 gh - Got rid of the custom PgInt2 and PgInt8 types. Normal Python int and long are used now, so coercion works again with Python 2.1 through 2.4. This will also get rid of the maintenance nightmare that came with C's "long long" type on various platforms. Index: PgSQL.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pyPgSQL/PgSQL.py,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** PgSQL.py 21 May 2005 01:31:23 -0000 1.49 --- PgSQL.py 1 Jun 2006 14:42:51 -0000 1.50 *************** *** 30,33 **** --- 30,38 ---- # Date Ini Description | # --------- --- ------------------------------------------------------- | + # 01JUN2006 gh - Got rid of the custom PgInt2 and PgInt8 types. Normal | + # Python int and long are used now, so coercion works | + # again with Python 2.1 through 2.4. This will also get | + # rid of the maintenance nightmare that came with C's | + # "long long" type on various platforms. | # 20MAY2005 bga - Fixed code so that a DateTimeDelta is returned for a | # PostgreSQL time datatype. | *************** *** 430,433 **** --- 435,444 ---- noWeakRef = 1 + # Define boolean constants for old Python versions + try: + True + except: + True, False = 1, 0 + try: from mx import DateTime *************** *** 1969,2137 **** return 'NULL' ! #-----------------------------------------------------------------------+ ! # Name: PgInt8 | ! # | ! # Description: A Python wrapper class for the PostgreSQL int8 type. | ! # It's primary purpose it to check for overflow during | ! # calulations. | ! # | ! # Note: The PgInt8 class uses a Python Long Integer to hold | ! # the PostgreSQL int8 type. | ! # | ! # Note: This class will only be defined if the C implementation | ! # of the PgInt8 object was not imported with/from libpq. | ! #-----------------------------------------------------------------------+ ! ! if dir().count('PgInt8') == 0: # Only define this class is PgInt8 wasn't ! # brought in via libpq. ! class PgInt8: ! def __init__(self, value): ! if value is None: ! self.value = value ! return ! ! self.value = long(value) ! if self.value < -9223372036854775808L or \ ! self.value > 9223372936854775807L: ! raise OverflowError, 'int8 initialization' ! ! def __checkresult(self, value, op): ! if value < -9223372036854775808L or value > 9223372936854775807L: ! raise OverflowError, 'int8 %s' % op ! return PgInt8(value) ! ! def __coerce__(self, other): ! if other is None: ! return None ! res = coerce(self.value, other) ! if res is None: ! return None ! _s, _o = res ! return (self, _o) ! ! def __hash__(self): ! return hash(self.value) ! ! def __cmp__(self, other): ! return cmp(self.value, other) ! ! def __nonzero__(self): ! return self.value != 0 ! ! def __add__(self, other): ! return self.__checkresult(self.value + other, "addition") ! ! def __sub__(self, other): ! return self.__checkresult(self.value - other, "subtraction") ! ! def __mul__(self, other): ! return self.__checkresult(self.value * other, "mulitplication") ! ! def __div__(self, other): ! return self.__checkresult(self.value / other, "division") ! ! def __divmod__(self, other): ! _a, _b = divmod(self.value, other) ! return (self.__checkresult(_a, "divmod"), _b) ! ! def __pow__(self, other, modulus=None): ! return self.__checkresult(pow(self.value, other, modulus), "pow") ! ! def __lshift__(self, other): ! return self.__checkresult(self.value << other, 'lshift') ! ! def __rshift__(self, other): ! return self.__checkresult(self.value >> other, 'rshift') ! ! def __and__(self, other): ! return self.__checkresult(self.value & other, 'and') ! ! def __xor__(self, other): ! return self.__checkresult(self.value ^ other, 'xor') ! ! def __or__(self, other): ! return self.__checkresult(self.value | other, 'or') ! ! def __radd__(self, other): ! return self.__checkresult(other + self.value, "addition") ! ! def __rsub__(self, other): ! return self.__checkresult(other - self.value, "subtraction") ! ! def __rmul__(self, other): ! return self.__checkresult(other * self.value, "mulitplication") ! ! def __rdiv__(self, other): ! return self.__checkresult(other / self.value, "division") ! ! def __rdivmod__(self, other): ! _a, _b = divmod(other, self.value) ! return (self.__checkresult(_a, "divmod"), ! self.__checkresult(_b, "divmod")) ! ! def __rpow__(self, other, modulus=None): ! return self.__checkresult(pow(other, self.value, modulus), "pow") ! ! def __rlshift__(self, other): ! return self.__checkresult(other << self.value, 'lshift') ! ! def __rrshift__(self, other): ! return self.__checkresult(other >> self.value, 'rshift') ! ! def __rand__(self, other): ! return self.__checkresult(other & self.value, 'and') ! ! def __rxor__(self, other): ! return self.__checkresult(other ^ self.value, 'xor') ! ! def __ror__(self, other): ! return self.__checkresult(other | self.value, 'or') ! ! def __neg__(self): ! return self.__checkresult(neg(self.value), 'neg') ! ! def __pos__(self): ! return self.__checkresult(pos(self.value), 'pos') ! ! def __abs__(self): ! return self.__checkresult(abs(self.value), 'abs') ! ! def __complex__(self): ! return complex(self) ! ! def __int__(self): ! return int(self.value) ! ! def __long__(self): ! return self.value # PgInt8 is already a Long. ! ! def __float__(self): ! return float(self.value) ! ! def __complex__(self): ! return complex(self.value) ! ! def __hex__(self): ! return hex(self.value) ! ! def __oct__(self): ! return oct(self.value) ! ! def __repr__(self): ! return repr(self.value) ! ! def __str__(self): ! return str(self.value) ! ! def _quote(self, forArray=0): ! if self.value is not None: ! s = str(self.value) ! if s[-1:] == "L": ! s = s[:-1] ! return "%s" % s ! return 'NULL' ! PgInt8Type = PgInt8 #-----------------------------------------------------------------------+ --- 1980,1992 ---- return 'NULL' ! # PgInt2 and PgInt8 used to be custom number types that checked for overflows ! # in their specific ranges. In order to make them work across current Python ! # versions we got rid of them and replaced them with int and long. ! PgInt2 = int ! PgInt2Type = IntType + PgInt8 = long + PgInt8Type = LongType #-----------------------------------------------------------------------+ Index: __init__.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pyPgSQL/__init__.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** __init__.py 14 Jul 2003 21:25:34 -0000 1.5 --- __init__.py 1 Jun 2006 14:42:51 -0000 1.6 *************** *** 32,34 **** """ ! __version__ = "2.4" --- 32,34 ---- """ ! __version__ = "2.5" |
From: <gha...@us...> - 2006-06-01 14:39:40
|
Update of /cvsroot/pypgsql/pypgsql In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16827 Modified Files: README README.win32 Log Message: Updated READMEs for next release. Index: README =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/README,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** README 31 Jul 2004 20:26:25 -0000 1.33 --- README 1 Jun 2006 14:39:29 -0000 1.34 *************** *** 2,6 **** ---------------------------------------------------------------------------- ! pyPgSQL - v2.4: Python DB-API 2.0 Compliant Interface Module for PostgreSQL. ---------------------------------------------------------------------------- =============================== --- 2,6 ---- ---------------------------------------------------------------------------- ! pyPgSQL - v2.5: Python DB-API 2.0 Compliant Interface Module for PostgreSQL. ---------------------------------------------------------------------------- =============================== *************** *** 8,12 **** =============================== ! pyPgSQL, version 2.4 A Python DB-API 2.0 compliant interface for PostgreSQL Copyright 2000 by Billy G. Allie. --- 8,12 ---- =============================== ! pyPgSQL, version 2.5 A Python DB-API 2.0 compliant interface for PostgreSQL Copyright 2000 by Billy G. Allie. *************** *** 59,66 **** support for various PostgreSQL data types, such as INT8, NUMERIC, MONEY, BOOL, ARRAYS, etc. This module is written in Python. This version works ! with PostgreSQL 7.0 or later and Python 2.0 or later. pyPgSQL was originally developed on a UnixWare 7.1.1 system, but is nowadays ! also developed on FreeBSD and various Windows and Linux flavours. 1.2 Distribution Files --- 59,66 ---- support for various PostgreSQL data types, such as INT8, NUMERIC, MONEY, BOOL, ARRAYS, etc. This module is written in Python. This version works ! with PostgreSQL 7.0 or later and Python 2.1 or later. pyPgSQL was originally developed on a UnixWare 7.1.1 system, but is nowadays ! also developed on Windows and Linux. 1.2 Distribution Files Index: README.win32 =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/README.win32,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** README.win32 1 Dec 2002 19:30:56 -0000 1.4 --- README.win32 1 Jun 2006 14:39:29 -0000 1.5 *************** *** 3,7 **** ========================================================================== ! by Gerhard Häring (ger...@gm...) 1. Compiling PostgreSQL's libpq client library --- 3,9 ---- ========================================================================== ! by Gerhard Häring (gh...@gh...) ! ! THIS DOCUMENT IS OBSOLETE! 1. Compiling PostgreSQL's libpq client library |
From: <gha...@us...> - 2006-06-01 14:38:21
|
Update of /cvsroot/pypgsql/pypgsql In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16219 Modified Files: setup.py Log Message: 01JUN2006 gh Removed RPM-specific hack. Use pg_config on win32. Index: setup.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/setup.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** setup.py 26 Sep 2005 08:08:17 -0000 1.25 --- setup.py 1 Jun 2006 14:38:18 -0000 1.26 *************** *** 15,19 **** # pyPgSQL. | #=======================================================================| ! # Copyright 2001, 2002 by Gerhard Haering. | # All rights reserved. | # | --- 15,19 ---- # pyPgSQL. | #=======================================================================| ! # Copyright 2001 - 2006 by Gerhard Haering. | # All rights reserved. | # | *************** *** 45,48 **** --- 45,49 ---- # Date Ini Description | # --------- --- ------------------------------------------------------- | + # 01JUN2006 gh Removed RPM-specific hack. Use pg_config on win32. | # 26SEP2005 gh Changed win32 build process to use MSVC.NET (needed | # for Python 2.4, and add an additonal needed library | *************** *** 83,87 **** from distutils.extension import Extension ! __version__ = "2.4" # Define the runtime library path for this module. It starts out as None. --- 84,88 ---- from distutils.extension import Extension ! __version__ = "2.5" # Define the runtime library path for this module. It starts out as None. *************** *** 110,116 **** include_dirs = ["/usr/include", "/usr/local/pgsql/include", "/usr/include/postgresql"] 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') --- 111,114 ---- *************** *** 143,160 **** 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 mingw instead of MSVC.NET. ! 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", "shfolder"] modname="pyPgSQL.libpq.libpq" else: --- 141,148 ---- optional_libs += ["ssl", "crypto"] elif sys.platform == "win32": ! include_dirs = [os.popen("pg_config --includedir").read().strip()] ! library_dirs = [os.popen("pg_config --libdir").read().strip() + "/ms"] #optional_libs += ["wsock32", "advapi32"] ! optional_libs = ["libpq", "wsock32", "advapi32"] # , "shfolder"] modname="pyPgSQL.libpq.libpq" else: |
From: <gha...@us...> - 2006-06-01 13:40:46
|
Update of /cvsroot/pypgsql/pypgsql/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25328/test Modified Files: PgSQLTestCases.py Log Message: 01JUN2006 gh Slimmed down tests to make them work with recent Python and PostgreSQL releases. Index: PgSQLTestCases.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/test/PgSQLTestCases.py,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** PgSQLTestCases.py 6 Mar 2005 20:15:36 -0000 1.27 --- PgSQLTestCases.py 1 Jun 2006 13:40:36 -0000 1.28 *************** *** 33,36 **** --- 33,38 ---- # Date Ini Description | # --------- --- ------------------------------------------------------- | + # 01JUN2006 gh Slimmed down tests to make them work with recent Python | + # and PostgreSQL releases. | # 06MAR2005 bga Updated tests for PostgresQL 8.0 | # 06OCT2004 bga [Bug #816729] Updated tests for PostgreSQL 7.4(beta). | *************** *** 211,216 **** self.failUnless(b == 12345670, 'PgInt8 match failed to produce correct result.') ! b = PgSQL.PgInt8(3037000649L) ! self.failUnlessRaises(OverflowError, pow, b, 2) def CheckPgInt2(self): --- 213,218 ---- self.failUnless(b == 12345670, 'PgInt8 match failed to produce correct result.') ! # b = PgSQL.PgInt8(3037000649L) ! # self.failUnlessRaises(OverflowError, pow, b, 2) def CheckPgInt2(self): *************** *** 239,244 **** self.failUnless(b == 173, 'PgInt2 match failed to produce correct result.') ! b = PgSQL.PgInt2(182) ! self.failUnlessRaises(OverflowError, pow, b, PgSQL.PgInt2(2)) def CheckPgMoney(self): --- 241,246 ---- self.failUnless(b == 173, 'PgInt2 match failed to produce correct result.') ! # b = PgSQL.PgInt2(182) ! # self.failUnlessRaises(OverflowError, pow, b, PgSQL.PgInt2(2)) def CheckPgMoney(self): *************** *** 404,419 **** self.cnx = PgSQL.connect(database='template1') 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): try: --- 406,410 ---- self.cnx = PgSQL.connect(database='template1') self.cur = self.cnx.cursor() ! def tearDown(self): try: *************** *** 619,649 **** """Test execute() with a singleton string as the parameter.""" ! if self.vstr.startswith("8.0"): ! flen = 11 ! elif self.vstr.startswith("7.4"): ! flen = 11 ! elif self.vstr.startswith("7.3"): ! flen = 11 ! elif self.vstr.startswith("7.2"): ! flen = 9 ! elif self.vstr.startswith("7.1"): ! flen = 7 ! else: ! flen = 4 ! ! try: ! self.cur.execute(""" ! select * from pg_database ! where datname = %s""", 'template1') ! except StandardError, msg: ! self.fail(msg) ! ! self.assertEqual(type(self.cur.description), types.ListType, ! "cur.description should be a list, but isn't.") ! clen = len(self.cur.description) ! self.assertEqual(clen, flen, ! "Length of cur.description is %d, it should be %d." % ! (clen, flen)) # The following test checks the length of one of the cur.description's --- 610,619 ---- """Test execute() with a singleton string as the parameter.""" ! self.cur.execute(""" ! select 'x' || %s ! """, "y") ! res = self.cur.fetchone() ! self.assertEqual(res[0], "xy", "The query did not produce the expected result") # The following test checks the length of one of the cur.description's *************** *** 655,666 **** 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() --- 625,628 ---- *************** *** 669,732 **** try: self.cur.execute(""" ! select * from pg_database ! where datname = %s""", ('template1',)) except StandardError, msg: 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() def CheckExecuteWithDictionary(self): """Test execute() with a dictionary as the parameter.""" ! try: ! self.cur.execute(""" ! select * from pg_database ! where datname = %(dbname)s""", {'dbname': 'template1'}) ! except StandardError, msg: ! 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.") def CheckResultObject(self): --- 631,652 ---- try: self.cur.execute(""" ! select %s, %s ! """, ("a", "b")) except StandardError, msg: self.fail(msg) ! res = self.cur.fetchone() ! self.failUnlessEqual(res[0], "a", "did not get expected result for first column") ! self.failUnlessEqual(res[1], "b", "did not get expected result for second column") ! self.cur.close() def CheckExecuteWithDictionary(self): """Test execute() with a dictionary as the parameter.""" ! self.cur.execute(""" ! select %(value)s ! """, {"value": 10}) ! res = self.cur.fetchone() ! self.failUnlessEqual(res[0], 10, "Result does not match query parameter") def CheckResultObject(self): *************** *** 802,806 **** "res should be None at this point, but it isn't.") ! def CheckDoMoreResultObjectChecks(self): # Define the row counts for various version of PosrtgreSQL # Note: We only have to check for the minor version number in order --- 722,726 ---- "res should be None at this point, but it isn't.") ! def _disabled_CheckDoMoreResultObjectChecks(self): # Define the row counts for various version of PosrtgreSQL # Note: We only have to check for the minor version number in order |
From: <gha...@us...> - 2006-05-28 22:29:10
|
Update of /cvsroot/pypgsql/pypgsql In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17794 Modified Files: pgresult.c Log Message: Integrated patch #1224272. Use PyOS_ascii_strtod instead of strtod in order to be locale-agnostic. Index: pgresult.c =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pgresult.c,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** pgresult.c 2 Oct 2002 04:08:38 -0000 1.18 --- pgresult.c 28 May 2006 22:29:06 -0000 1.19 *************** *** 29,32 **** --- 29,34 ---- | Date Ini Description | | --------- --- ------------------------------------------------------- | + | 29MAY2006 gh Integrated patch #1224272. Use PyOS_ascii_strtod | + | instead of strtod in order to be locale-agnostic. | | 01OCT2002 gh HAVE_LONG_LONG => HAVE_LONG_LONG_SUPPORT | | 03FEB2002 bga Change the constant that is used to determine when to | *************** *** 111,114 **** --- 113,285 ---- /*--------------------------------------------------------------------------*/ + #if (PY_VERSION_HEX < 0x02040000) + + /* code stolen from Python 2.4 */ + + #include <locale.h> + + #define ISSPACE(c) ((c) == ' ' || (c) == '\f' || (c) == '\n' || \ + (c) == '\r' || (c) == '\t' || (c) == '\v') + #define ISDIGIT(c) ((c) >= '0' && (c) <= '9') + #define ISXDIGIT(c) (ISDIGIT(c) || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F')) + + /** + * PyOS_ascii_strtod: + * @nptr: the string to convert to a numeric value. + * @endptr: if non-%NULL, it returns the character after + * the last character used in the conversion. + * + * Converts a string to a #gdouble value. + * This function behaves like the standard strtod() function + * does in the C locale. It does this without actually + * changing the current locale, since that would not be + * thread-safe. + * + * This function is typically used when reading configuration + * files or other non-user input that should be locale independent. + * To handle input from the user you should normally use the + * locale-sensitive system strtod() function. + * + * If the correct value would cause overflow, plus or minus %HUGE_VAL + * is returned (according to the sign of the value), and %ERANGE is + * stored in %errno. If the correct value would cause underflow, + * zero is returned and %ERANGE is stored in %errno. + * + * This function resets %errno before calling strtod() so that + * you can reliably detect overflow and underflow. + * + * Return value: the #gdouble value. + **/ + double + PyOS_ascii_strtod(const char *nptr, + char **endptr) + { + char *fail_pos; + double val; + struct lconv *locale_data; + const char *decimal_point; + int decimal_point_len; + const char *p, *decimal_point_pos; + const char *end = NULL; /* Silence gcc */ + + /* g_return_val_if_fail (nptr != NULL, 0); */ + assert(nptr != NULL); + + fail_pos = NULL; + + locale_data = localeconv(); + decimal_point = locale_data->decimal_point; + decimal_point_len = strlen(decimal_point); + + assert(decimal_point_len != 0); + + decimal_point_pos = NULL; + if (decimal_point[0] != '.' || + decimal_point[1] != 0) + { + p = nptr; + /* Skip leading space */ + while (ISSPACE(*p)) + p++; + + /* Skip leading optional sign */ + if (*p == '+' || *p == '-') + p++; + + if (p[0] == '0' && + (p[1] == 'x' || p[1] == 'X')) + { + p += 2; + /* HEX - find the (optional) decimal point */ + + while (ISXDIGIT(*p)) + p++; + + if (*p == '.') + { + decimal_point_pos = p++; + + while (ISXDIGIT(*p)) + p++; + + if (*p == 'p' || *p == 'P') + p++; + if (*p == '+' || *p == '-') + p++; + while (ISDIGIT(*p)) + p++; + end = p; + } + } + else + { + while (ISDIGIT(*p)) + p++; + + if (*p == '.') + { + decimal_point_pos = p++; + + while (ISDIGIT(*p)) + p++; + + if (*p == 'e' || *p == 'E') + p++; + if (*p == '+' || *p == '-') + p++; + while (ISDIGIT(*p)) + p++; + end = p; + } + } + /* For the other cases, we need not convert the decimal point */ + } + + /* Set errno to zero, so that we can distinguish zero results + and underflows */ + errno = 0; + + if (decimal_point_pos) + { + char *copy, *c; + + /* We need to convert the '.' to the locale specific decimal point */ + copy = malloc(end - nptr + 1 + decimal_point_len); + + c = copy; + memcpy(c, nptr, decimal_point_pos - nptr); + c += decimal_point_pos - nptr; + memcpy(c, decimal_point, decimal_point_len); + c += decimal_point_len; + memcpy(c, decimal_point_pos + 1, end - (decimal_point_pos + 1)); + c += end - (decimal_point_pos + 1); + *c = 0; + + val = strtod(copy, &fail_pos); + + if (fail_pos) + { + if (fail_pos > decimal_point_pos) + fail_pos = (char *)nptr + (fail_pos - copy) - (decimal_point_len - 1); + else + fail_pos = (char *)nptr + (fail_pos - copy); + } + + free(copy); + + } + else + val = strtod(nptr, &fail_pos); + + if (endptr) + *endptr = fail_pos; + + return val; + } + + #endif + + /*--------------------------------------------------------------------------*/ + PyObject *PgResult_New(PGresult *res, PgConnection *conn, int type) { *************** *** 624,628 **** case PG_FLOAT8: ! valueObj = Py_BuildValue("d", strtod(value, NULL)); break; --- 795,799 ---- case PG_FLOAT8: ! valueObj = Py_BuildValue("d", PyOS_ascii_strtod(value, NULL)); break; |
From: <gha...@us...> - 2005-09-26 08:08:28
|
Update of /cvsroot/pypgsql/pypgsql In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14887 Modified Files: libpqmodule.h pgconnection.c pgversion.c setup.py Log Message: 26SEP2005 gh Changed win32 build process to use MSVC.NET (needed for Python 2.4, and add an additonal needed library for PostgreSQL 8. Other trivial fixes to allow compilation with MSVC.NET to finally build win32 binaries for Python 2.4. Index: libpqmodule.h =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/libpqmodule.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** libpqmodule.h 16 Jun 2003 11:59:41 -0000 1.10 --- libpqmodule.h 26 Sep 2005 08:08:17 -0000 1.11 *************** *** 44,49 **** --- 44,51 ---- #include <winsock.h> #include <windows.h> + #ifdef __MINGW__ #include "win32.h" #endif + #endif #define MODULE_NAME "libpq" Index: pgconnection.c =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pgconnection.c,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** pgconnection.c 16 May 2005 03:31:03 -0000 1.23 --- pgconnection.c 26 Sep 2005 08:08:17 -0000 1.24 *************** *** 100,103 **** --- 100,107 ---- #include "libpqmodule.h" + #ifdef _MSC_VER + #define strcasecmp lstrcmpiA + #endif + /*******************************************************\ | Notice Processor - Adds database notices to a list | Index: pgversion.c =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pgversion.c,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** pgversion.c 1 Mar 2005 21:06:44 -0000 1.22 --- pgversion.c 26 Sep 2005 08:08:17 -0000 1.23 *************** *** 32,35 **** --- 32,37 ---- | Date Ini Description | | --------- --- ------------------------------------------------------- | + | 26SEP2005 gh Minor fix for stricter C compilers (move variable | + | declaration to start of function). | | 06OCT2004 bga [Bug #786712 & #816729] Allowed for a version string | | containing the words "alpha" and "beta". | *************** *** 164,167 **** --- 166,170 ---- { char *last; + int i; /*******************************************************************\ *************** *** 181,185 **** * alpha, beta, etc versions of PostgreSQL */ - int i; for (i = 1; token[i] != 0; i++) { if (!isdigit(token[i])) { --- 184,187 ---- Index: setup.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/setup.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** setup.py 6 Mar 2005 04:56:26 -0000 1.24 --- setup.py 26 Sep 2005 08:08:17 -0000 1.25 *************** *** 45,48 **** --- 45,52 ---- # Date Ini Description | # --------- --- ------------------------------------------------------- | + # 26SEP2005 gh Changed win32 build process to use MSVC.NET (needed | + # for Python 2.4, and add an additonal needed library | + # for PostgreSQL 8. | + # [Bug #1154791] | # 05MAR2004 bga Added /usr/include/postgresql to includes. | # [Bug #1154791] | *************** *** 140,144 **** 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") --- 144,148 ---- elif sys.platform == "win32": # This works with the PostgreSQL source tree, so it's a bit ugly ... ! # Lines commented out are for using mingw instead of MSVC.NET. win_pg_build_root = os.getenv("PG_SRC", "../postgresql") *************** *** 149,156 **** "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: --- 153,160 ---- "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", "shfolder"] modname="pyPgSQL.libpq.libpq" else: |
From: Billy G. A. <bal...@us...> - 2005-05-21 01:31:48
|
Update of /cvsroot/pypgsql/pypgsql/pyPgSQL In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15921/pyPgSQL Modified Files: PgSQL.py Log Message: 20MAY2005 bga - Fixed code so that a DateTimeDelta is returned for a PostgreSQL time datatype. Index: PgSQL.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pyPgSQL/PgSQL.py,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** PgSQL.py 16 May 2005 03:37:56 -0000 1.48 --- PgSQL.py 21 May 2005 01:31:23 -0000 1.49 *************** *** 30,33 **** --- 30,35 ---- # Date Ini Description | # --------- --- ------------------------------------------------------- | + # 20MAY2005 bga - Fixed code so that a DateTimeDelta is returned for a | + # PostgreSQL time datatype. | # 15MAY2005 bga - A change to the datetime parsing changed the default | # datetime object from localtime to UTC. This update | *************** *** 925,930 **** if _ftv == PG_INTERVAL: return self.interval2RelativeDateTime(value) else: ! if (useUTCtimeValue): return DateTime.Parser.DateTimeFromString(value) else: --- 927,934 ---- if _ftv == PG_INTERVAL: return self.interval2RelativeDateTime(value) + elif _ftv == PG_TIME: + return DateTime.Parser.TimeFromString(value) else: ! if useUTCtimeValue or _ftv == PG_DATE: return DateTime.Parser.DateTimeFromString(value) else: |
From: Billy G. A. <bal...@us...> - 2005-05-16 21:56:50
|
Update of /cvsroot/pypgsql/pypgsql/pyPgSQL In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3623/pyPgSQL Modified Files: PgSQL.py Log Message: 15MAY2005 bga - A change to the datetime parsing changed the default datetime object from localtime to UTC. This update returns the default to localtime and adds a new variable, 'useUTCtimeValue' to control the default value of a datetime object. Setting it to 1 will cause the datetime object to reference the UTC time, 0 will cause the datetime object to reference the client's local time zone. Index: PgSQL.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pyPgSQL/PgSQL.py,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** PgSQL.py 6 Mar 2005 20:00:08 -0000 1.47 --- PgSQL.py 16 May 2005 03:37:56 -0000 1.48 *************** *** 1,3 **** ! #ident "@(#) $Id$" # vi:set sw=4 ts=8 showmode ai: #--(H+)-----------------------------------------------------------------+ --- 1,3 ---- ! #ident "@(#) $Il: PgSQL.py,v 1.47 2005/03/06 20:00:08 ballie01 Exp $" # vi:set sw=4 ts=8 showmode ai: #--(H+)-----------------------------------------------------------------+ *************** *** 30,33 **** --- 30,41 ---- # Date Ini Description | # --------- --- ------------------------------------------------------- | + # 15MAY2005 bga - A change to the datetime parsing changed the default | + # datetime object from localtime to UTC. This update | + # returns the default to localtime and adds a new vari- | + # able, 'useUTCtimeValue' to control the default value | + # of a datetime object. Setting it to 1 will cause the | + # datetime object to reference the UTC time, 0 will | + # cause the datetime object to reference the client's | + # local time zone. | # 27FEB2005 bga - Bug fix release to catch up with the outstanding bug | # reports. | *************** *** 446,449 **** --- 454,466 ---- noPostgresCursor = 0 + # Setting this variable to 1 will cause the datatime instance returned from + # the result set for a timestame with timezone to reference the corresponding + # UTC time value (not the value expressed in the clients time zone). + + useUTCtimeValue = 0 + + # Define the regular expresions used to determin the type of SQL statement + # that is being executed. + re_DQL = re.compile('^[\s]*SELECT[\s]', re.I) re_DRT = re.compile('[\s]*DROP[\s]+TABLE[\s]', re.I) *************** *** 909,914 **** return self.interval2RelativeDateTime(value) else: ! return DateTime.Parser.DateTimeFromString(value) ! #return DateTime.ISO.ParseAny(value) elif _ftv == BINARY: if isinstance(value, PgBytea) or type(value) is PgLargeObjectType: --- 926,933 ---- return self.interval2RelativeDateTime(value) else: ! if (useUTCtimeValue): ! return DateTime.Parser.DateTimeFromString(value) ! else: ! return DateTime.Parser.DateTimeFromString(value).localtime() elif _ftv == BINARY: if isinstance(value, PgBytea) or type(value) is PgLargeObjectType: |
From: Billy G. A. <bal...@us...> - 2005-05-16 21:20:52
|
Update of /cvsroot/pypgsql/pypgsql In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2881 Modified Files: pgconnection.c Log Message: 23MAR2005 bga Change code to fix some compatability problems with PostgreSQL 8.x. Index: pgconnection.c =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pgconnection.c,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** pgconnection.c 6 Mar 2005 20:00:07 -0000 1.22 --- pgconnection.c 16 May 2005 03:31:03 -0000 1.23 *************** *** 29,32 **** --- 29,34 ---- | Date Ini Description | | --------- --- ------------------------------------------------------- | + | 23MAR2005 bga Change code to fix some compatability problems with | + | PostgreSQL 8.x. | | 05MAR2005 bga Added missing PQclear() (fixes minor memory leak). | | [Bug #987719] | *************** *** 141,145 **** } ! r = ((r = PQhost(conn)) ? r : "localhost"); self->host = Py_BuildValue("s", r); self->port = Py_BuildValue("l", strtol(PQport(conn), NULL, 10)); --- 143,149 ---- } ! r = PQhost(conn); ! if (r == NULL || *r == 0) ! r = "localhost"; self->host = Py_BuildValue("s", r); self->port = Py_BuildValue("l", strtol(PQport(conn), NULL, 10)); *************** *** 148,152 **** self->tty = Py_BuildValue("s", PQtty(conn)); self->user = Py_BuildValue("s", PQuser(conn)); ! self->pass = Py_BuildValue("s", PQpass(conn)); self->bePID = Py_BuildValue("i", PQbackendPID(conn)); self->socket = Py_BuildValue("i", PQsocket(conn)); --- 152,162 ---- self->tty = Py_BuildValue("s", PQtty(conn)); self->user = Py_BuildValue("s", PQuser(conn)); ! r = PQpass(conn); ! if (r != NULL && *r == 0) { ! self->pass = Py_None; ! Py_INCREF(Py_None); ! } else { ! self->pass = Py_BuildValue("s", r); ! } self->bePID = Py_BuildValue("i", PQbackendPID(conn)); self->socket = Py_BuildValue("i", PQsocket(conn)); *************** *** 1190,1194 **** m = PQerrorMessage(cnx); ! if (*m == (char)0) { Py_INCREF(Py_None); --- 1200,1204 ---- m = PQerrorMessage(cnx); ! if (m != NULL && *m == (char)0) { Py_INCREF(Py_None); |
From: Billy G. A. <bal...@us...> - 2005-04-09 02:19:53
|
Update of /cvsroot/pypgsql/pypgsql In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6208 Modified Files: libpqmodule.c Log Message: 08APR2005 bga Un-did one of the fixes put in on 01MAR2005. It wasn't broke until I 'fixed' it. 01MAR2005 bga Fixed most outstanding bug reports and patches. Index: libpqmodule.c =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/libpqmodule.c,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** libpqmodule.c 1 Mar 2005 21:06:43 -0000 1.31 --- libpqmodule.c 9 Apr 2005 02:19:41 -0000 1.32 *************** *** 32,35 **** --- 32,40 ---- | Date Ini Description | | --------- --- ------------------------------------------------------- | + | 08APR2005 bga Un-did one of the fixes put in on 01MAR2005. It wasn't | + | broke until I 'fixed' it. | + | 01MAR2005 bga Fixed most outstanding bug reports and patches. | + | 09NOV2003 bga Fixed a buffer overrun error in libPQquoteBytea based | + | on a fix by James Matthew Farrow. [Bug #838317]. | | 09NOV2003 bga Fixed a buffer overrun error in libPQquoteBytea based | | on a fix by James Matthew Farrow. [Bug #838317]. | *************** *** 382,386 **** PyObject *result; ! slen = strlen(sin) + 1; sout = (char *)PyMem_Malloc(slen); if (sout == (char *)NULL) --- 387,391 ---- PyObject *result; ! slen = strlen(sin); sout = (char *)PyMem_Malloc(slen); if (sout == (char *)NULL) |
From: Billy G. A. <bal...@us...> - 2005-03-06 20:15:46
|
Update of /cvsroot/pypgsql/pypgsql/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5087/test Modified Files: PgSQLTestCases.py Log Message: 06MAR2005 bga Updated PgSQLTestCases.py for PostgreSQL 8.0. Index: PgSQLTestCases.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/test/PgSQLTestCases.py,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** PgSQLTestCases.py 6 Oct 2003 18:36:56 -0000 1.26 --- PgSQLTestCases.py 6 Mar 2005 20:15:36 -0000 1.27 *************** *** 33,36 **** --- 33,37 ---- # Date Ini Description | # --------- --- ------------------------------------------------------- | + # 06MAR2005 bga Updated tests for PostgresQL 8.0 | # 06OCT2004 bga [Bug #816729] Updated tests for PostgreSQL 7.4(beta). | # Thanks to Jeff Putnam for the fixes. | *************** *** 583,587 **** self.cur.close() vstr = "%(major)d.%(minor)d" % self.cnx.version ! if self.cnx.version.level != 0: vstr = vstr + ".%(level)d" % self.cnx.version self.failUnlessEqual(v, vstr, --- 584,588 ---- self.cur.close() vstr = "%(major)d.%(minor)d" % self.cnx.version ! if v != vstr or self.cnx.version.level != 0: vstr = vstr + ".%(level)d" % self.cnx.version self.failUnlessEqual(v, vstr, *************** *** 618,622 **** """Test execute() with a singleton string as the parameter.""" ! if self.vstr.startswith("7.4"): flen = 11 elif self.vstr.startswith("7.3"): --- 619,625 ---- """Test execute() with a singleton string as the parameter.""" ! if self.vstr.startswith("8.0"): ! flen = 11 ! elif self.vstr.startswith("7.4"): flen = 11 elif self.vstr.startswith("7.3"): *************** *** 803,807 **** # Note: We only have to check for the minor version number in order # to determine the needed row counts. ! rc = { '7.4':137, '7.3':124, '7.2':101, '7.1':80, '7.0':65, '6.5':47 } v = self.vstr --- 806,810 ---- # Note: We only have to check for the minor version number in order # to determine the needed row counts. ! rc = { '8.0':140, '7.4':137, '7.3':124, '7.2':101, '7.1':80, '7.0':65, '6.5':47 } v = self.vstr |
From: Billy G. A. <bal...@us...> - 2005-03-06 20:00:51
|
Update of /cvsroot/pypgsql/pypgsql In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv891 Modified Files: pgconnection.c Log Message: 06MAR2005 bga Found another missing PQclear() call in pgconnection.c Fixed a syntax error in PgSQL.py Index: pgconnection.c =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pgconnection.c,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** pgconnection.c 6 Mar 2005 05:13:29 -0000 1.21 --- pgconnection.c 6 Mar 2005 20:00:07 -0000 1.22 *************** *** 504,507 **** --- 504,508 ---- PyErr_SetString(exc, PQerrorMessage(PgConnection_Get(self))); + PQclear(res); return (PyObject *)NULL; } |
From: Billy G. A. <bal...@us...> - 2005-03-06 20:00:28
|
Update of /cvsroot/pypgsql/pypgsql/pyPgSQL In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv891/pyPgSQL Modified Files: PgSQL.py Log Message: 06MAR2005 bga Found another missing PQclear() call in pgconnection.c Fixed a syntax error in PgSQL.py Index: PgSQL.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pyPgSQL/PgSQL.py,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** PgSQL.py 6 Mar 2005 04:56:27 -0000 1.46 --- PgSQL.py 6 Mar 2005 20:00:08 -0000 1.47 *************** *** 974,978 **** #lst[_i] = DateTime.ISO.ParseAny(lst[_i]) else: ! lst[_i] = self.interval2RelativeDateTime(lst{_i]) elif _ftv == PG_MONEY: if lst[_i][0] == '(': --- 974,978 ---- #lst[_i] = DateTime.ISO.ParseAny(lst[_i]) else: ! lst[_i] = self.interval2RelativeDateTime(lst[_i]) elif _ftv == PG_MONEY: if lst[_i][0] == '(': |
From: Billy G. A. <bal...@us...> - 2005-03-06 05:13:39
|
Update of /cvsroot/pypgsql/pypgsql In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13918 Modified Files: pgconnection.c Log Message: 05MAR2005 bga Implemented partial fix given in Patch #987719. Index: pgconnection.c =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pgconnection.c,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** pgconnection.c 10 May 2004 03:34:03 -0000 1.20 --- pgconnection.c 6 Mar 2005 05:13:29 -0000 1.21 *************** *** 29,32 **** --- 29,34 ---- | Date Ini Description | | --------- --- ------------------------------------------------------- | + | 05MAR2005 bga Added missing PQclear() (fixes minor memory leak). | + | [Bug #987719] | | 09MAY2004 bga Added a 'debug' feature to the PgConnection object. | | 26JUN2003 bga Fixed a bug I introduced into lo_import. | *************** *** 385,388 **** --- 387,391 ---- PyErr_SetString(exc, errmsg); + PQclear(res); return NULL; } |
From: Billy G. A. <bal...@us...> - 2005-03-06 04:56:43
|
Update of /cvsroot/pypgsql/pypgsql In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10896 Modified Files: setup.py Log Message: 05MAR2005 bga Fixed bugs #1154792 1154791. Index: setup.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/setup.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** setup.py 10 May 2004 03:34:03 -0000 1.23 --- setup.py 6 Mar 2005 04:56:26 -0000 1.24 *************** *** 45,48 **** --- 45,50 ---- # Date Ini Description | # --------- --- ------------------------------------------------------- | + # 05MAR2004 bga Added /usr/include/postgresql to includes. | + # [Bug #1154791] | # 25APR2003 gh Added changes for registration with the Python Package | # index (PyPI) (http://python.org/pypi). | *************** *** 102,106 **** library_dirs = YOUR_LIST_HERE elif sys.platform == "linux2": ! include_dirs = ["/usr/include", "/usr/local/pgsql/include"] library_dirs = ["/usr/lib"] --- 104,108 ---- library_dirs = YOUR_LIST_HERE elif sys.platform == "linux2": ! include_dirs = ["/usr/include", "/usr/local/pgsql/include", "/usr/include/postgresql"] library_dirs = ["/usr/lib"] |
From: Billy G. A. <bal...@us...> - 2005-03-06 04:56:42
|
Update of /cvsroot/pypgsql/pypgsql/pyPgSQL In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10896/pyPgSQL Modified Files: PgSQL.py Log Message: 05MAR2005 bga Fixed bugs #1154792 1154791. Index: PgSQL.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pyPgSQL/PgSQL.py,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** PgSQL.py 1 Mar 2005 21:06:44 -0000 1.45 --- PgSQL.py 6 Mar 2005 04:56:27 -0000 1.46 *************** *** 974,978 **** #lst[_i] = DateTime.ISO.ParseAny(lst[_i]) else: ! lst[i] = self.interval2RelativeDateTime(lst{_i]) elif _ftv == PG_MONEY: if lst[_i][0] == '(': --- 974,978 ---- #lst[_i] = DateTime.ISO.ParseAny(lst[_i]) else: ! lst[_i] = self.interval2RelativeDateTime(lst{_i]) elif _ftv == PG_MONEY: if lst[_i][0] == '(': *************** *** 3204,3208 **** isinstance(parms[0], PgResultSet)): parms = _quoteall(self.__unicodeConvert(parms[0])) - self.res = self.conn.conn.query(_qstr % parms) else: parms = self.__unicodeConvert(parms) --- 3204,3207 ---- |
From: Billy G. A. <bal...@us...> - 2005-03-01 21:07:12
|
Update of /cvsroot/pypgsql/pypgsql/pyPgSQL In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25157/pyPgSQL Modified Files: PgSQL.py Log Message: 01MAR2005 bga Implemented most outstanding bug fixes and patches. Index: PgSQL.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pyPgSQL/PgSQL.py,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** PgSQL.py 27 Feb 2005 18:40:04 -0000 1.44 --- PgSQL.py 1 Mar 2005 21:06:44 -0000 1.45 *************** *** 30,33 **** --- 30,38 ---- # Date Ini Description | # --------- --- ------------------------------------------------------- | + # 27FEB2005 bga - Bug fix release to catch up with the outstanding bug | + # reports. | + # 27FEB2005 gh - Converted all checks for Unicode types to isinstance | + # checks. Fixes bugs #1055180, #1051520, #1016026, | + # #1016010. | # 31JUL2004 bga - Fixed mis-spelling of __comm to __conn. | # [Bug #1001242] | *************** *** 460,463 **** --- 465,474 ---- TimestampFromTicks = DateTime.TimestampFromTicks + #--------------------------------------------------+ + # The RelativeDateTime type for PgInterval support | + #--------------------------------------------------+ + + RelativeDateTime = DateTime.RelativeDateTime + #-----------------------------------------------+ # The DateTimeDelta type for PgInterval support | *************** *** 472,476 **** DateTimeType = DateTime.DateTimeType DateTimeDeltaType = DateTime.DateTimeDeltaType - DateTimeDelta = DateTime.DateTimeDelta #-----------------------------------------------------------------------+ --- 483,486 ---- *************** *** 583,586 **** --- 593,602 ---- """Type cache -- used to cache postgreSQL data type information.""" + _time_units = ( + ( 'days', 'day'), + ( 'months', 'month', 'mon', 'mons' ), + ( 'years', 'year'), + ) + def __init__(self, conn): if noWeakRef: *************** *** 611,614 **** --- 627,651 ---- ydh = ydh[2:] + # Convert any months using 30 days per month, which is PostgreSQL's + # assumption about the number of days in a months IF it doesn't + # know the end or start date of the interval. If PG DOES know either + # date it will use the correct length of the month, eg 28-31 days. + # However, at this stage we have no way of telling which one it + # was. If you want to work with accurate intervals (eg. post-processing + # them) you need to use date1-date2 syntax rather than age(date1, date2) + # in your queries. + # + # This is per discussion on pgsql-general: + # http://www.spinics.net/lists/pgsql/msg09668.html + # Google for: + # >>>"interval output format" available that removes ambiguity<<< + # + # Note: Should a notice be provided to the user that post-processing + # year/month intervals is unsafe practice ? + if len(ydh) > 1: + if ydh[1].lower().startswith('mon'): + result += parser('%s days' % ((int(ydh[0]) * 30),)) + ydh = ydh[2:] + # Converts any days and adds it to the years (as an interval) if len(ydh) > 1: *************** *** 623,626 **** --- 660,694 ---- return result + def interval2RelativeDateTime(self, s): + """Parses PostgreSQL INTERVALs. + The expected format is [[[-]YY years] [-]DD days] [-]HH:MM:SS.ss""" + + tokens = s.split() + quantity = None + result = RelativeDateTime() + for token in tokens: + # looking for quantity + if token.isdigit() or token[0] == '-' and token[1:].isdigit(): + quantity = int(token) + continue + # looking for unit + elif token.isalpha() and not quantity is None: + unitAttr = None + for unit in self._time_units: + if token in unit: + unitAttr = unit[0] + if unitAttr and not quantity is None: + setattr(result, unitAttr, quantity) + quantity = None + continue + # looking for time + elif token.find(':') != -1: + hms = [ int(value) for value in token.split(':') ] + result.hour = hms[0] + result.minute= hms[1] + if len(hms) == 3: + result.second = hms[2] + return result + def parseArray(self, s): """Parse a PostgreSQL array strings representation. *************** *** 829,839 **** return PgMoney(value).value elif _ftv == DATETIME: ! if type(value) in [DateTimeType, DateTimeDeltaType]: return value else: if _ftv == PG_INTERVAL: ! return self.interval2DateTimeDelta(value) else: ! return DateTime.ISO.ParseAny(value) elif _ftv == BINARY: if isinstance(value, PgBytea) or type(value) is PgLargeObjectType: --- 897,914 ---- return PgMoney(value).value elif _ftv == DATETIME: ! if type(value) is DateTimeType: ! if value in ('infinity', '+infinity', '-infinity'): ! fake_infinity = '9999-12-13 23:59:59' # fake infinity ! if value[0] == '-': ! value = '-' + fake_infinity ! else: ! value = fake_infinity return value else: if _ftv == PG_INTERVAL: ! return self.interval2RelativeDateTime(value) else: ! return DateTime.Parser.DateTimeFromString(value) ! #return DateTime.ISO.ParseAny(value) elif _ftv == BINARY: if isinstance(value, PgBytea) or type(value) is PgLargeObjectType: *************** *** 888,892 **** lst[_i] = PgInt2(lst[_i]) elif _ftv == DATETIME: ! lst[_i] = DateTime.ISO.ParseAny(lst[_i]) elif _ftv == PG_MONEY: if lst[_i][0] == '(': --- 963,978 ---- lst[_i] = PgInt2(lst[_i]) elif _ftv == DATETIME: ! if _fvt != PG_INTERVAL: ! if lst[_i] in ('infinity', '+infinity', '-infinity'): ! fake_infinity = '9999-12-13 23:59:59' # fake infinity ! if lst[_i][0] == '-': ! lst[_i] = '-' + fake_infinity ! else: ! lst[_i] = fake_infinity ! else: ! lst[_i] = DateTime.Parser.DateTimeFromString(lst[_i]) ! #lst[_i] = DateTime.ISO.ParseAny(lst[_i]) ! else: ! lst[i] = self.interval2RelativeDateTime(lst{_i]) elif _ftv == PG_MONEY: if lst[_i][0] == '(': *************** *** 1455,1459 **** # and scale. It can also make a copy of a PgNumeric. self.__v = value.__v ! if scale: self.__s = scale _ds = scale - value.__s --- 1541,1545 ---- # and scale. It can also make a copy of a PgNumeric. self.__v = value.__v ! if scale is not None: self.__s = scale _ds = scale - value.__s *************** *** 1669,1673 **** _c = self.__coerce__(other) if _c is None: ! return None self, other = _c if self.__s < other.__s: --- 1755,1759 ---- _c = self.__coerce__(other) if _c is None: ! return 1 self, other = _c if self.__s < other.__s: *************** *** 1698,1706 **** def _quote(self, forArray=0): ! if self.__v != None: if forArray: return '"%s"' % self.__fmtNumeric() else: ! return "'%s'" % self.__fmtNumeric() return 'NULL' --- 1784,1792 ---- def _quote(self, forArray=0): ! if self.__v is not None: if forArray: return '"%s"' % self.__fmtNumeric() else: ! return self.__fmtNumeric() return 'NULL' *************** *** 1853,1861 **** def _quote(self, forArray=0): ! if self.value: if forArray: return '"%s"' % str(self.value) else: ! return "'%s'" % str(self.value) return 'NULL' --- 1939,1947 ---- def _quote(self, forArray=0): ! if self.value is not None: if forArray: return '"%s"' % str(self.value) else: ! return str(self.value) return 'NULL' *************** *** 2191,2195 **** # ary using _quote. | # dateTimeDelta2Interval() -- converts a DateTimeDelta type into | ! # a string PostgreSQL accepts as a interval. | #-----------------------------------------------------------------------+ --- 2277,2283 ---- # ary using _quote. | # dateTimeDelta2Interval() -- converts a DateTimeDelta type into | ! # a string PostgreSQL accepts as an interval. | ! # relativeDateTime2Interval() -- converts a RelativeDateTime into | ! # a string PostgreSQL accepts as an interval. | #-----------------------------------------------------------------------+ *************** *** 2266,2269 **** --- 2354,2359 ---- elif type(_i) is DateTime.DateTimeDeltaType: _j = '%s"%s",' % (_j, dateTimeDelta2Interval(_i)) + elif isinstance(value, RelativeDateTime): + _j = '%s"%s",' % (_j, relativeDateTime2Interval(_i)) elif type(_i) is PgInt2Type or isinstance(_i, PgInt8Type): _j = '%s%s,' % (_j, str(_i)) *************** *** 2295,2298 **** --- 2385,2390 ---- elif type(value) is DateTimeDeltaType: return "'%s'" % dateTimeDelta2Interval(value) + elif isinstance(value, RelativeDateTime): + return "'%s'" % relativeDateTime2Interval(value) elif isinstance(value, StringType): return PgQuoteString(value) *************** *** 2358,2361 **** --- 2450,2469 ---- raise TypeException, "DateTimeDelta2Interval requires a DataTimeDelta." + + def relativeDateTime2Interval(interval): + """ + relativeDateTime2Interval - Converts a RelativeDateTime to an interval string\n + The output format is YYYY years M mons DD days HH:MM:SS\n + """ + + if type(interval) is RelativeDateTime: + return "%s years %s mons %s days %02i:%02i:%02i" % ( + interval.years, interval.months, interval.days, + interval.hours, interval.minutes, interval.seconds + ) + else: + raise TypeException, \ + "relativeDateTime2Interval requires a RelativeDateTime" + #-----------------------------------------------------------------------+ # Name: Connection | *************** *** 2849,2853 **** break elif count > 0: ! for _i in range(count): _j = self.__fetchOneRow() if _j is not None: --- 2957,2961 ---- break elif count > 0: ! for _i in xrange(count): _j = self.__fetchOneRow() if _j is not None: |