You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import apsw
def myexectrace(cursor, sql, bindings):
print '*', sql
print '*', cr.getdescription()
return True
cn = apsw.Connection(':memory:')
cn.setexectrace(myexectrace)
cr = cn.cursor()
cr.execute('create table x(x integer);')
cr.execute('create table y(y text, z integer);')
cr.execute('insert into x values (1),(2),(3)')
cr.execute("insert into y values ('A',1),('B',2),('C',3)")
for row in cr.execute('select * from x; select * from y;'):
print row
for row in cr.execute('select * from x; select * from y;'):
print cr.getdescription()
for row in cr.execute('select * from y; select * from x;'):
print row
for row in cr.execute('select * from y; select * from x;'):
print cr.getdescription()
--//--
returns the following:
>test.py
* create table x(x integer);
* ()
* create table y(y text, z integer);
* ()
* insert into x values (1),(2),(3)
* ()
* insert into y values ('A',1),('B',2),('C',3)
* ()
* select * from x;
* ((u'x', u'integer'),)
(1,)
(2,)
(3,)
* select * from y;
* ((u'x', u'integer'),)
(u'A', 1)
(u'B', 2)
(u'C', 3)
* select * from x;
* ((u'x', u'integer'),)
((u'x', u'integer'),)
((u'x', u'integer'),)
((u'x', u'integer'),)
* select * from y;
* ((u'x', u'integer'),)
((u'x', u'integer'),)
((u'x', u'integer'),)
((u'x', u'integer'),)
* select * from y;
* ((u'y', u'text'), (u'z', u'integer'))
(u'A', 1)
(u'B', 2)
(u'C', 3)
* select * from x;
* ((u'y', u'text'), (u'z', u'integer'))
(1,)
(2,)
(3,)
* select * from y;
* ((u'y', u'text'), (u'z', u'integer'))
((u'y', u'text'), (u'z', u'integer'))
((u'y', u'text'), (u'z', u'integer'))
((u'y', u'text'), (u'z', u'integer'))
* select * from x;
* ((u'y', u'text'), (u'z', u'integer'))
((u'y', u'text'), (u'z', u'integer'))
((u'y', u'text'), (u'z', u'integer'))
((u'y', u'text'), (u'z', u'integer'))
Adding a printf("RESET\n"); to the start of the resetcursor indicates that the cursor is not reset between statements hence the description_cache is not cleared:
One solution is to add Py_CLEAR for the description_cache in the cursor_step routine around line 900 after the bindings are reset for the next statement and before the exectrace hook is called. On the other hand, perhaps a call to resetcursor should be being made somewhere in this case. In any event, inserting the extra calls to clear the description_cache fixes and produces the following (correct) output:
Using following code (test.py):
Adding a printf("RESET\n"); to the start of the resetcursor indicates that the cursor is not reset between statements hence the description_cache is not cleared:
One solution is to add Py_CLEAR for the description_cache in the cursor_step routine around line 900 after the bindings are reset for the next statement and before the exectrace hook is called. On the other hand, perhaps a call to resetcursor should be being made somewhere in this case. In any event, inserting the extra calls to clear the description_cache fixes and produces the following (correct) output:
The text was updated successfully, but these errors were encountered: