Skip to content

wrong detection of IncompleteExecutionError in fetchone() #376

@hofmandl1

Description

@hofmandl1

the following snippet demonstrates a bug that we did not experience with 3.36.0 but started to experience when upgrading to 3.39.4.0 (3.39.3.0 is also affected, but I guess this is not very relevant):

import apsw

connection = apsw.Connection(":memory:")
cursor = connection.cursor()
cursor.execute('SELECT 1;\n').fetchone()
cursor.execute('SELECT 2;').fetchone()

Error is

Traceback (most recent call last):
  File "C:\Users\hofmandl\apsw_bug.py", line 6, in <module>
    cursor.execute('SELECT 2;').fetchone()
  File "apsw\src\cursor.c", line 229, in resetcursor
    AddTraceBackHere(__FILE__, __LINE__, "resetcursor", "{s: i}", "res", res);
apsw.IncompleteExecutionError: Error: there are still remaining sql statements to execute

Changing either the first fetchone to fetchall or removing the newline character at the end of the statement or removing the semicolon makes the exception go away.

Note that this may be easier to produce than one might think. In our case we also didn't use the newline literal, but had a multiline-string:

cursor.execute('''
      SELECT A, B, C
           FROM FOO
      WHERE BAR = 1;
''').fetchone()

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions