bug in PyGreSQL module

Jeremy Hylton jeremy at cnri.reston.va.us
Tue Apr 13 18:04:41 EDT 1999


I'm using PyGreSQL 2.3, Postgres 6.4.2, and Python 1.5.2b2 on RedHat
Linux 5.2.  (That's a lot of version numbers!)

Here's an example of the error.  I've extracted the three rows from a
table (and gotten ride of the date because it's too wide).   As you
can see, in the first two rows the min, average, and max fields are
empty. 

source|source_addr|dest|dest_addr|when|size|sent|recv|min|average|max
------+-----------+----+---------+----+----+----+----+---+-------+---
    19|         41|   6|        6|XXXX| 100|  10|   0|   |       |   
    19|         41|   6|        6|XXXX|1000|  10|   0|   |       |   
    19|         41|   6|        6|XXXX| 100|  10|   4|120|    184|245

If I perform the query in Python and then call the getresult method, I 
get back the following list:

[(19, 41, 6, 6, 'Tue Apr 13 00:46:05 1999 EDT', 100, 10, 0, 0, 0, 0), 
(19, 41, 6, 6, 'Tue Apr 13 00:45:14 1999 EDT', 1000, 10, 0, 0, 0, 0), 
(19, 41, 6, 6, 'Tue Apr 13 00:16:05 1999 EDT', 100, 10, 4, 120, 184, 245)]

The nulls have been converted to 0.  This seems straightforward given
the C code in getresult.  If the field is an integer, the libpq value
is always handed off to PyInt_FromLong.  I would think that there
should be an explicit check for NULLs in pg_getresult that converts
them to None.

Jeremy




More information about the Python-list mailing list