Repository navigation
Refresh all connection-local state on PRAGMA data_version changes - #28
Merged
Merged
Conversation
fill_db_version_if_needed consumed the data_version check for its own cache, leaving other cached state (e.g. merge-equal-values config) stale when a different code path observed the change first. Introduce refresh_connection_state_if_needed which performs the single data_version check and fans out to per-cache reload_* functions (reload_db_version, reload_connection_config). Invoke it from the db_version fill path, crsql_config_get, crsql_set_ts, and crsql_changes merge inserts so every cached value is reloaded consistently from the same snapshot. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
gorbak25
added this pull request to stack #30
October 11, 2026 22:14
The fill_db_version_if_needed wrapper no longer earns its name now that the shared refresher handles first-use initialization itself.
somtochiama
approved these changes
Oct 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When
PRAGMA data_versionchanges, we previously only reloadeddb_version, but the config may have changed too. This PR refreshes all connection-local state on a data_version change and is structured so morereload_*methods can be added later (e.g. caches we'd like to keep across commit boundaries).This is extracted from #26, where knowing the current config is needed to pick the right queries/code paths. Splitting it out makes the motivation clearer.
data_versionis also checked inx_crsql_set_tsto work around a vtab limitation: when the schema changes on another connection, we need to regenerate our cached statements in addition to reloading config anddb_version. That regeneration fails during a write tocrsql_changesbecause of nested trigger limitations. Since #26 makesset_tsa prerequisite for most crsql operations, it's the best place to optimistically reload connection state.