Bug 51857 - fetchone() / fetchmany() broken in PyGreSQL (Python interface)
fetchone() / fetchmany() broken in PyGreSQL (Python interface)
Status: CLOSED ERRATA
Product: Red Hat Database
Classification: Red Hat
Component: client-interfaces (Show other bugs)
7.1
All Linux
medium Severity medium
: ---
: ---
Assigned To: Neil Padgett
Fernando Nasser
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2001-08-15 18:03 EDT by Neil Padgett
Modified: 2007-04-18 12:35 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2001-08-15 18:06:36 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Patch fixes the issue (provided on pgsql-patches mailing list by Gerhard Hdring <haering_python@gmx.de>) (899 bytes, patch)
2001-08-15 18:06 EDT, Neil Padgett
no flags Details | Diff

  None (edit)
Description Neil Padgett 2001-08-15 18:03:11 EDT
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@redhat.com)

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 18:06:32 EDT
Created attachment 28053 [details]
Patch fixes the issue (provided on pgsql-patches mailing list by Gerhard Hdring <haering_python@gmx.de>)

Note You need to log in before you can comment on or make changes to this bug.