[CONPY-51] commit clears cursor buffer before fetch Created: 2020-04-03  Updated: 2020-04-05  Resolved: 2020-04-05

Status: Closed
Project: MariaDB Connector/Python
Component/s: DBAPI 2.0
Affects Version/s: 0.9.55
Fix Version/s: 0.9.56

Type: Bug Priority: Major
Reporter: Luciano Barcaro Assignee: Georg Richter
Resolution: Fixed Votes: 0
Labels: None


 Description   

if a select query is executed without parameter, after commit, the cursor looses fetched rows.

db = mariadb.connect(...)
qr = db.cursor(buffered=True)
qr.execute('create temporary table temp (a int unsigned)')
qr.execute('insert into temp values (1), (2), (3)')
 
qr.execute('select a from temp')
db.commit()
qr.fetchall()
Traceback (most recent call last):
  File "<input>", line 1, in <module>
    qr.fetchall()
mariadb.ProgrammingError: Cursor doesn't have a result set
 
qr.execute('select a from temp where a > ?', (0, ))
db.commit()
qr.fetchall()
[(1,), (2,), (3,)]



 Comments   
Comment by Georg Richter [ 2020-04-03 ]

Fix should be simple: if cursor type is buffered, we need to store the field_count value inside cursor instead of calling the api function mysql_(stmt_)field_count which was resetted due to previous commit call.

Comment by Luciano Barcaro [ 2020-04-03 ]

Georg, did you noted that if I pass a parameter, the commit does not flush the cursor buffer?

Generated at Thu Feb 08 03:29:53 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.