Skip to content

compile/plan: fix identifier escaping in ALTER COPY DROP, lenient integer CAST, MySQL multiline regexp terminators (#30550 #30417 #30210) - #30646

Merged
XuPeng-SH merged 29 commits into
mainfrom
fix-b-compat-30550-30417-30210
Oct 24, 2026
Merged

XuPeng-SH merged 29 commits into
mainfrom
fix-b-compat-30550-30417-30210

Conversation

@aptend

@aptend aptend commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • BUG

Which issue(s) this PR fixes:

Fixes #30550
Fixes #30417
Fixes #30210

What this PR does / why we need it:

  • Reuse identifier quoting for COPY ALTER's internal DROP and index-clone DELETE, including embedded backticks.
  • Return zero with warning 1292 for explicit signed/unsigned CAST of lexically invalid text. Preserve NULL, numeric prefixes, strict implicit conversion, binary conversion and masked rows. Keep COUNT diagnostic regression witnesses meaningful by using lexical DECIMAL errors where integer CAST now succeeds.
  • Implement wide multiline line assertions without splitting subjects or routing ordinary regular patterns to ICU. An unrelated trailing CR no longer turns a successful ^a\s match into a size/budget error, including inputs above 1 MiB. LIKE, INSTR, SUBSTR and REPLACE share the same regular matcher and retain original context, occurrence priorities, captures and binary offsets.

The regular matcher is a private, pinned Go 1.27.1 implementation with its BSD license and source provenance retained. NFA, bit-state and one-pass execution share one immutable line-assertion policy. Parsing/compiler and the existing SQL cache, binary conversion, occurrence iteration and replacement limits remain authoritative. Delete the line splitter, subject scans/fallbacks and generated position wrappers. Look up raw pattern/normalized flags/domain before rewriting or classifying warm cached patterns. Genuine ICU syntax retains its existing bounded engine; raw pattern and generated anchor expansion are bounded before oversized allocation or cache publication.

Wide m without u recognizes CR/LF/CRLF/NEL/LS/PS in text and byte-sized binary terminators. CRLF is atomic; scoped flags and whole-subject anchors retain their meaning. Preserve main's consuming-atom semantics, including ordinary dot's LF exclusion, and its existing EOF-caret behavior after LF. This implements wide line assertions, not full ICU equivalence.

Accepted design and maintenance policy, engine provenance. Go updates require upstream reconciliation and differential/SQL/performance validation. Only the four BSD source files are excluded from Apache header checks; no lint/coverage exclusions were added. Unused upstream experimental private wrappers and ineffective assignments were removed.

Integrated main at f70d19d43a987d53926d53720cb63500e61fb850 with a history-preserving merge because the PR branch prohibits force pushes.

Validation on macOS arm64, Go 1.27.1:

  • Native artifacts verified and mo-service built. Complete owning function and private-engine normal/race suites passed after review corrections. Planner and compile normal/race suites passed after main integration; subsequent changes preserve their interfaces and the independently verified default matcher behavior.
  • Final incremental gofmt, diff, error-code, license, vet, molint and configured golangci-lint checks cover compile, plan, function and the private matcher. The complete repository header-policy check also passed.
  • Default-engine differential tests compare compilation, matches, captures and replacements to the pinned standard library. Dedicated tests select all three executors, cover Unicode/binary terminators, CRLF, zero-width/EOF boundaries, original-context offset search, concurrent reuse, NULL/error precedence and replacement budgets. Six cross-line pattern families above 1 MiB pass all four operations; oversized ICU expansion is rejected before allocation/publication.
  • Normal mo-tester comparison passed COUNT, CAST, REGEXP, CTE, conditional INSERT and branch-set cases; REGEXP passed twice on the same instance. The final rebuilt binary also passed the REGEXP case and 16 public SQL controls, including the exact ICU expansion trigger. Test-owned resources were cleaned up. Earlier unchanged COPY/identifier/IVF clone SQL controls remain valid.
  • Independent gpt-6.1-sol / xhigh design and overall review completed. The review's ICU expansion finding was fixed and re-reviewed with no remaining material code/design blocker.

Three-sample medians of the identical warmed 256-row production-vector fixture:

Pattern ^alpha, mode m Main Previous PR Fixed
Short text 30.41 us 138.96 us 27.23 us
32 KiB text 42.85 us 1,569.07 us 40.59 us
32 KiB binary 2,195.39 us 8,950.70 us 2,163.57 us

The reported prefix regression is removed. Fixed m uses three allocations per 256-row batch, with no per-row allocation. Default/Unix controls measured 1.02–1.13x main; these local microbenchmarks are not a general TP-throughput claim. ICU admission changes run on cache misses only.

Local evidence and exact source/check receipts: /Users/xupeng/.codex/issue-to-pr/matrixone/pr30646-fix-20261024/round2/. Fresh remote CI is pending; local checks do not replace its result.

…30550)

The COPY ALTER path built internal DROP TABLE and DELETE statements with
'`%s`.`%s`' interpolation. A legal identifier containing an embedded
backtick (doubled in SQL) broke out of the quoted name and the internal
statement failed with a syntax error. Route both sites through
sqlquote.QualifiedIdent, which doubles embedded backticks.
…warning (#30417)

MySQL's explicit CAST of a string that cannot start a numeric conversion
to SIGNED/UNSIGNED returns 0 with 'Truncated incorrect INTEGER value'
(ER_TRUNCATED_WRONG_VALUE) even under strict sql_mode. MatrixOne returned
20203 instead. The explicit-mode branch of strToSigned/strToUnsigned now
matches the MySQL contract; strict assignment and binary paths unchanged.
…#30210)

m mode now matches MySQL's full line-terminator set (LF, CRLF, CR, NEL,
U+2028, U+2029) while the u marker preserves Unix-LF semantics. The match
wrapper rewrites unescaped ^/$ outside classes/quotes into zero-width
lookaround forms and routes them to the regexp2 engine; routing sites now
evaluate the flag-wrapped pattern so injected lookarounds are detected.
@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 →

…ults with #30417 CAST zero-warning semantics (#30646 CI follow-up)
@XuPeng-SH

XuPeng-SH commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-xupeng · superseded

Commit: 8aea7e744fb3a4e09199452958084f9e57809bb1

"interrupted"

@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: 8aea7e744fb3a4e09199452958084f9e57809bb1

Assessment: request_changes

Reviewed the complete 17-file delta and latest comments. Identifier quoting and explicit CAST handling appropriately reuse existing owners. The REGEXP line-splitting design does not preserve matching, iteration and replacement contracts. Six confirmed defects remain, including an infinite loop and a roughly 524× performance regression.

Model: gpt-6-astra / xhigh

Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1

  • P1 pkg/sql/plan/function/func_builtin_regexp_linesplit.go:107: Evaluate REGEXP_LIKE on text subject "a\rb\n", pattern "^z$", match_type "m".
    Impact: The query loops indefinitely. The trailing empty line returns termEnd=len(subject), and callers reuse that cursor, receiving the same line forever. Ensure the final empty line is yielded only once.
    Evidence: TestReviewTrailingLFNoMatch timed out after three seconds with the stack inside wideMultilineNextLine/regexpWideLike. The identical merge-base test and ICU control completed with false. See hang-head.jsonl and semantic-base.jsonl.

  • P1 pkg/sql/plan/function/func_builtin_regexp_linesplit.go:71: Match "^alpha" with match_type "m" against LF-only text "alpha\n" followed by 32,768 characters.
    Impact: Routing still scans the entire subject before RE2 can accept the prefix. This retains the previously reported regression and contradicts the claimed restoration of short-circuit performance. Avoid mandatory whole-subject scanning on this path.
    Evidence: Identical production-vector benchmarks over 256 rows, three samples per revision: head median 25.792 ms versus merge-base 49.238 µs, approximately 524× slower. Allocations increased from 259 to 772 per batch. See bench-head.log and bench-base.log.

  • P1 pkg/sql/plan/function/func_builtin_regexp_linesplit.go:75: Evaluate REGEXP_LIKE with pattern "^a.", match_type "m", and a text subject containing 16,384 'a' characters followed by CR.
    Impact: A previously supported, immediate prefix match now fails regexp2 admission. Allowing dot sends the entire subject through regexp2's memory estimate even though the match needs only two characters. Preserve the supported RE2 input domain when selecting the compatibility path.
    Evidence: TestReviewDotAdmission fails with 'regular expression evaluation exceeds the maximum supported memory of 8388608 bytes'. The identical merge-base test and ICU control return true. See semantic-head.jsonl, semantic-base.jsonl and icu-controls.log.

  • P2 pkg/sql/plan/function/func_builtin_regexp_linesplit.go:397: REGEXP_REPLACE on "a\ra" with pattern "^a", replacement "X", position 1, occurrence 2 or 3, and match_type "m".
    Impact: Both calls return "X\rX". They should return "a\rX" and unchanged "a\ra", respectively. When a line contains fewer matches than the remaining occurrence, useOcc stays zero and replaces every match on that line. Emit earlier lines unchanged until the requested occurrence is reached.
    Evidence: TestReviewReplaceOccurrence reproduces both wrong results through builtInRegexpReplace; independent ICU match enumeration confirms the expected outputs. See semantic-head.jsonl and icu-controls.log.

  • P2 pkg/sql/plan/function/func_builtin_regexp_linesplit.go:192: Match text "a\rb" with match_type "m" using "^a\z", "\Ab$", or "(?-m:^b)|^z".
    Impact: All three incorrectly return true. Excluding consuming line-terminator nodes does not make a pattern line-local: whole-subject anchors and disabled multiline scopes acquire new boundaries when evaluated against isolated lines. Preserve their original context or exclude these patterns from per-line evaluation.
    Evidence: All three TestReviewWholeSubjectAnchors subtests fail through builtInRegexpLike at HEAD and pass at the merge base. ICU returns false for each. See semantic-head.jsonl, semantic-base.jsonl and icu-controls.log.

  • P2 pkg/sql/plan/function/func_builtin_regexp_linesplit.go:251: REGEXP_INSTR on text "\ra", pattern "^", position 1, occurrence 1, return option 0, and match_type "m".
    Impact: The result is 2 instead of 1 because lineEnd > startByte skips the initial empty line and its valid zero-width match. Include eligible empty-line boundaries when searching from the requested position.
    Evidence: TestReviewEmptyInitialLine reproduces 2 through regularInstrWithMatchType; the same merge-base test and ICU control return 1. See semantic-head.jsonl, semantic-base.jsonl and icu-controls.log.

Validation:

  • Evidence and receipt reconciliation are retained in /home/xupeng/.local/state/mo-bot/jobs/c697b64831e9fb2a1aa4619c/attempt-1/evidence-audit.json; design and coverage analysis are in review-notes.json. Frozen HEAD, complete patch and unchanged checkout were verified.

  • Isolation preflight passed. Native reuse was verified against 291 current source inputs, seven artifact hashes, the repository build-owner receipt and retained build log.

  • semantic-head.jsonl, receipt 1792659717088693434-7: six existing focused CAST/REGEXP test groups passed; four added regression groups failed. Overall exit 1.

  • hang-head.jsonl, receipt 1792659910537161045-3: intentional three-second test timeout confirmed nontermination. semantic-base.jsonl, receipt 1792659967279233596-3: all four selected baseline control groups passed.

  • Standalone ICU 76.1 controls passed, receipt 1792659951996905999-34. Head/base benchmark receipts 1792660048607148269-3 and 1792660347445035305-3 both exited 0; identical fixtures and frozen baseline overlays were verified.

  • Benchmark controls: mu median 60.054 versus 49.687 µs; no match_type median 26.293 versus 23.446 µs, with three allocations on both revisions. Existing simple-anchor large-input and terminator tests passed.

Limitations:

  • Fresh checks used production vector entry points and matching helpers, not a running SQL server. ICU checks are reference probes, not MySQL-server tests.

  • Frozen CI reports success, but its summary does not cover the demonstrated counterexamples. Earlier author full-suite, race and BVT artifacts predate the new line-splitting implementation.

  • Linked issue bodies were not supplied; their contracts were assessed from frozen PR descriptions and comments. Full SQL/BVT and race suites were not repeated after these confirmed blockers.

…nchor defects (#30646)

mo-bot review round 4 found six confirmed defects in the per-line RE2
evaluation. Fixes, one per finding:

- Terminate trailing-line iteration (P1, func_builtin_regexp_linesplit.go:99):
  the final empty line after a trailing LF was yielded with termEnd =
  len(subject), so callers reusing the cursor re-yielded it forever
  (REGEXP_LIKE('a\rb\n', '^z$', 'm') hung). termEnd is now len(subject)+1
  as the exhausted sentinel; the empty subject  is one empty line, which
  keeps (?m)^$ semantics after the routing change below.
- Drop the mandatory whole-subject pre-scan (P1, 532-524x): routing no
  longer inspects the subject at all. Anchor-only patterns that cannot
  match a line terminator always take the per-line route, so a prefix hit
  short-circuits on the first line at base-engine speed; the
  regexpWideMultilineSubjectNeedsICU gate is removed.
- Plain dot is no longer terminator-capable (P1 admission): OpAnyCharNotNL
  matches ICU's default dot (which excludes every line terminator), so
  patterns like '^a.' evaluate per line instead of falling back to
  regexp2's 8 MiB admission budget. Dot with match_type 'n' (OpAnyChar)
  and \s / explicit classes still route to regexp2.
- Subject anchors excluded from per-line evaluation (P2): patterns whose
  parsed form contains OpBeginText / OpEndText (\A, \z, or (?-m:) scopes)
  now route to whole-subject regexp2, since per-line buffers would give
  those anchors fake line boundaries.
- REPLACE occurrence counts across lines (P2): when a line holds fewer
  matches than the remaining occurrence, the line is emitted unchanged
  instead of replacing every match on it ('a\ra', '^a', occ 2/3).
- Zero-width matches at the requested byte position are eligible (P2):
  wideNthMatch and REPLACE now include lines whose end equals startByte
  (lineEnd >= startByte), so REGEXP_INSTR('\ra', '^', 1, ...) returns 1.

Regression tests: new file regexp_wide_linesplit_review_test.go with one
counterexample per finding plus route-selection and extended controls;
existing routing assertions in TestRegexpWideMultilineReviewFindings were
migrated to the round-4 contract (per-line is subject-independent; plain
dot per-line; oversized dot no error; terminator-literal still errors
explicitly). Full regexp suite: 296 PASS / 0 FAIL.
@aptend

aptend commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

Fixes for the six round-4 defects (head 0afd650 + main merge 4a7474f):

  • P1 infinite loop (linesplit.go:107): the trailing empty line after LF is now yielded once — termEnd carries a len(subject)+1 exhausted sentinel; REGEXP_LIKE('a\rb\n','^z$','m') terminates. Empty subject "" is one empty line, preserving (?m)^$ semantics.
  • P1 524x perf (linesplit.go:71): routing no longer pre-scans the subject at all. Anchor-only patterns that cannot match a line terminator always take the per-line route, so an anchored prefix hit short-circuits on the first line; the subject gate is deleted.
  • P1 regexp2 admission (linesplit.go:75): plain dot (OpAnyCharNotNL) is no longer terminator-capable — it matches ICU's default dot that excludes every line terminator, so '^a.' evaluates per line instead of hitting regexp2's 8 MiB budget. Dot with match_type 'n' (OpAnyChar), \s and terminator-containing classes still route to regexp2.
  • P2 whole-subject anchors (linesplit.go:75/192): patterns whose parsed form contains OpBeginText/OpEndText (\A, \z, (?-m:) scopes) now route to whole-subject regexp2 — per-line buffers would give those anchors fake line boundaries.
  • P2 REPLACE occurrence (linesplit.go:397): matches are counted across lines; a line holding fewer than the remaining occurrence is emitted unchanged. ('a\ra','^a',occ 2 → 'a\rX', occ 3 → unchanged).
  • P2 INSTR start position (linesplit.go:251): zero-width matches at the requested byte are eligible — guard is now lineEnd >= startByte; REGEXP_INSTR('\ra','^',1,1,0,'m') = 1.

Regression evidence: new regexp_wide_linesplit_review_test.go (one counterexample per finding + route-selection controls); the pre-existing routing assertions migrated to the round-4 contract. Full regexp suite: 309 PASS / 0 FAIL after merging origin/main (2b388dd).

Align the replace-occurrence case struct fields so the SCA static-check
(golangci-lint gofmt) accepts the new regression file added in 0afd650.
@XuPeng-SH

XuPeng-SH commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: 6c133a627fdbcf8e0529037bc8dae8acc01af8ba

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: 6c133a627fdbcf8e0529037bc8dae8acc01af8ba

Assessment: request_changes

Reviewed the complete 18-file delta and latest comments. Identifier quoting and explicit CAST handling appropriately reuse existing owners. REGEXP line splitting breaks whole-subject matching and replacement contracts: five confirmed defects remain, including a replacement-size limit bypass and a roughly 291× prefix-match slowdown.

Model: gpt-6-astra / xhigh

Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1

  • P1 pkg/sql/plan/function/func_builtin_regexp_linesplit.go:460: Replace all '^a' matches in nine 'a\n' lines with an 8 MiB replacement using match_type 'm'.
    Impact: Each line independently passes the replacement-size check, while the outer builder accumulates a result exceeding the established 64 MiB limit. Enforce the aggregate budget before appending, including unchanged text and terminators.
    Evidence: TestReviewCurrentReplaceLimit returns 75,497,481 bytes with no error at HEAD. The identical merge-base control returns the expected 67,108,864-byte size-limit error. The production caller receives this materialized result through regularReplaceWithMatchType. See semantic-head.log and semantic-base.log.

  • P1 pkg/sql/plan/function/func_builtin_regexp_linesplit.go:261: Evaluate REGEXP_LIKE with pattern '^alpha', match_type 'm', and a subject containing 'alpha' followed by 32,768 ASCII characters without a line terminator.
    Impact: wideMultilineNextLine scans the entire first line before the matcher can accept the prefix. Removing the routing pre-scan therefore does not restore short-circuit performance. Preserve prefix matching without first finding the complete line boundary.
    Evidence: Identical warmed production-vector benchmarks over 256 rows, three samples per revision, measured median 13.931 ms at HEAD versus 47.909 µs with merge-base function code: approximately 291× slower. Allocations increased from 259 to 3,587 per batch. See bench-head.log and bench-base.log.

  • P1 pkg/sql/plan/function/func_builtin_regexp_linesplit.go:76: Evaluate REGEXP_LIKE with pattern '^a\s', match_type 'm', and subject 'a\n' followed by 16,384 ASCII characters.
    Impact: This previously supported immediate prefix match now enters regexp2 and fails its admission budget. Larger subjects also encounter the new 1 MiB rejection. Preserve the supported input domain for regular cross-line patterns instead of making the backtracking engine their only execution path.
    Evidence: TestReviewCurrentAdmission fails through builtInRegexpLike with the 8,388,608-byte evaluation-memory error at 16,386 subject bytes and the explicit size rejection at 1,048,579 bytes. Both identical merge-base controls and independent ICU controls return true.

  • P2 pkg/sql/plan/function/func_builtin_regexp_linesplit.go:453: REGEXP_REPLACE on subject '\na', pattern '^', replacement 'X', position 1, occurrence 0 and match_type 'm'.
    Impact: The empty line is passed to regularReplaceWithMatchType, whose whole-subject empty-string shortcut suppresses its valid match. The result is '\nXa' instead of 'X\nXa'; interior empty lines are also skipped. Keep empty-line matching distinct from the empty-subject contract.
    Evidence: TestReviewCurrentEmptyLineReplace reproduces the wrong results through builtInRegexpReplace for leading, interior and trailing LF boundaries. Identical merge-base controls pass. ICU independently confirms the leading and interior empty-line expectations.

  • P2 pkg/sql/plan/function/func_builtin_regexp_linesplit.go:110: REGEXP_REPLACE on subject 'a\r', pattern '$', replacement 'X', position 1, occurrence 0 and match_type 'm'; likewise with trailing NEL, LS or PS.
    Impact: Stopping iteration after these terminators applies the caret exclusion to every pattern and loses the valid dollar match at the true end of the subject. Preserve terminal matches independently of the rule excluding a trailing caret.
    Evidence: HEAD returns 'aX\r' instead of ICU's 'aX\rX'. TestReviewCurrentTerminalDollar confirms the missing terminal replacement for all four terminators; the merge base preserves that terminal replacement. ICU 76.1 independently enumerates both dollar matches.

Validation:

  • Evidence is retained under /home/xupeng/.local/state/mo-bot/jobs/9afab1e3cfb1a4ff6baf6337/attempt-1. evidence-audit.json reconciles commands, source fingerprints, overlays, native hashes, exit receipts and logs. Audit receipt 1792736809661161777-4.json passed; review-notes.json records the complete change map and ownership analysis.

  • Isolation preflight passed. An incompatible retained native build was rejected, then the repository build owner successfully rebuilt prerequisites. Verified 309 frozen native inputs and seven output hashes. Source remained unchanged.

  • semantic-head.log, receipt 1792736490983134087-16.json: selected existing CAST, multiline and previous-review regression groups passed; four new regression groups failed. semantic-base.log, receipt 1792736642224056752-3.json: all four identical control groups passed.

  • Head/base benchmark receipts 1792736657588899285-3.json and 1792736686654424098-3.json both exited 0. Control medians were 59.645 versus 48.378 µs for 'mu', and 26.534 versus 22.795 µs without match_type.

  • Standalone ICU controls passed, receipt 1792736419250944548-35.json. Frozen exact-head CI reports successful UT, SCA, coverage and both active BVT topologies; these do not cover the demonstrated counterexamples.

Limitations:

  • Fresh checks exercised production function entry points and matching helpers, not a running SQL server. ICU was a standalone reference; benchmarks measure predicate execution rather than whole-query throughput.

  • Earlier author full-suite, race and BVT artifacts predate the current line-splitting implementation. Full race/BVT suites were not repeated after confirming the blockers.

  • Raw CI logs and linked issue bodies were absent from frozen evidence; issue contracts were assessed from the supplied PR description, comments and source.

- caret context through the line splitter: suppress '^' matches at
  end-of-input after trailing lone CR/NEL/LS/PS and emit the terminal
  empty segment so '$' still anchors before a trailing lone terminator
- subject-content gate on the wide route: subjects proven free of line
  terminators take the exact RE2 path even for terminator-matching or
  caret-anchored patterns; over-budget subjects only error when a wide
  terminator is genuinely present
- plain-dot (non-terminator) patterns stay on the per-line route; REGEXP
  _LIKE/INSTR/SUBSTR get caret-suppressed evaluation plus literal-prefix
  and terminator-class short-circuits on wide subjects
- REPLACE: caret-suppressed occurrence counting, empty-line replacement,
  aggregate per-call output budget instead of per-line subject budget,
  empty-subject shortcut preserved
- update frozen review test to the subject-gated contracts
@aptend

aptend commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

Round-5 fixes are in — @maintainer please re-review.

Changes in 28f12d7 (merged with latest main as 9611a08)

  1. Caret context through the line splitter (wideMultilineNextLine now returns caretOK): '^' matches are suppressed at end-of-input after a trailing lone CR/NEL/LS/PS, and the terminal empty segment is emitted so '$' still anchors before a trailing lone terminator — matching ICU on all four wide terminators, in both text and binary domains.
  2. Subject-content gate on the wide route: subjects proven free of line terminators take the exact RE2 path even for terminator-matching or caret-anchored patterns (LE-1 equivalence); regexp2 is kept only where the subject genuinely carries wide terminators within its admission budget; over-budget + wide terminator → explicit wide multiline error, never silent LF-only fallback.
  3. Plain dot (non-terminator) patterns stay on the per-line route; LIKE/INSTR/SUBSTR get caret-suppressed evaluation plus literal-prefix and terminator-class short-circuits on wide subjects (no 8MiB admission memory for anchored prefixes).
  4. REPLACE: caret-suppressed occurrence counting, empty-line replacement ('\n\nx' under '^' → 'X\nX\nxX'), aggregate per-call output budget instead of per-line subject budget, and the MySQL empty-subject shortcut preserved on the wide path.
  5. Tests: 5 new frozen regressions (empty-line replace, terminal '$', aggregate limit, prefix short-circuit, terminator-class routing) + updated TestRegexpWideMultilineReviewFindings to the subject-gated contracts (non-const '^a\rb' still errors over budget with wide terminator; const 'a\rb' now answers correctly on any size; single-line subjects no longer error).

Local verification

  • gofmt clean; full pkg/sql/plan/function test package: PASS (7.2s)
  • All 11 TestReviewWide* regressions green, incl. prior-round suites
  • Merged origin/main @ 564d023 before push (no force-push/amend)

@aptend

aptend commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

CI attribution for the red lanes on 9611a08 — only one lane is a real failure; the other two reds are derived.

  • multi cn e2e bvt test docker compose(PROXY): TOTAL 48653 / FAILED 2 — both assertion failures are inside test/distributed/cases/dml/select/count_derived_sort.sql ([30] vs [21], row count 1 vs 0), the BVT case introduced today by fix(plan): eliminate unobserved sorts below scalar COUNT #30828 (count-sort-elimination). The values repeat identically across the tester's in-lane retries, and the same file passes on the same head in every other topology (standalone BVT, compose CO-pool).
  • fix(plan): eliminate unobserved sorts below scalar COUNT #30828's own PR skipped the PROXY lane, so this run is the first-ever PROXY execution of that case; no other completed MatrixOne ALL CI run since 06:50Z has executed a PROXY job.
  • The case contains zero regexp usage; the regexp line-splitting diff in this PR cannot reach it. UT / SCA / the other BVT lanes are green on this head (17 ✅).
  • Coverage red is downstream: the PROXY compose job is a coverage producer, its artifact is missing (coverage-inputs.txt not found → merge step skipped). CI Required is the aggregate.
  • Failed jobs rerun queued to confirm determinism; if it reproduces identically, this needs the plan team's attention on fix(plan): eliminate unobserved sorts below scalar COUNT #30828 rather than a change in this PR.

@XuPeng-SH

XuPeng-SH commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: 24de44cd1b0e3a91481c2bf1e45f0616394e59e0

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: 24de44cd1b0e3a91481c2bf1e45f0616394e59e0

Assessment: request_changes

Reviewed the complete 21-file delta and supplied review concerns. Identifier quoting and explicit CAST handling appropriately reuse existing owners. Earlier REGEXP boundary fixes pass, but the line-splitting design still narrows supported inputs and substantially slows ordinary predicates.

Model: gpt-6-astra / xhigh

Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1

  • P1 pkg/sql/plan/function/func_builtin_regexp_linesplit.go:84: Evaluate REGEXP_LIKE with pattern '^a\s', match_type 'm', and subject 'a\n' followed by 16,384 ASCII characters and a trailing CR.
    Impact: An unrelated trailing terminator forces this immediate prefix match through regexp2 and aborts a previously successful statement. Preserve the supported input domain for regular cross-line patterns instead of imposing backtracking-engine admission limits.
    Evidence: Production builtInRegexpLike tests fail in both text and binary modes with the 8,388,608-byte evaluation-memory error. Larger controls hit the new 1 MiB rejection. All four identical tests pass with frozen merge-base REGEXP code. See head-admission.log and base-admission.log; receipts 1792812612252978234-9.json and 1792812651408416280-3.json.

  • P1 pkg/sql/plan/function/func_builtin_regexp_linesplit.go:427: Evaluate a constant '^alpha' multiline predicate across text rows containing 'alpha' followed by 32,768 ASCII characters.
    Impact: The matcher scans 4 KiB before accepting an immediate prefix match, while routing reparses the constant pattern for every row. The bounded probe reduces the previous slowdown but does not restore inexpensive prefix matching. Cache invariant pattern analysis and preserve prefix short-circuiting.
    Evidence: Identical warmed production-vector benchmarks over 256 rows, three samples per variant, measured median 1.551 ms at HEAD versus 47.100 µs with base REGEXP code: approximately 33× slower. Allocated bytes increased from 4,352 to 213,250 per batch. Short text inputs were 5.8× slower; long binary inputs were 3.9× slower. See bench-head.log and bench-base.log; receipts 1792812697300224698-3.json and 1792812722624270459-3.json.

Validation:

  • Artifacts are retained under /home/xupeng/.local/state/mo-bot/jobs/149b59ac54e976b81d0652a0/attempt-1. evidence-audit.json reconciles commands, source fingerprints, overlay hashes, exits and logs; audit receipt 1792812842594650088-4.json passed. Source remained unchanged.

  • Isolation preflight passed. Verified 192 native-source inputs against retained prerequisites and passed the repository's native provenance verification before compiling tests. Go checks used the assigned caches and test-exec.

  • Selected existing REGEXP and explicit-CAST tests passed: 99 top-level tests, 461 passes including subtests, zero skips. Existing termination, occurrence, empty-line, terminal-dollar and aggregate-output-limit regressions passed. See existing-head.log and receipt 1792812664532707703-3.json.

  • Base comparisons restored all changed REGEXP production files through an overlay while retaining identical diagnostic fixtures and surrounding dependencies.

  • Long-text benchmark controls measured 62.814 versus 47.980 µs with 'mu', and 22.221 versus 20.040 µs without match_type, per 256-row batch.

  • The frozen current-head CI snapshot reports successful UT, SCA, coverage and active BVT checks. These do not cover the demonstrated counterexamples.

Limitations:

  • Fresh counterexamples exercise production function entry points; benchmarks measure operator execution rather than whole-query throughput. Full race/BVT suites and a SQL server session were not repeated.

  • local_validation is empty and the author's macOS artifact directory is unavailable. Author execution claims were not independently reconciled. Raw CI logs and linked issue bodies were absent from the supplied evidence.

@XuPeng-SH

XuPeng-SH commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: bd19b2a6c0bbf06cc56e55a0891441981ad5046a

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: bd19b2a6c0bbf06cc56e55a0891441981ad5046a

Assessment: approve

Reviewed the complete 32-file delta, affected owners and prior review concerns. Quoting and CAST changes reuse established owners. The pinned regexp fork centralizes wide-line assertions while preserving subject context, caching and resource limits. No actionable findings remain.

Model: gpt-6-astra / xhigh

Session: 01a13dcf-1586-7a01-9000-d45e20995cf8 · slot 1 · generation 1

Validation:

  • Reconciled nine check receipts with frozen source, commands, exits and retained logs in /home/xupeng/.local/state/mo-bot/jobs/b4f41408bc177dd241e728ac/attempt-1/evidence-audit.json. Source remains unchanged.

  • Isolation preflight passed. Verified 192 native inputs through the repository provenance owner, pinned Go 1.27.1 upstream hashes and the matcher fork diff.

  • Passed 97 focused REGEXP/CAST tests and 11 prior-review regression tests, including large subjects, boundaries, positions, replacement limits, ICU cleanup, masking, NULLs and warnings.

  • The complete private matcher package passed normally and with the race detector, including all three executors and concurrent reuse.

  • Three-sample production predicate benchmarks: wide-mode short/long text medians were 31.32/46.65 microseconds versus base 34.26/49.53; long binary was 1.614 versus 1.603 milliseconds. Allocations fell from 259 to 3 per 256-row batch.

  • Frozen current-head CI reports successful build, UT, SCA, coverage and PROXY/PESSIMISTIC BVT checks. Changed SQL fixtures and expected results were reviewed separately.

Limitations:

  • Default text predicates measured 8–9% slower and short Unix-line predicates 11% slower; these bounded costs are accepted alongside the compatibility improvement. Benchmarks cover warmed function execution, not whole-query throughput.

  • Local execution exercised function entry points rather than a fresh SQL server. CI evidence is the frozen status snapshot. Unavailable author macOS artifacts and linked issue bodies were not treated as independently verified evidence.

@mergify

mergify Bot commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-24 10:57 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🚫 Left the queue — 2026-10-24 10:57 UTC · at bd19b2a6c0bbf06cc56e55a0891441981ad5046a

This pull request spent 3 seconds in the queue, with no time running CI.

Reason

The pull request cannot be checked because of an incompatibility with branch protections

'Require a pull request before merging' branch protections are enabled on fix-b-compat-30550-30417-30210, Mergify cannot check the pull request inplace.

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

  • Requeue this pull request

This branch had an error being deployed

1 failed deployment
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/XXL Denotes a PR that changes 2000+ lines

Projects

None yet

3 participants