Skip to content

fix(sql): honor escape parity in LIKE fast paths - #29976

Merged
XuPeng-SH merged 3 commits into
matrixorigin:mainfrom
ck89119:issue-29951-main
Oct 12, 2026
Merged

XuPeng-SH merged 3 commits into
matrixorigin:mainfrom
ck89119:issue-29951-main

Conversation

@ck89119

@ck89119 ck89119 commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #29951

What this PR does / why we need it:

The constant-pattern LIKE/ILIKE fast path treats a trailing % or _ as escaped whenever its preceding byte is a backslash. This misclassifies an escaped backslash followed by a wildcard and can return false where the general matcher and MySQL return true.

  • Count the consecutive backslashes before the trailing wildcard: only an odd-length run escapes it; an even-length run leaves it as a wildcard.
  • Include the start of the pattern so two-byte \% and \_ patterns correctly match literal wildcard characters.
  • Preserve the existing fast paths without adding allocations or per-row work. Explicit ESCAPE and binary LIKE paths are unchanged.
  • Add 17 semantic scenarios across LIKE/ILIKE and constant/nonconstant patterns (68 unit subcases), including odd/even escape runs, prefix/contains/underscore shapes, negative controls, empty strings, and NULL values.
  • Add a standalone, zero-table BVT for direct SQL, ILIKE, NOT LIKE, and repeated prepared execution with explicitly textual parameters. Its expected result is generated and verified with mo-tester; existing LIKE BVT files remain unchanged.

Validation

Local validation used Go 1.27.1 on darwin/arm64 with GOEXPERIMENT=simd and the repository CGo test wrapper.

  • Before the fix: 18 constant-pattern regression subcases failed for the expected wrong-result reason; nonconstant-pattern controls passed.
  • After the fix: all 68 regression subcases and the full pkg/sql/plan/function unit suite passed with -count=1.
  • Changed production statement coverage: 100% (6/6).
  • Go-version-matched gofmt and vet passed; incremental golangci-lint v2.14.0 reported 0 issues.
  • Native libraries and mo-service built successfully.
  • Direct LIKE/NOT LIKE and prepared SQL results matched an independent MySQL 8.4.11 oracle.
  • operator/like_escape_parity.sql passed strict result and metadata comparison twice on the same clean standalone instance: 27/27 each time, no skipped statements; test-owned service cleanup completed.
  • Self-review and delivery diff checks passed.

Validation evidence was reused after syncing to 02a2823c20: incoming upstream changes were confined to join/correlated-subquery behavior and truncate tests, did not intersect the function unit-test dependency closure, and are not exercised by this scalar-only BVT. No full-repository SCA, multi-CN, or CI-green claim is made.

QA handoff

User-visible MySQL compatibility fix. Verify escaped backslashes before trailing %/_, literal wildcard controls, and repeated prepared text parameters on the deployed build. Automated coverage includes the unit regression and standalone BVT above.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@XuPeng-SH

XuPeng-SH commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: c3c435873505c957a3e4adc6938fb3b27ffbf190

Assessment: approve

Reviewed the complete four-file delta and its callers. The fix correctly handles odd/even escape runs and two-byte patterns within the existing LIKE/ILIKE fast paths. It adds no allocations or per-row classification. Tests cover meaningful boundaries and public SQL behavior. No actionable defects introduced by this PR remain.

Model: gpt-6-astra / xhigh

Session: 01a12d8f-7dea-77c2-a565-38d45b5564e4 · slot 0 · generation 0

Validation:

  • Traced SQL binding, LIKE/ILIKE dispatch, escape removal, general matching, UTF-8 handling, NULL propagation, and unchanged explicit-ESCAPE/binary routing.

  • Reviewed all 68 unit subcases, fixture cleanup, and the standalone BVT’s direct, negated, and repeated prepared-query assertions.

  • Reused frozen exact-head successful UT, SCA, coverage, PROXY BVT, and PESSIMISTIC BVT evidence, supplemented by the author’s reported MySQL comparison and repeated strict BVT passes.

  • Independent standalone probe compared extracted base/head fast paths against a rune-based oracle: 704,800 comparisons, 1,230 corrected results, and zero new mismatches.

  • Exact HEAD, clean checkout, diff whitespace, and Go formatting checks passed. Audit and probe artifacts are retained in the attempt directory.

Limitations:

  • The probe uses stubbed vector adapters, not production SQL execution. No local native tests or throughput benchmarks were run.

  • The probe also reproduced preexisting multi-segment ILIKE case-folding mismatches, such as value 'A' with pattern '%a%%', at both base and head; these are outside this delta.

  • Frozen evidence supplies suite-level CI conclusions and the PR’s issue description, without individual CI logs or a separate issue [Bug]: LIKE ignores an escaped backslash immediately before a trailing % wildcard #29951 snapshot.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mo-bot review · mo-bot-local · review

Commit: c3c435873505c957a3e4adc6938fb3b27ffbf190

Assessment: approve

Reviewed the complete four-file delta and its callers. The fix correctly handles odd/even escape runs and two-byte patterns within the existing LIKE/ILIKE fast paths. It adds no allocations or per-row classification. Tests cover meaningful boundaries and public SQL behavior. No actionable defects introduced by this PR remain.

Model: gpt-6-astra / xhigh

Session: 01a12d8f-7dea-77c2-a565-38d45b5564e4 · slot 0 · generation 0

Validation:

  • Traced SQL binding, LIKE/ILIKE dispatch, escape removal, general matching, UTF-8 handling, NULL propagation, and unchanged explicit-ESCAPE/binary routing.

  • Reviewed all 68 unit subcases, fixture cleanup, and the standalone BVT’s direct, negated, and repeated prepared-query assertions.

  • Reused frozen exact-head successful UT, SCA, coverage, PROXY BVT, and PESSIMISTIC BVT evidence, supplemented by the author’s reported MySQL comparison and repeated strict BVT passes.

  • Independent standalone probe compared extracted base/head fast paths against a rune-based oracle: 704,800 comparisons, 1,230 corrected results, and zero new mismatches.

  • Exact HEAD, clean checkout, diff whitespace, and Go formatting checks passed. Audit and probe artifacts are retained in the attempt directory.

Limitations:

  • The probe uses stubbed vector adapters, not production SQL execution. No local native tests or throughput benchmarks were run.

  • The probe also reproduced preexisting multi-segment ILIKE case-folding mismatches, such as value 'A' with pattern '%a%%', at both base and head; these are outside this delta.

  • Frozen evidence supplies suite-level CI conclusions and the PR’s issue description, without individual CI logs or a separate issue #29951 snapshot.

@mergify mergify Bot added the queued label Oct 12, 2026
@mergify

mergify Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-12 08:56 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-10-12 09:16 UTC · at 78340f6da145861b2a3e36ab0c31925fd37718f0

This pull request spent 19 minutes 32 seconds in the queue, with no time running CI.

Reason

Pull request #29976 has been dequeued

Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.

The author needs to enable "Allow edits from maintainers" on this pull request.

Hint

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.
If you do update this pull request, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Waiting for any of
  • check-neutral = CI Required
  • check-skipped = CI Required
  • check-success = CI Required
All conditions

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request

This branch was previously deployed

1 inactive deployment
ci — 78340f6d Deployed Oct 12, 2026 by mergify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants