Skip to content

fix(sql): honor DESC column filters and ordinary table partitions - #32197

Merged
XuPeng-SH merged 6 commits into
matrixorigin:mainfrom
aptend:fix/astra-meow-30890-31927
Nov 5, 2026
Merged

XuPeng-SH merged 6 commits into
matrixorigin:mainfrom
aptend:fix/astra-meow-30890-31927

Conversation

@aptend

@aptend aptend commented Nov 4, 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:

Fixes #30890
Fixes #31927

What this PR does / why we need it:

Honor the column argument in DESC, DESCRIBE and EXPLAIN table statements through the existing SHOW COLUMNS LIKE binder. Exact names use the current stored spelling; wildcard and missing-name arguments keep the existing LIKE semantics. Regenerate derived predicates for each build and restore the saved AST afterward, so prepared replanning observes case-only metadata changes. For user and subscribed views, the same live, publisher-bound description supplies both the rows and the exact-name spelling, including stale physical-column snapshots.

Include ordinary base tables in information_schema.PARTITIONS with one row whose partition fields are NULL. Preserve one row per physical partition and use the correct base or partition table for statistics. Retain tenant/object visibility and exclusions for internal index tables, partition sub-tables, views, sequences and temporary tables.

Reconcile persisted PARTITIONS definitions on the existing startup and bounded tenant-maintenance paths alongside VIEWS, including already-current-version tenants. Skip ErrNoSuchTable or ErrBadDB only after the same transaction confirms that the account no longer exists; propagate surviving-account and existence-probe failures so the page rolls back and retains its cursor. Update the CN admission fixture for TABLES, PARTITIONS and the four trace views, preserving the startup-failure/closed-ingress assertion.

A narrow sequence-retry follow-up keeps the exactly-once terminal verdict consistent on every later allocation entry: a stamped terminal identity now surfaces that stamped identity with its recorded residue for any caller, instead of temporarily formatting the current caller's names; caller cancellation still wins, and unstamped or non-tier-2 routes keep their unchanged behavior. The conjunctive compile regressions now rely on the current main synctest bubble harness for scheduling determinism; no additional test patch is claimed for them.

Validation:

  • Independently reviewed the complete final 17-file change and the real planner, view-description, request/result lifetime, bootstrap, transactional maintenance, sequence-retry terminal and failure consumers. The final review fixes add no service or persisted format.
  • The current CGO-enabled planner regression uses the real bound expression executor, preserving the predicate's function, overload and literal while remapping its input column. The verified preimage fails (original rc 1); restored final code passes the focused selection and the nearby Desc|ShowColumns family (original rc 0). A matching named test executable passes 3 roots and 11 subtests: 14 RUN, 14 PASS, 0 FAIL. It covers saved-AST first/reused/fresh plans, stale view map hits/misses, authored LIKE/wildcard/unknown controls, publisher account 17, description failure, post-description binding failure, exact child cleanup and caller restoration.
  • The stamped-identity follow-up is covered by a focused unit test that first stamps the verdict through the real probe-first expiry decision and then enters a different identity: the pre-fix code fails (original rc 1, the surface names the current caller); the fixed code passes with the stamped identity and its recorded residue, caller cancellation winning, and unstamped/ineligible routes unchanged. The surrounding function family passes 38 RUN entries with 0 FAIL (23 top-level tests and 15 subtests) on the unchanged function/native closure.
  • The two conjunctive sequence-retry compile regressions pass the exact two-case selection on the final tree (original rc 0, 2 RUN, 2 PASS, 0 FAIL) with the upstream synctest harness; locally they need no stress or repetition.
  • Local SCA on the final source passes through the repository's exported dependency/test-graph selector. Its computed affected closure reaches the full-scan threshold (335/508 packages), selecting ./...; make static-check-selected STATIC_CHECK_PACKAGES='./...' passes with original rc 0 and 0 final issues. Repository-pinned molint/golangci configuration, err-check and license header/dependency checks pass. This is the selector's explicit fallback, with retained input inventory, commands and raw results.
  • Retain source-matched earlier CN admission and bootstrap error-path regressions, and the earlier normal mo-tester controls (46/46 statements on their recorded CGO/SIMD service binary and source identity), for the unchanged portions. Their nonzero selections and original exits are recorded separately from the new planner/executor and sequence-retry evidence; no new service-level execution is claimed for the new regressions.

CI and reviewer decisions remain pending for the updated publication HEAD.

@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 →

@mergify mergify Bot added kind/bug Something isn't working kind/test-ci labels Nov 4, 2026
@matrix-meow matrix-meow added the size/L Denotes a PR that changes [500,999] lines label Nov 4, 2026
@aptend
aptend force-pushed the fix/astra-meow-30890-31927 branch from c0580a7 to 33d62ee Compare November 5, 2026 00:05
@XuPeng-SH

XuPeng-SH commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: 33d62eeb79e6a519253d6e384153378067b9041a

Review completed. Read the assessment.

@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: 33d62eeb79e6a519253d6e384153378067b9041a

Assessment: request_changes

Two reproducible DESC filtering defects remain. The PARTITIONS changes coherently reuse existing visibility and transactional maintenance.

Model: gpt-6.1-sol / max

Session: 01a1a004-90c3-73b1-acc9-3d4636452003 · slot 0 · generation 0

  • P2 pkg/sql/plan/build_show.go:692: A prepared DESC replans after the target column's stored spelling changes only in case.
    Impact: The retained LIKE pattern rejects the matching column, while a fresh DESC plan matches it.
    Evidence: The first build assigns stmt.Like; subsequent builds skip regeneration. frontend/computation_wrapper.go:941 and mysql_cmd_executor.go:3305 reuse the saved AST. TestReviewDescReplanUsesCurrentOriginSpelling in plan-probe-v2.log records current n_NAME, reused pattern N_Name matching false, and fresh pattern n_NAME matching true. Keep the derived predicate local or regenerate it on every build.

  • P2 pkg/sql/plan/build_show.go:694: DESC current_v LIVENAME when the live view output contains livename but its physical column snapshot is stale.
    Impact: Case folding misses the logical column, and the uppercase LIKE pattern removes an existing result row.
    Evidence: The map comes from tableDef.Cols before viewDescriptionRelation supplies authoritative logical columns at line 807. Existing view-metadata tests explicitly support stale physical snapshots. The corrected planner/LIKE probe fails stale-physical/LIVENAME while current-physical and lowercase controls pass. Derive exact-name spelling from the same live description used to produce the rows.

Validation:

  • Reviewed the complete 13-file delta, linked issues and both discussion entries; source remained unchanged.

  • Preflight and repository-owned native build passed. Corrected isolated planner probes reproduced both failures; three selected repository tests and nearby controls passed.

  • Reconciled nine check receipts with source fingerprints, commands, exits and retained logs in validation-ledger.json.

  • Reused supplied head-matched successful build, UT, SCA and complementary BVT CI results; checked both new 23-statement case/result pairs.

Limitations:

  • Probes used the real planner and LIKE evaluator with repository fixtures. No fresh service-level or predecessor-migration run was performed; raw CI and historical author-run logs were not supplied.

@aunjgr aunjgr 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.

Reviewed the complete 13-file diff, the SHOW COLUMNS binder, PARTITIONS visibility/statistics expression and startup/periodic reconciliation consumers. DESC uses a typed LIKE literal rather than SQL interpolation. Ordinary tables receive the NULL-partition row while partition, internal-index, view, sequence and temporary-table identities remain filtered appropriately.

The maintenance cursor publishes only after the page transaction succeeds; PARTITIONS typed errors for a surviving account propagate rather than silently losing repair work, and probe results are closed. Existing VIEWS behavior is preserved. The startup admission fixture accounts for the additional reconciliation in both success and failure branches.

No blocking findings. Reused latest-head successful CI and the source-bound planner/bootstrap/admission and SQL evidence described in the PR. No new local service, race or predecessor-upgrade run was performed.

@XuPeng-SH

XuPeng-SH commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: d88831456496eadc197425a2fd5d538505482bc2

Review completed. Read the assessment.

@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: d88831456496eadc197425a2fd5d538505482bc2

Assessment: approve

Approve. Both prior DESC findings are resolved through per-build AST restoration and one authoritative live view description for rows and filter spelling. PARTITIONS preserves visibility and statistics identities while reusing transactional startup and tenant reconciliation. The sequence follow-up consistently surfaces the stamped terminal identity. These fixes reuse existing owners without new durable state.

Model: gpt-6.1-sol / max

Session: 01a1a004-9884-72c0-ad39-f096c4209c4a · slot 1 · generation 0

Validation:

  • Reviewed the complete 17-file delta, real binder/view-description, bootstrap/upgrade, CN admission and sequence-terminal consumers, plus linked issues #30890/#31927. discussion-assessment.json covers all six keys and reconciles the earlier conflicting verdicts against current source.

  • Frozen-head CI completed successfully for the shared build, Ubuntu/x86 UT, arm64 SCA, coverage, proxy compose BVT and pessimistic compose BVT. Skipped and neutral jobs were not treated as passes.

  • Reused attributed author reports of the real-expression-executor planner preimage/final regressions (14 RUN/PASS), stamped-identity and surrounding function family (38 RUN entries), and two conjunctive compiler regression roots. Earlier admission/bootstrap and 46-statement service evidence is limited to its reported unchanged scope.

  • Local bounded source/metadata audit passed with clean frozen source (checks/1793887459072129367-2.json; review-audit.py/json/log). All 13 changed Go files parse/format; both 23-statement fixture streams and 25 expected rowsets were independently checked. The PARTITIONS SQL witness distinguishes baseline partition-only rows from candidate ordinary-plus-partition rows and verifies statistic targets under modeled visibility/temporary boundaries.

  • Raw diff whitespace checking reported only 13 rendered empty-cell trailing-space lines in the DESC result fixture (checks/1793887431582475247-2.json, exit 2; diff-check.log). The initial audit stop is retained separately; non-result source whitespace passes.

Limitations:

  • No fresh local Go/native, MatrixOne service or predecessor-migration execution was performed. CI statuses and detailed author reports were reused; raw per-test CI/author logs are absent from local_validation, which is empty.

  • The independent SQLite/LIKE checks validate query shape and fixture values, not MatrixOne binding, privilege enforcement, legacy temporary-object recognition or runtime upgrade behavior. Earlier 46-statement service evidence does not claim execution of the new planner/sequence regressions.

@mergify mergify Bot added the queued label Nov 5, 2026
@mergify

mergify Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

🚫 Left the queue · pull request dequeued

1 h 44 min in the queue, with no time running CI.

So far

  • ✅ Entered the queue Thu 5 Nov, 14:11 · rule main · triggered by rule Automatic queue on approval for main
  • ⏹️ Testing stopped · in place
  • 🚫 Left the queue 15:54 · a5193f5

Reason

Pull request #32197 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.

To get back in the queue

  • Push a change if one is needed: the pull request is queued again once its queue conditions match.
  • If no change is needed, tick the box below to queue it again as it is.

Merge conditions not met when it left the queue

  • any of · required by GitHub branch protection:
    • check-neutral = CI Required
    • check-skipped = CI Required
    • check-success = CI Required

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

  • Requeue this pull request
2 merge conditions met
  • #review-threads-unresolved = 0 · required by GitHub branch protection
  • github-review-approved · required by GitHub branch protection

Times in UTC · dashboard · how the merge queue works

@XuPeng-SH
XuPeng-SH merged commit 547d2cb into matrixorigin:main Nov 5, 2026
@mergify mergify Bot added dequeued and removed queued labels Nov 5, 2026
XuPeng-SH pushed a commit that referenced this pull request Nov 9, 2026
…32357)

## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Related to #31175
Related to #31179

## What this PR does / why we need it:


**Design.**
`docs/design/20261108-pattern-matching-effective-collation.md` (revision
r5, SHA256
`c37413e83c10d49cd71153d22b2066733d3ecc1f2a543b14b50b830c9ecbba42`,
revised in `b9d08296ef` after the rebase onto `c99234dcf4`) records the
problem evidence, invariants, MySQL/ICU/UCA precedent and alternatives,
ownership and data flow, resource budgets and boundaries,
compatibility/rollout, and the validation map for the complete change.
r5 corrects r4's validation-map fold-fully expectation with engine
bounds measured during the post-approval implementation: exact fold
emission grows quadratically with run length, and the regexp2 route's
binding engine bound for long fold runs is its compiled
backtracking-state limit (4,096 tracks — a 40-rune fold run compiles at
1,439 tracks and is admitted; an 80-rune run compiles past the bound),
so the round-14 four-alternative comment-bearing shape raises the
bounded resource-limit error under `i` even after deduplication, and
fold-fully proofs relocate to below-bound regexp2 shapes and to the RE2
route at the original scale. No invariant, ownership decision, budget
value, or error family changes; r4's independent design-only PASS
(SHA256
`c31aef6c201f712c72aca88c59149d6805f1b99fddad9d2a0cde724021edc098`)
remains the base. r4 had resolved the r3 finding (equal effective
inline-option state before deduplication; an intervening unscoped setter
makes a duplicate ineligible, so `^(?:ss|(?i)a|ss)$` keeps both `ss`
branches) and carried forward the r3 resolutions of the two r2 findings
(capture/backreference/option-aware dedup eligibility; the
resource-limit error contract with planned public-path BVT proof).
Design r5 passed the independent design-first review, and the production
deltas are implemented in head `bd80b57137` on top of the r5 design
commit. Revision r6 (2026-11-09) records the resolution of the
implementation review's P1 on the r5 head: the alternative-deduplication
prepass is linear and carries its own charged work bound (4 MiB) —
construct marks land on the innermost branch in O(1) with close-time
flag folding into the enclosing branch, and each alternation closure
tracks its most recent unscoped-setter branch incrementally — so many
identical siblings and deeply nested groups cannot perform quadratic
work before the rewrite budgets are initialized; abandoning the prepass
returns the source pattern unchanged, deferring to the approved
expansion budgets with no new SQL-visible outcome. It extends
`docs/design/regexp-icu-compatibility.md` (issue #28305), whose
admission/cache/budget layer this change threads case folding through.

**Problem.** `LIKE`, `ILIKE`, `REGEXP`/`REGEXP_LIKE` and `FIND_IN_SET`
ignored the effective collation and compared byte-wise. Under the
default `utf8mb4_general_ci` (and under an explicit `utf8mb4_unicode_ci`
column) `'a' LIKE 'A'` returned 0 and `WHERE name LIKE 'alice%'` missed
`'Alice'`, while MySQL returns 1 for both — and while `=`/`IN` and
`LOCATE`/`INSTR`/`POSITION` on the same data already honored the
collation. Pattern operators therefore disagreed with their sibling
operators, and `LIKE 'prefix%'` index range scans could return different
rows than folded scans.

**Root causes closed by this PR.**

1. The LIKE executor and FIND_IN_SET ran byte-wise matchers and the
regexp engine ran case-sensitively; none of the pattern operators
consulted the operands' resolved collation (column COLLATE, expression
COLLATE, session default, `_binary` introducer, `CAST(x AS BINARY)`).
2. Collation-correct matching needs more than per-character caseless
flags: `utf8mb4_general_ci` folds by MySQL's weight table,
`utf8mb4_unicode_ci` compares UCA 4.0.0 primary weights per character,
and ci REGEXP needs Unicode full case folding (`ß`↔`ss`) that
per-character orbits cannot express.
3. The planner rewrote `col LIKE 'prefix%'` into byte-ordered
`prefix_eq`/`=` filters, which return different rows than
collation-folded LIKE.
4. Constant folding truncated planner-built binary→text conversions
whose target width is `-1` (every non-empty constant folded to `''`) and
re-marked folded `CAST(x AS BINARY)` literals as binary-introducer
domains, losing a winning case-insensitive collation.
5. Aggregating the matchers into collation resolution exposed implicit
ci-column vs `CAST(x AS BINARY)` ties (equal coercibility 2) to the
resolver's version check, raising error 1267 where base behavior and
MySQL compare byte-wise; `find_in_set`'s overload registration also cast
binary operands to utf8 `varchar`, erasing the binary string domain for
non-constant operands.
6. Constant `CAST(x AS BINARY)`, `BINARY 'x'` and `binary(x)` presented
a coercible literal's coercibility (4) instead of MySQL's IMPLICIT
coercibility (2) for cast results: folding replaces the cast with a
literal that keeps only its type, and the `binary()` function fell
through to the default rank. A case-insensitive column then strictly
outranked the binary operand and the planner converted it to
case-insensitive text, flipping `vc LIKE BINARY 'a%'` / `vc LIKE
CAST('a%' AS BINARY)` / `BINARY vc LIKE 'a%'` to case-insensitive
(surfaced by `operator/mysql_compat_string_binary_comparison`).

**What changes.**

- `pkg/common/collation/wildcard.go` (new): collation-aware LIKE matcher
— general_ci weight folding, UCA per-character weights, `_`/`%`/ESCAPE
handling, bounded multi-`%` segment matching with cancellation.
- `pkg/sql/plan/function/func_builtin_regexp.go`,
`regexp_casefold.go`/`regexp_casefold_tables.go` (new), `regexp_icu.go`:
LIKE/ILIKE/REGEXP/REGEXP_LIKE resolve the operands' collation (including
the ESCAPE argument; `REGEXP_LIKE` resolves from subject and pattern);
ci collations route LIKE through the weighted matcher and REGEXP through
an exact, bounded full-fold pattern rewrite (byte-identical below its
budgets; per-character caseless orbit above them); the binary/ci mix
keeps MySQL's error 3995 in both operand orders, and malformed-pattern
verdicts are always taken from the source pattern as written.
- `pkg/sql/plan/function/func_binary.go`: FIND_IN_SET honors the
resolved collation (weighted whole-key membership, unpadded comparison;
trailing spaces stay significant).
- `pkg/sql/plan/collation_expression.go`: expression-level collation
resolution covers the pattern matchers; a scoped pairwise tie rule
(`patternBinaryCollationAdmission` + `pairwiseBinaryTieWinner`) restores
the base behavior for implicit ci-column vs binary-CAST predicates only
— the binary operand wins the equal-implicit-rank tie,
LIKE/ILIKE/FIND_IN_SET compare byte-wise, REGEXP keeps 3995, and
text-text conflicts still raise 1267. Binary-domain cast results are
stamped with MySQL's IMPLICIT coercibility (2) so the tie rule, not a
rank-4 literal default, decides them.
- `pkg/sql/plan/base_binder.go`: `CAST(x AS BINARY)`/`BINARY 'x'` carry
IMPLICIT coercibility from creation; the stamp rides the expression
type, so constant folding (which preserves the type wholesale) cannot
drop it.
- `pkg/sql/plan/opt_misc.go`: for case-insensitive columns the planner
keeps the LIKE predicate instead of rewriting it to byte-ordered
`prefix_eq`/`=` filters, so scan and index paths return the same rows.
- `pkg/sql/plan/function/func_cast.go`,
`pkg/sql/plan/rule/constant_fold.go`: negative-width conversion targets
no longer truncate folded constants, and a folded binary-CAST literal
keeps the selected text domain when an explicit ci collation won the
resolution.
- `pkg/sql/plan/function/list_builtIn.go`: `find_in_set` uses the
domain-preserving overload registration.

**Issue-to-test proof.** Every reproduction row from #31175 and the
preserved #31179 report is pinned: `'a' LIKE 'A'`/`'ABC' LIKE
'abc'`/`'abc' REGEXP 'ABC'`/`'abc' REGEXP '[A-Z]+'` now return 1; the
`ci1`/`uci2` table rows match folded `LIKE 'alice%'` and `REGEXP
'^alice'`; `FIND_IN_SET('A','a,b')` = 1; explicit `utf8mb4_unicode_ci`
column and literal COLLATE cases agree across `=`/IN/LIKE/REGEXP;
binary/case-sensitive controls (`_bin` collations, `_binary` domains)
stay byte-wise; `LOCATE`/`INSTR`/`POSITION`/`FIND_IN_SET` neighbors keep
their behavior.

- UT: `pkg/common/collation` (weights, segments, boundaries),
`pkg/sql/plan` (resolution/admission matrix incl. CAST and prepared
shapes, executor routing over real typed batches, fold/cast
preservation, folded-`CAST(x AS BINARY)`/`BINARY 'x'`/`binary()`
coercibility regression test) and `pkg/sql/plan/function` (fold rewrite
tables/orbits, matcher routing, error shapes).
`pkg/sql/plan/build_show_desc_oracle_test.go` fixture spellings now
differ beyond letter case, because the DESCRIBE/SHOW COLUMNS filter LIKE
honors the effective case-insensitive collation (the #32197
replan-refilter assertions are unchanged).
`pkg/tests/sqlintegration/like_prefix_index_test.go` pins its #31940
prefix-plan fixtures to `utf8mb4_bin`, the byte-ordered domain the
prefix rewrite requires, and the new
`TestLikePrefixCaseInsensitiveKeepsFoldedPredicate` proves that under
`utf8mb4_general_ci` the analyzed planner keeps the folding LIKE
predicate (no `prefix_in_range`/`prefix_eq`) while scan, forced-index
and computed-subject paths all return the folded rows
(`'abc'`/`'ABC'`/`'Abc'` for `LIKE 'abc%'`).
- BVT: new
`test/distributed/cases/charset_collation/issue_31175_pattern_collation.sql`
— 416 statements covering literals, columns, explicit COLLATE in both
operand orders, `_binary`/HEX/BIT/CAST domains, prepared `CAST(?)`
parameters, user variables, VARBINARY columns, index-vs-scan plans,
NULL/empty/escape boundaries and error texts; every expected value
probed against a MySQL 8.0.44 oracle. Its resource-boundary rows pin the
r5 contract: the 328-byte four-alternative comment-bearing shape raises
the bounded resource-limit error naming the regexp2 4,096-track
backtracking-state bound under `i` while the `c` control returns 1,
below-bound shapes fold fully on the regexp2 route (six `ß` match twelve
`s`), and the RE2 route folds fully at the original scale (forty `ß`
match eighty `s`). New
`test/distributed/cases/charset_collation/issue_31175_pattern_resource_limits.sql`
(15 statements) pins the bounded error contract at every bound —
per-pattern emission budget exhaustion, RE2 nesting admission, the
4,096-track bound, and below-bound positive/negative fold controls
(`CONCAT(REPEAT('ß',20),'a')` matches the forty-`s`-then-`a` branch = 1;
the unsuffixed subject = 0). Existing expectations updated only where
folding intentionally changes results (`operator/like_operator`,
`optimizer/like` plans, `function/func_regular_like` CRLF-multiline
rows), plus the same intentional case-folding flips surfaced by CI in
`charset_collation/charset_collation_advanced` (`code LIKE 'abc%'`),
`charset_collation/charset_collation_basic` (`name LIKE 'app%'/'APP%'`
on the `general_ci` table; the `utf8mb4_bin` controls are unchanged),
`operator/operator.test` (`username LIKE '%Frau'`),
`operator/regexp_operator` and `operator/not_regexp_operator` (`'Acorn'
[NOT] REGEXP 'Corn'`), and `fulltext2/fulltext2_covered` (`tag LIKE
'Act%'`). `operator/mysql_compat_string_binary_comparison` keeps its
committed expectations: its CI failure was root cause 6, fixed in code.

Local validation: `mo-cgo-test -count=1 ./pkg/sql/plan
./pkg/sql/plan/rule ./pkg/sql/plan/function ./pkg/common/collation` (all
packages pass), `go vet` clean, gofmt clean, `go test -count=1 -run
'TestLikePrefixIndex$|TestLikePrefixCaseInsensitiveKeepsFoldedPredicate$'
./pkg/tests/sqlintegration` (both pass, memory+persisted phases; the
unadapted fixture failed the line-105 plan assertion in CI coverage UT
on this head), and mo-tester `run` of the new BVT passes 410/410 on the
fixed binary while the pre-fix binary fails exactly the new
discriminator statements. At the pre-rebase r5 head `5c628ab92f` (same
diff, now rebased): focused UT batches pass (`pkg/sql/plan/function`
dedup/fold/routing suites incl.
`TestRegexp2CaseFoldIdenticalAlternativesDedup` and
`TestRE2CaseFoldIdenticalAlternativesDedup`; full `pkg/common/collation`
batch incl. the LIKE budget UTs), and mo-tester `genrs` + independent
row review + two normal-comparison `run` passes of
`include=issue_31175_pattern` on one clean instance each pass 431/431
(416 collation + 15 resource-limits). After the root-cause-6 fix,
mo-tester `run` additionally passes
`operator/mysql_compat_string_binary_comparison` (57/57), the six
refreshed files above, `function/func_regular_like`, `optimizer/like`
and `optimizer/like_prefix_range` on the rebuilt binary
(`operator/like_operator` passes 190/190 in CI; one `rpad`+cast INSERT
at row 230 fails only under the local prepared-statement runner, before
and after this change); live probes confirm `vc LIKE BINARY 'a%'` / `vc
LIKE CAST('a%' AS BINARY)` / `BINARY vc LIKE 'a%'` / `vc LIKE BINARY vb`
compare byte-wise while `_binary 'a%'` and plain literals keep folding
case-insensitively.



**Rebase note (2026-11-09).** Rebased onto main `c99234dcf4` to clear
the merge conflict: #32341's `BuildPlan`/`CompilerContext.Resolve`
signature migration overlapped this PR's `n_NAME`→`n_PAME` expectation
update in `pkg/sql/plan/build_show_desc_oracle_test.go` (kept the PR's
case-beyond-letter-case fixture with the new 4-argument call and
`TableResolution` output), and one PR-added `BuildPlan` call in
`pkg/sql/plan/collation_expression_test.go` was migrated to the new
signature. The post-rebase PR diff is byte-identical to the pre-rebase
diff outside those two resolutions. Post-rebase validation on
`bd80b57137`: all five touched Go packages (`pkg/sql/plan`,
`pkg/sql/plan/function`, `pkg/common/collation`, `pkg/sql/plan/rule`,
`pkg/tests/sqlintegration`) compile clean via `mo-cgo-test`; the 26
DESC-oracle/LIKE-prefix/binary-tie tests and the 20 collation-expression
tests (incl. the migrated `TestPatternBinaryColumnCastTieRestored`)
pass; the full `pkg/sql/plan/rule` suite passes.

**Review-resolution note (2026-11-09, head `c8a615913c`).** Resolved the
mo-bot implementation review's P1 on `bd80b57137` (the deduplication
prepass performed quadratic work before the rewrite budgets):
identical-sibling dedup now makes one pass per alternation (65,536
alternatives: 2.19 s -> 4.8 ms in an exact-source probe) and
capture/reference/setter marks fold upward at group close instead of
walking the ancestor stack per construct (32,768 nested captures: 0.94 s
-> 4.7 ms), with eligibility verdicts preserved exactly; a charged 4 MiB
prepass bound abandons dedup byte-identically on exhaustion (the
depth-2000 nested-alternation shape that would hash ~410 MB is capped).
Validation on `c8a615913c`: focused dedup/work-bound/eligibility suites
pass (incl. exact-budget straddle pins and nested flag-propagation
rows), the broad `CaseFold|Dedup|Regexp|RE2` selection passes 135/135
top-level tests (917 runs incl. subtests, 0 failures), gofmt and `go
vet` clean. No BVT result changes: abandonment is unreachable below the
bound (every BVT pattern is orders of magnitude smaller), and dedup
outputs are unchanged for all in-budget patterns.

**Base refresh (2026-11-09, head `07943b3040`).** Rebased onto main
`da867c90df` (6 commits: #32401, #32399, #31419, #32353, #32380, #32251)
under the scheduled ci_base_refresh after run 42566409967's four
failures were verified as the unrelated #27066 tool-download transport
class. Zero file overlap with this PR's diff; no conflict resolutions
needed and the post-rebase PR diff is byte-identical to the pre-rebase
diff. Post-rebase validation on `07943b3040`: `go test -count=1` passes
for all three affected packages — `pkg/common/collation` (17.2s),
`pkg/sql/plan/function` (38.9s), `pkg/sql/plan` (131.1s). No code
change; design r5/r6 record and all review dispositions carry over
unchanged.

**Residual limits** (pinned by tests and documented in the issue): LIKE
stays a per-character weight comparison (no multi-character expansion
spanning; `ß LIKE 'ss'` = 0); three ICU-only regexp corners diverge
(character-class string closure, caseless backreference matching,
quantified-atom image spanning); equality/IN over pure literals under
explicit `utf8mb4_general_ci` keep a pre-existing parity gap that a
follow-up issue owns; `REGEXP_INSTR`/`REGEXP_SUBSTR`/`REGEXP_REPLACE`
keep their default case behavior unless `match_type` requests `i`; PAD
SPACE, sort weights and key uniqueness under ci collations are out of
scope per the issue's acceptance checklist.

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

This branch was successfully deployed

No deployments
ci — a5193f58 Deployed Nov 5, 2026 by mergify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dequeued kind/bug Something isn't working kind/test-ci size/XL Denotes a PR that changes [1000, 1999] lines

Projects

None yet

4 participants