Bug 51857

Summary: fetchone() / fetchmany() broken in PyGreSQL (Python interface)
Product: Red Hat Database Reporter: Neil Padgett <npadgett>
Component: client-interfacesAssignee: Neil Padgett <npadgett>
Status: CLOSED ERRATA QA Contact: Fernando Nasser <fnasser>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.1   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2001-08-15 22:06:36 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Patch fixes the issue (provided on pgsql-patches mailing list by Gerhard Hdring <haering_python@gmx.de>) none

Description Neil Padgett 2001-08-15 22:03:11 UTC
From Bugzilla Helper:
User-Agent: Mozilla/4.77 [en] (X11; U; Linux 2.4.3-12smp i686)

Description of problem:


Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
Excerpt from report: (Reported by williams)

I'm using the Python Database API 2.0 interface module (pgdb.py) to 
access a PosgreSQL database. I'm using the new interface (as opposed to 
the old pg.py) because I'm emulating behaviour of the DCOracle interface 
to Oracle, which is a 2.0 compliant module.

I'm trying to understand the behavior of the 'fetchone' access method. 
It looks like it should allow me to iterate through the results of a 
select one row at a time, but it seems to only give me the first row of 
the result set. I've looked at both the python code and the underlying C 
code and I can't really convince myself one way or the other (i.e. is it 
working as designed, or is it broken?).

The following python code is what I'm using to test it:

######################################
import pgdb

db = pgdb.connect(database="williams", host="rhnsat")

c = db.cursor()

c.execute('select tablename from pg_tables')

print 'rowcount = ', c.rowcount

row = c.fetchone()
count = 0
while row != None:
     print count, str(row)
     count = count + 1
     row = c.fetchone()

#count = 0
#for row in c.fetchall():
#    print count, str(row)
#    count = count + 1
#####################################

The commented out block at the bottom "works" in that it returns all the 
tablenames in the database. The uncommented code follwing the print 
statement "doesn't work" in that it only returns the first row of data. 
What I find strange is that it does this "rowcount" times, then returns 
None, indicating no more data. This is what leads me to believe that 
it's broken. If fetchone were only intended to return the first row of a 
result set, it seems to me that the loop would never terminate.


Actual Results:   

Additional info:

Comment 1 Neil Padgett 2001-08-15 22:06:32 UTC
Created attachment 28053 [details]
Patch fixes the issue (provided on pgsql-patches mailing list by Gerhard Hdring <haering_python>)