Repository navigation
Cherry pick #118766 to 26.3: Do not rewrite end-anchored LIKE chains into multiMatchAny - #119910
Conversation
Do not rewrite end-anchored LIKE chains into `multiMatchAny`
|
Dear @Ergus, @alexey-milovidov, this cherry-pick PR has not been updated for 3d0h6m53s. Please resolve the conflicts to backport #118766, or close this PR if the backport is no longer needed. This PR will be automatically closed after 7 days of inactivity. |
|
This cherry-pick cannot be resolved as-is: it is a follow-up fix to a rework that this branch does not have. Why it conflictsThe fix is written against the
Every conflict is that gap, not a real divergence in the fix:
Only Impact on this branchThe underlying problem is real here too: However, #94517 is also what flipped Suggested resolutionClose this PR. Landing the fix here means hand-writing a different change against the old 175-line pass, dropping the performance test, and rewriting the stateless test without the setting it depends on — a new backport rather than a cherry-pick, for a path that is off by default on this branch. Backporting #94517 itself is not a reasonable alternative: it is a 175→630-line rewrite of the pass plus three new settings and a default flip, on a stable release branch. If the fix is wanted here regardless, it should be raised as a separate, branch-specific PR. 🤖 Generated with Claude Code |
…into `multiMatchAny`
Resolve the conflicts of the automated cherry-pick. The 26.3 branch carries the
original, much simpler `ConvertOrLikeChainPass` (no `multiSearchAny` path, no
`PatternData`, no per-chain thresholds, and `optimize_or_like_chain` defaults to
`false`), so the master version of the pass, of the `optimize_or_like_chain`
description and the `tests/performance/optimize_or_like_chain_hits.xml` change
do not apply. The fix is adapted to the 26.3 pass instead.
Conflict resolutions:
* `src/Common/likePatternToRegexp.{h,cpp}` merged cleanly and is taken as is:
`likePatternToRegexp` now reports through an optional `has_end_anchor`
out-parameter whether it emitted a trailing `$`.
* `src/Analyzer/Passes/ConvertOrLikeChainPass.cpp` keeps the 26.3 pass and adds
the end-anchor check to it: a `{i}like` branch whose regexp ends with `$` is
left as the original branch instead of being folded into `multiMatchAny`.
`multiMatchAny` runs the regexp through Vectorscan, where `$` also matches
before a final newline, while `like`/`ilike` use RE2, where `$` is the
absolute end - so the rewrite widened the filter and `LIKE 'a'` also matched
`'a\n'`. In the 26.3 pass the grouping is per branch rather than per chain, so
only the anchored branches are kept and the rest of the chain is still
rewritten; the results are the same either way.
* `src/Analyzer/Passes/ConvertOrLikeChainPass.h` and `src/Core/Settings.cpp`
keep their 26.3 text plus a note that end-anchored patterns are never
rewritten.
* `tests/performance/optimize_or_like_chain_hits.xml` does not exist on 26.3;
the deletion is kept.
* `tests/queries/0_stateless/05055_optimize_or_like_chain_end_anchor.sql` drops
the `optimize_or_like_chain_min_patterns` setting, which 26.3 does not have,
and the comment about whole-group rejection is adjusted to the per-branch
behaviour. The expected results are unchanged.
Original pull-request: #118766
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
🕵 Conflicts resolved; the PR is @PedroTadim's analysis above is accurate: this is a follow-up to the How each conflict was resolved:
The net diff against One thing worth a separate decision, deliberately left out of this cherry-pick: 26.3 still carries the old-analyzer twin of this optimization in 🤖 Generated with Claude Code |
Original pull-request #118766
Do not merge this PR manually
This pull-request is a first step of an automated backporting.
It contains changes similar to calling
git cherry-picklocally.If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.
The check results does not matter at this step - you can safely ignore them.
Before you resolve anything
Conflicts are often caused by a prerequisite change that has not been backported yet, rather than by a real divergence. The bot re-tries this cherry-pick against the release branch on every run, so if that is the case here it will merge itself as soon as the prerequisite lands, and you will see a comment saying so. Manual resolution is only needed while the conflict persists.
Troubleshooting
If the conflicts were resolved in a wrong way
If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:
pr-cherrypicklabel from the PRYou also need to check the Original pull-request for
pr-backports-createdlabel, and delete if it's presented thereThe PR source
The PR is created in the CI job