Skip to content

Commit 3f2c433

Browse files
author
Erlend Egeberg Aasland
authored
bpo-45041: Restore sqlite3 executescript behaviour for SELECT queries (GH-28509)
* bpo-45041: Restore sqlite3 executescript behaviour for select queries * Add regression test
1 parent dd02a69 commit 3f2c433

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

Lib/sqlite3/test/test_regression.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,17 @@ def dup(v):
475475
con.execute("drop table t")
476476
con.commit()
477477

478+
def test_executescript_step_through_select(self):
479+
with managed_connect(":memory:", in_mem=True) as con:
480+
values = [(v,) for v in range(5)]
481+
with con:
482+
con.execute("create table t(t)")
483+
con.executemany("insert into t values(?)", values)
484+
steps = []
485+
con.create_function("step", 1, lambda x: steps.append((x,)))
486+
con.executescript("select step(t) from t")
487+
self.assertEqual(steps, values)
488+
478489

479490
if __name__ == "__main__":
480491
unittest.main()

Modules/_sqlite/cursor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ pysqlite_cursor_executescript_impl(pysqlite_Cursor *self,
760760
&tail);
761761
if (rc == SQLITE_OK) {
762762
do {
763-
(void)sqlite3_step(stmt);
763+
rc = sqlite3_step(stmt);
764764
} while (rc == SQLITE_ROW);
765765
rc = sqlite3_finalize(stmt);
766766
}

0 commit comments

Comments
 (0)