From: jeremy at cnri.reston.va.us (Jeremy Hylton)
Date: Tue, 13 Apr 1999 22:04:41 GMT
Subject: bug in PyGreSQL module
In-Reply-To: <Pine.SOL2.3.96.SK.990413202550.14558g-100000@sun.med.ru>
References: <14099.24295.229214.504295@bitdiddle.cnri.reston.va.us>
	<Pine.SOL2.3.96.SK.990413202550.14558g-100000@sun.med.ru>
Message-ID: <14099.48588.851795.102448@bitdiddle.cnri.reston.va.us>
Content-Length: 1302
X-UID: 1601                                                  

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




