Repository navigation
Revert "Fix positionCaseInsensitiveUTF8 giving different results for constant and column arguments" - #122634
Merged
rschu1ze merged 1 commit intoSep 28, 2026
Conversation
…r constant and column arguments"
Contributor
rschu1ze
enabled auto-merge
September 28, 2026 10:36
rschu1ze
deleted the
revert-122113-fix-position-case-insensitive-utf8-constant
branch
September 28, 2026 11:34
This was referenced Sep 28, 2026
shankar-iyer
pushed a commit
to shankar-iyer/ClickHouse
that referenced
this pull request
Oct 21, 2026
…, tail length and row layout Re-submission of ClickHouse#122113, which was reverted in ClickHouse#122634, addressing the review comments and the follow-up issues ClickHouse#122594 and ClickHouse#122595. `positionCaseInsensitiveUTF8`, `countSubstringsCaseInsensitiveUTF8` and `ILIKE` gave different results depending on which arguments were constant, on how many bytes followed a match, and on the neighbouring rows of a block. - A case-insensitive UTF-8 match can cover a different number of haystack bytes than the needle has (`ẞ` and `ß`, `Ⱥ` and `ⱥ`). The row boundary checks in `PositionImpl`, `CountSubstringsImpl` and `MatchImpl` compared `needle.size()` with the end of the row, so a match could continue into the next row, or be rejected although it fits. `countSubstrings*` also advanced by `needle.size()` after a match. Add `matchEnd` to the searchers, which returns the end of the haystack part that a match covers, and use it at these places. The exact length searchers keep a plain pointer comparison. - The SIMD pre-checks accepted only the lower and upper case encodings of the needle, while the scalar comparison accepted every code point with the same `Poco::Unicode::toLower`, so a match could depend on the number of bytes after it. Make both use one rule, `utf8CaseFold`: `Poco::Unicode::toLower`, except that KELVIN SIGN, ANGSTROM SIGN, OHM SIGN and GREEK CAPITAL LETTER THETA SYMBOL match only themselves. Matching them to `k`, `å`, `ω` and `θ` is not possible without losing the SIMD and `Volnitsky` fast paths for every needle that contains one of these letters, which was measured to be up to 5 times slower. - Fix the first-byte and SIMD filters for the Greek `ι` and `μ`, whose `Poco::Unicode::toUpper` is a different code point, so that `Ι` and `Μ` were never found in a long haystack. - Route the constant haystack and constant needle case through the same searcher, and remove `toLowerIfNeed`. - Skip the decoding for two ASCII bytes in the scalar comparison. `ILIKE` patterns that go through `re2` keep the folding of `re2`. Add the test `05331_position_case_insensitive_utf8_constness`. In `02346_text_index_ilike_utf8_case_folding`, a KELVIN SIGN no longer matches `ILIKE '%zzzk%'`. Closes: ClickHouse#122594 Closes: ClickHouse#122595 Related: ClickHouse#122113 Related: ClickHouse#122634 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
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.
Reverts #122113
It introduced two new bugs
@valerypetrov
Workflow [PR]
Sync PR [sync-upstream/pr/122634]
Version info
26.10.1.904-master(included in26.10and later)