Repository navigation
Check only the deleted row's validity bit on DELETE - #25
Merged
Merged
Conversation
vec0Update_Delete_ClearValidity() tested `bx >> (chunk_offset % CHAR_BIT)`, which is nonzero whenever a later row's bit in the same byte of the chunk's validity bitmap is set. Deleting a row whose own bit was already clear therefore succeeded instead of failing with "validity bit is not set". Only a damaged _chunks table has such a row. The check now tests the row's bit alone, `(bx >> (chunk_offset % CHAR_BIT)) & 1`. Ported from photostructure/sqlite-vec@f6a3244 by Matthew McEachen. test_vec0_delete_errors sets a chunk's validity byte to x'02', clearing row 1's bit while row 2's stays set, and expects the delete of row 1 to fail. It fails on main and passes here. The full suite passes (143 passed, 4 skipped, 259 snapshots), and make test-unit passes.
This was referenced Oct 24, 2026
Owner
|
Thanks, a clear fix: the old test let any higher bit in the same byte stand in for the row's own, and the new case in |
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.
vec0Update_Delete_ClearValidity()checks a row's validity bit withbx >> (chunk_offset % CHAR_BIT), which is nonzero whenever a later row's bit in the same byte of the chunk's validity bitmap is set. A DELETE of a row whose own bit is already clear therefore succeeds instead of failing with "validity bit is not set". Only a damaged_chunkstable has such a row:The check now tests the row's bit alone,
(bx >> (chunk_offset % CHAR_BIT)) & 1. This is photostructure/sqlite-vec@f6a3244 by Matthew McEachen, ported.test_vec0_delete_errorsgains that case, which fails on main and passes here. The full suite passes (143 passed, 4 skipped, 259 snapshots), also with vec0 built with AddressSanitizer and UBSan, andmake test-unitpasses. It merges cleanly with each of our open PRs here (#9, #10, #11, #12, #13, #14, #17, #18, #19, #20, #21, #22, #23, #24) and with #26, which reads the bitmap through the same handle.The same change is open upstream as asg017#358.