[issue44079] [sqlite3] remove superfluous statement weak ref list from connection object

Erlend E. Aasland report at bugs.python.org
Wed May 19 05:53:39 EDT 2021


Erlend E. Aasland <erlend.aasland at innova.no> added the comment:

Yes, that seems to be the intention. But, I don't think there is a need to maintain the second list:

1. Resetting statements was historically needed both for commit and rollback; pending statements would block such operations. That's no longer the case for recent SQLite versions (commits fixed in SQLite 3.6.5, rollbacks in SQLite 3.7.11). The sqlite3 module no longer reset commit statements (6ed442c48dd7f8d3097e688a36bc027df3271621), and there should be no need to reset rollbacks either (see bpo-44092).
2. A statement with ref count zero will be garbage collected. Thus, of a statement is dropped from the LRU cache, it will be sqlite3_finalize'd. No statement, no problem. It's the same effect as if _pysqlite_drop_unused_statement_references() used the same limit as the LRU cache.

If we want to explicit reset statements (for some reason), we'd be better off to use sqlite3_stmt_next(). It's faster, and it covers _all_ statements for a given connection.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44079>
_______________________________________


More information about the Python-bugs-list mailing list