Skip to content

Commit 17dfa76

Browse files
committed
Handle executemany incomplete iteration
1 parent 29d13dd commit 17dfa76

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

apsw/tests/__main__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,6 +1010,20 @@ def myvals():
10101010
# incomplete execution across executemany
10111011
c.executemany("select * from foo; select ?", ((1,), (2,))) # we don't read
10121012
self.assertRaises(apsw.IncompleteExecutionError, c.executemany, "begin", (1, 2))
1013+
# this gets more complicated - if executemany doesn't consume the iterable
1014+
# and another execute is started, we also consider that incomplete
1015+
c.executemany("select ?", ((i,) for i in range(10)))
1016+
self.assertRaisesRegex(
1017+
apsw.IncompleteExecutionError, ".*executemany were not fully consumed.*", c.execute, "select 3"
1018+
)
1019+
c.executemany("select ?", ((i,) for i in range(10)))
1020+
self.assertRaisesRegex(
1021+
apsw.IncompleteExecutionError,
1022+
".*executemany were not fully consumed.*",
1023+
c.executemany,
1024+
"select ?",
1025+
((i,) for i in range(10)),
1026+
)
10131027

10141028
# set type (pysqlite error with this)
10151029
c.execute("create table xxset(x,y,z)")

src/cursor.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ resetcursor(APSWCursor *self, int force)
183183
if (next)
184184
{
185185
Py_DECREF(next);
186+
if(!PyErr_Occurred())
187+
PyErr_Format(ExcIncomplete, "Error: The values for executemany were not fully consumed");
186188
res = SQLITE_ERROR;
187189
assert(PyErr_Occurred());
188190
}

0 commit comments

Comments
 (0)