Conversation
… on SQLite
SqliteByteArrayMethodTranslator translated `bytes.Contains(b)` with a parameter
or column argument to `instr(bytes, char(b))`. `char()` returns TEXT containing
the UTF-8 encoding of the code point, which makes `instr` compare as text
rather than as bytes, so every value above 0x7F was wrong in both directions:
`instr(X'DEADBEEF', char(222))` returns 0 (missed match), while
`instr(X'01C38802', char(200))` returns 2 (false match on the UTF-8 bytes of
U+00C8). The constant path already built a proper BLOB literal.
Build the search value as `unhex(printf('%02X', b))` instead, which yields a
one-byte BLOB and makes `instr` compare bytes, and add a test with a byte
above the ASCII range.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.
… on SQLite
SqliteByteArrayMethodTranslator translated
bytes.Contains(b)with a parameter or column argument toinstr(bytes, char(b)).char()returns TEXT containing the UTF-8 encoding of the code point, which makesinstrcompare as text rather than as bytes, so every value above 0x7F was wrong in both directions:instr(X'DEADBEEF', char(222))returns 0 (missed match), whileinstr(X'01C38802', char(200))returns 2 (false match on the UTF-8 bytes of U+00C8). The constant path already built a proper BLOB literal.Build the search value as
unhex(printf('%02X', b))instead, which yields a one-byte BLOB and makesinstrcompare bytes, and add a test with a byte above the ASCII range.