Skip to content

Cherry pick #118766 to 26.6: Do not rewrite end-anchored LIKE chains into multiMatchAny - #119911

Merged
robot-clickhouse-ci-1 merged 7 commits into
backport/26.6/118766from
cherrypick/26.6/118766
Sep 17, 2026
Merged

robot-clickhouse-ci-1 merged 7 commits into
backport/26.6/118766from
cherrypick/26.6/118766

Conversation

@robot-ch-test-poll4

Copy link
Copy Markdown
Contributor

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-pick locally.
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:

  • delete the pr-cherrypick label from the PR
  • delete this branch from the repository

You also need to check the Original pull-request for pr-backports-created label, and delete if it's presented there

The PR source

The PR is created in the CI job

@robot-ch-test-poll4 robot-ch-test-poll4 added pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! do not test disable testing on pull request pr-bugfix Pull request with bugfix, not backported by default labels Sep 14, 2026
@robot-ch-test-poll3

Copy link
Copy Markdown
Contributor

Dear @Ergus, @alexey-milovidov, this cherry-pick PR has not been updated for 3d0h6m15s. 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.

@PedroTadim

Copy link
Copy Markdown
Member

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 conflicts

The fix is written against the ConvertOrLikeChainPass rework from #94517, merged to master on 2026-07-13. That rework is on 26.7 and 26.8 but not on 26.3 or 26.6, and the split matches the cherry-pick outcomes exactly:

branch ConvertOrLikeChainPass.cpp PatternData / PatternInfo optimize_or_like_chain default cherry-pick
26.8 632 lines yes true merged clean
26.7 630 lines yes true merged clean
26.6 175 lines no false conflicts
26.3 175 lines no false conflicts

Every conflict is that gap, not a real divergence in the fix:

  • src/Analyzer/Passes/ConvertOrLikeChainPass.cpp — the fix adds may_have_end_anchor to PatternData and allRegexpsHaveNoEndAnchor to PatternInfo, and wires the latter into the multiMatchAny eligibility test. Neither struct exists here; the old pass has no eligibility checks at all and converts every like / ilike directly into multiMatchAny.
  • src/Analyzer/Passes/ConvertOrLikeChainPass.h and src/Core/Settings.cpp — both conflicts are documentation text describing master-only behaviour (indexHint preservation, the multiSearchAny path, optimize_or_like_chain_min_patterns and optimize_or_like_chain_min_substrings).
  • tests/performance/optimize_or_like_chain_hits.xml — modify/delete; the file does not exist on this branch.
  • tests/queries/0_stateless/05055_optimize_or_like_chain_end_anchor.sql merges without conflict but cannot run: its first statement is SET optimize_or_like_chain_min_patterns = 1, a setting Enable optimize_or_like_chain by default. #94517 introduced. Every query in it would fail with an unknown-setting exception.

Only src/Common/likePatternToRegexp.{h,cpp}, which add the has_end_anchor out-parameter, apply cleanly.

Impact on this branch

The underlying problem is real here too: likePatternToRegexp appends $, the result is handed to multiMatchAny, and Vectorscan's $ also matches before a final newline, so s LIKE 'tenant-a' additionally returns 'tenant-a\n'.

However, #94517 is also what flipped optimize_or_like_chain from false to true. On this branch it is still false, so the rewrite — and therefore the widened filter — only happens for users who enable the setting explicitly.

Suggested resolution

Close 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not test disable testing on pull request pr-bugfix Pull request with bugfix, not backported by default pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants