Skip to content

executor: Fix LIKE with non-ASCII patterns on unsigned-char platforms (#11038) - #11047

Open
ti-chi-bot wants to merge 2 commits into
pingcap:release-nextgen-202603from
ti-chi-bot:cherry-pick-11038-to-release-nextgen-202603
Open

executor: Fix LIKE with non-ASCII patterns on unsigned-char platforms (#11038)#11047
ti-chi-bot wants to merge 2 commits into
pingcap:release-nextgen-202603from
ti-chi-bot:cherry-pick-11038-to-release-nextgen-202603

Conversation

@ti-chi-bot

Copy link
Copy Markdown
Member

This is an automated cherry-pick of #11038

What problem does this PR solve?

Issue Number: close #11037

Problem Summary

LIKE pattern matching can produce incorrect results for non-ASCII patterns on platforms where char is unsigned, such as Linux AArch64.

The implementation used char values as sentinel states while scanning UTF-8 characters. Bytes greater than 0x7F were interpreted differently when char is unsigned, causing the matcher to incorrectly handle escaped non-ASCII characters and patterns containing UTF-8 literals.

The initial correctness fix avoided the signedness-dependent behavior, but introduced an extra per-character decoding cost in the hot matching path. This could cause a measurable performance regression for common LIKE workloads on AArch64.

What is changed and how it works

  • Replace signedness-sensitive char sentinel handling in the LIKE matcher with an explicit representation that works consistently regardless of whether the compiler treats char as signed or unsigned.
  • Add regression test coverage for non-ASCII UTF-8 patterns, including escaped wildcard cases, to ensure the matcher produces the same result on x86 and AArch64.
  • Preserve the existing optimized ASCII fast path in the matcher. The revised implementation avoids unnecessary UTF-8 decoding for ordinary ASCII pattern matching while applying the correct handling only when non-ASCII bytes are encountered.

As a result, LIKE matching is correct for non-ASCII patterns on unsigned-char platforms, without giving up the substantial performance benefit of the prior optimized implementation.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

None

Summary by CodeRabbit

  • Bug Fixes

    • Improved case-insensitive pattern matching for ASCII text.
    • Correctly handles escaped wildcard characters and consecutive wildcard symbols.
    • Prevents invalid or non-ASCII bytes from causing incorrect matching results.
    • Preserves expected matching behavior when processing Chinese text and mixed wildcard patterns.
  • Tests

    • Added coverage for Chinese text, escaped percent signs, and repeated wildcard patterns.

@ti-chi-bot ti-chi-bot added release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. type/cherry-pick-for-release-nextgen-202603 labels Aug 14, 2026
@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (3)
  • release-8.5
  • release-7.5
  • release-8.1

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 26a0483f-67ff-4fa3-a359-bf3b67e7a0bf

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ti-chi-bot

ti-chi-bot Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: yongman

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot Bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Aug 14, 2026
@ti-chi-bot

ti-chi-bot Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

[LGTM Timeline notifier]

Timeline:

  • 2026-08-14 15:02:25.21336407 +0000 UTC m=+3404331.249459116: ☑️ agreed by yongman.

@ti-chi-bot

ti-chi-bot Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

@ti-chi-bot: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-unit-next-gen 034e561 link true /test pull-unit-next-gen

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

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

Labels

approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. type/cherry-pick-for-release-nextgen-202603

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants