Skip to content

Use sqlite_master for the read-lock schema probe - #769

Closed
Vikram12301 wants to merge 1 commit into
tox-dev:mainfrom
Vikram12301:sqlite-master-schema-probe
Closed

Vikram12301 wants to merge 1 commit into
tox-dev:mainfrom
Vikram12301:sqlite-master-schema-probe

Conversation

@Vikram12301

Copy link
Copy Markdown
Contributor

Summary

The read lock forces SQLite to take a shared lock by selecting from the schema table. The code uses sqlite_schema, which only exists from SQLite 3.33.0 on. Older SQLite builds fail every read lock:

sqlite3.OperationalError: no such table: sqlite_schema

This changes the name to sqlite_master, the long-standing name that works on every SQLite version. Nothing else changes.

Reproduction

Built SQLite 3.32.3 from the official amalgamation and ran the same statement the read lock issues:

$ echo "BEGIN TRANSACTION; SELECT name FROM sqlite_schema LIMIT 1;" | ./sqlite3_332 :memory:
Error: near line 1: no such table: sqlite_schema
$ echo "BEGIN TRANSACTION; SELECT name FROM sqlite_master LIMIT 1;" | ./sqlite3_332 :memory:
OK

The bug is not platform specific. Any environment that bundles SQLite older than 3.33.0 hits it.

Testing

  • tox run -e 3.13: 1856 passed, 57 skipped, 100% line and branch coverage, diff-cover reports no missing lines.
  • tox run -e fix: passes.

The read lock forces SQLite to take a shared lock by selecting from the
schema table. The sqlite_schema name only exists from SQLite 3.33.0 on, so
older SQLite builds fail every read lock with "no such table: sqlite_schema".
sqlite_master is the long-standing name and works on all versions.
@gaborbernat gaborbernat closed this Oct 5, 2026
gaborbernat added a commit that referenced this pull request Oct 5, 2026
Use sqlite_master for the read-lock schema probe so SQLite versions older
than 3.33.0 can acquire read locks. Include the required changelog fragment.

Supersedes #769.

Co-authored-by: Vikram M <[email protected]>
@gaborbernat

Copy link
Copy Markdown
Member

#771

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants