This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author erlendaasland
Recipients berker.peksag, corona10, erlendaasland, serhiy.storchaka
Date 2021-02-24.21:09:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1614200974.06.0.056941670318.issue43290@roundup.psfhosted.org>
In-reply-to
Content
There are six users of pysqlite_step():

$ grep -nrE "\<pysqlite_step\>" Modules/_sqlite
Modules/_sqlite/util.c:27:int pysqlite_step(sqlite3_stmt* statement, pysqlite_Connection* connection)
Modules/_sqlite/connection.c:393:    rc = pysqlite_step(statement, self);
Modules/_sqlite/connection.c:442:        rc = pysqlite_step(statement, self);
Modules/_sqlite/connection.c:493:        rc = pysqlite_step(statement, self);
Modules/_sqlite/util.h:32:int pysqlite_step(sqlite3_stmt* statement, pysqlite_Connection* connection);
Modules/_sqlite/cursor.c:519:        rc = pysqlite_step(self->statement->st, self->connection);
Modules/_sqlite/cursor.c:715:            rc = pysqlite_step(statement, self->connection);
Modules/_sqlite/cursor.c:787:        rc = pysqlite_step(self->statement->st, self->connection);

The three users in Modules/_sqlite/connection.c — _pysqlite_connection_begin(), pysqlite_connection_commit_impl(), and pysqlite_connection_rollback_impl() – are all ok, following this pattern:
1) prepare the statement
2) verify that prepare was successful, bail if not
3) call step

pysqlite_cursor_executescript() (line 715 in Modules/_sqlite/cursor.c) is also ok:
1) prepare the statement
2) verify that prepare was successful, bail if not
3) call step until there are no more rows

I need a little bit more time to verify _pysqlite_query_execute() and pysqlite_cursor_iternext().



Note to self: pysqlite_cursor_executescript() calls sqlite3_finalize() three times. It would have been better to break out of the loop when rc != SQLITE_ROW, immediately call sqlite3_finalize() (error code is preserved if sqlite3_step() failed), and then check rc and PyErr_Occurred(). It will make the code easier to follow, IMO.
History
Date User Action Args
2021-02-24 21:09:34erlendaaslandsetrecipients: + erlendaasland, berker.peksag, serhiy.storchaka, corona10
2021-02-24 21:09:34erlendaaslandsetmessageid: <1614200974.06.0.056941670318.issue43290@roundup.psfhosted.org>
2021-02-24 21:09:34erlendaaslandlinkissue43290 messages
2021-02-24 21:09:33erlendaaslandcreate