-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SQLite schema cache is not properly invalidated #1332
Comments
If you really need to cache column names for whatever reason (performance?), maybe something like this can be done: BEGIN;
PRAGMA schema_version; -- compare the returned value with the cached version
SELECT some_user_query();
COMMIT; But at this point I'm not sure whether it would be better than not caching anything... |
Is there a way to create a temporary trigger that runs a callback when the schema changes? I think that would fix this SQLite column caching is a significant perf boost and I'd like to find a way to fix this without a performance regression |
Triggers do not cross the process boundary. SQLite internally has knowledge of the schema version, but that doesn't seem to be available to outside like column names are. A new SQLite API like this should work: sqlite3_uint64 sqlite3_schema_version(sqlite3_stmt*); This sounds like a feature request for SQLite! |
I think it'd be reasonable to add a flag to the |
Version
0.2.0
Platform
What steps will reproduce the bug?
Run the script:
In another terminal:
How often does it reproduce? Is there a required condition?
Always.
What is the expected behavior?
After the concurrent
alter table
statement, the output from Bun becomes:What do you see instead?
Bun's output is still:
Additional information
The previous issue on this (#921) was closed without a correct fix. #1056 only does schema cache invalidation for changes within the same process, but SQLite is a database sharable across processes. Especially considering all those recent distributed and replicated SQLite additions (Litestream, LiteFS, mvSQLite) this is a correctness issue with pretty high impact.
The text was updated successfully, but these errors were encountered: