Fix determine_update_operation to correctly detect INSERT with explicit rowid#26
Open
russellromney wants to merge 2 commits intoasg017:mainfrom
Open
Fix determine_update_operation to correctly detect INSERT with explicit rowid#26russellromney wants to merge 2 commits intoasg017:mainfrom
russellromney wants to merge 2 commits intoasg017:mainfrom
Conversation
The existing code checked argv[1] == NULL to detect INSERT operations, but according to SQLite documentation, argv[0] == NULL indicates INSERT. From SQLite xUpdate docs: - DELETE: argc=1, argv[0] is the rowid to delete - INSERT: argc>1, argv[0]=NULL, argv[1] is rowid (NULL for auto-generate) - UPDATE: argc>1, argv[0]≠NULL, argv[0]=argv[1] (same rowid) The bug caused INSERT with explicit rowid to fail (hit todo!()) because: 1. Code checked argv[1] for INSERT detection (should be argv[0]) 2. With explicit rowid, argv[1] is the rowid value, not NULL 3. Falls through to unimplemented UPDATE-with-rowid-change branch This fix: - Checks argv[0] for NULL to detect INSERT (matches docs) - Compares argv[0]/argv[1] values (not pointers) for UPDATE detection - Removes todo!() by treating rowid-change as regular UPDATE Fixes explicit rowid INSERT: INSERT INTO vtab(rowid, col) VALUES (1, 'x')
russellromney
added a commit
to russellromney/sqlite-tantivy
that referenced
this pull request
Jan 18, 2026
SQLite extension providing Tantivy-powered full-text search with FTS5-compatible MATCH syntax. Features: - Full-text search with Tantivy engine - FTS5-compatible CREATE VIRTUAL TABLE and MATCH syntax - Support for TEXT, TAG, INTEGER, FLOAT field types - In-SQLite storage (no external index files) - Phrase search, stemming, and tokenizer options Includes patch for sqlite-loadable-rs to fix INSERT with explicit rowid. See: asg017/sqlite-loadable-rs#26
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.
Summary
Fixes a bug in
determine_update_operationthat caused INSERT operations with explicit rowid to panic.The existing code checked
argv[1] == NULLto detect INSERT operations, but according to SQLite xUpdate documentation,argv[0] == NULLindicates INSERT:The Bug
When inserting with an explicit rowid:
argv[0]=NULL(indicating INSERT) andargv[1]=1(the rowid)argv[1]for NULLargv[1]=1(not NULL), it fell through to the unimplementedtodo!()branchThe Fix
argv[0]for NULL to detect INSERT (matches SQLite docs)argv[0]/argv[1]values (not pointers) for UPDATE detectiontodo!()by treating rowid-change UPDATE as regular UPDATETesting
Tested with sqlite-tantivy, a Tantivy-powered FTS virtual table that uses explicit rowids:
All 31 tests pass (25 unit + 6 integration).