fix(merge_insert): keep nested-field index correct on stable row id update#7410
Merged
jackye1995 merged 2 commits intoJun 23, 2026
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
jackye1995
added a commit
that referenced
this pull request
Jun 23, 2026
…olumn (#7412) The update API rejects nested column references (`set` errors on a `.` in the column name), so a nested field can only be changed by setting its whole **top-level struct column** (e.g. `SET s = named_struct('x', …)`). `commit_impl` built `fields_for_preserving_frag_bitmap` from the struct column's own (parent) field id via `field_id(column_name)`, so an index on a nested **child** field (a different leaf id) was absent from the set. `register_pure_rewrite_rows_update_frags_in_indices` then wrongly extended that child-field index over the rewritten fragment, which was therefore treated as indexed and never re-scanned — so the updated rows were silently dropped from queries on the index (false negatives). The fix collects the full field subtree of each updated column, so a struct-column update marks all descendant field ids as modified. Flat columns are unaffected (no children). This is the SQL `UPDATE` counterpart of the merge_insert fix in #7410. Adds a regression test (`test_update_struct_column_keeps_nested_index`): a BTree index on `s.x`, an update of the struct column `s`, and an assertion that the index's effective fragment bitmap is not extended over the rewritten fragment so the updated value is still found.
…pdate With stable row ids, a full-row merge_insert moves updated rows to a new fragment while preserving their row ids. The RewriteRows index maintenance then extends a scalar index's fragment bitmap to the new fragment unless the index covers a modified field. merge_insert built that modified-field set from the top-level `schema().fields`, so a nested-field index's leaf id was absent and the index was wrongly extended over the rewritten fragment. The fragment was then treated as indexed and never re-scanned, so updated rows were silently dropped from queries on that index. Build the set with `fields_pre_order()` so nested leaf field ids are included.
…pdate A merge_insert full-row update treats the whole schema as modified, so every column index drops the rewritten fragment from coverage -- including indexes on columns that were not changed. Add a multi-index test documenting this, with a TODO for a potential stable-row-id optimization that would preserve coverage for indexes on unchanged columns.
jackye1995
force-pushed
the
jack/nested-index-update-corruption
branch
from
June 23, 2026 17:03
839d945 to
4876cf5
Compare
westonpace
approved these changes
Jun 23, 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.
With stable row ids, a full-row
merge_insertmoves updated rows to a new fragment while preserving their row ids. The RewriteRows index maintenance (register_pure_rewrite_rows_update_frags_in_indices) then extends a scalar index's fragment bitmap to the new fragment unless the index covers a modified field.merge_insertbuilt that modified-field set from the top-levelschema().fields, so a nested-field index's leaf id was absent. The index was therefore wrongly extended over the rewritten fragment, which was then treated as indexed and never re-scanned — so updated rows were silently dropped from queries on that index (false negatives).The fix builds the set with
fields_pre_order()so nested leaf field ids are included. Flat schemas are unaffected (fields_pre_order()equals the top-level list when there are no children).Adds two regression tests in
dataset_merge_update.rs: a flat-index control and a nested-field guard that asserts the rewritten fragment is still data-scanned (via thefragments_scannedmetric) so the updated value is found.