Repository navigation
Conversation
XuPeng-SH
requested review from
LeftHandCold,
aptend and
aunjgr
as code owners
September 12, 2026 14:33
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
XuPeng-SH
force-pushed
the
codex/issues-28304-28305-regexp
branch
from
September 12, 2026 15:19
08bf9bf to
b2b2125
Compare
This was referenced Sep 12, 2026
XuPeng-SH
force-pushed
the
codex/issues-28304-28305-regexp
branch
from
September 12, 2026 16:23
b2b2125 to
1f6bfb9
Compare
XuPeng-SH
added a commit
that referenced
this pull request
Sep 13, 2026
## What type of PR is this? - [x] BUG - [ ] API-change - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Partial follow-up for #28305 — capture replacement only. This PR targets `main`. It depends on the regexp match-type positioning support in #28787, so the current PR diff includes #28787's prerequisite commits as well. Once #28787 merges, rebase this branch onto updated `main` to remove those prerequisite commits from this PR's diff. ## What this PR does / why we need it: REGEXP_REPLACE currently uses literal-replacement APIs and directly appends the replacement for occurrence-specific calls. Thus MySQL/ICU capture references such as $2$1 are returned literally rather than expanded (`REGEXP_REPLACE('ab', '(a)(b)', '$2$1')` should return `ba`). This change adds a bounded replacement-template parser for whole-match, numeric and supported named capture references, and backslash quoting. It preserves unmatched captures as empty and defers template errors until a match is actually selected, so a no-match result remains the original subject. The position-aware matcher exposes captures from the original pattern, and binary match offsets are mapped back to source bytes before captured content is appended. Ordinary replacements without dollar-sign or backslash markers retain the existing optimized literal path. Template execution keeps only the current match, does not cache row-specific templates, checks the final byte length against the engine's 64 MiB blob limit, and returns an error instead of truncating oversized output. Large conservative bounds use a size-only pass before allocating; the streaming path allocates only after its first match and starts with a bounded capacity. ## Scope and known limitations This is intentionally only the capture-replacement part of #28305. It does not add ICU-only pattern constructs (lookaround, pattern backreferences, atomic groups, possessive quantifiers, or grapheme matching), does not replace RE2, and does not claim complete ICU replacement-template parity. Unicode-digit references and ICU-specific Unicode escape forms remain out of scope pending a pinned-version compatibility decision. #28305 should remain open until those pattern-dialect gaps are resolved or explicitly split/closed by the issue owner. The runtime result limit is 64 MiB, matching MatrixOne's current maximum blob size. Results are never silently truncated. This PR does not alter the declared return-type formula. ## Validation and merge gates - Added focused UT coverage for group swapping, whole match, greedy numeric references and fallback, leading zeroes, unmatched and named groups, escaping, invalid/lazy templates, occurrence/position/overlap/anchor/zero-width cases, binary NUL/invalid UTF-8 captures, binary case folding, and output-size boundaries. - Added quote-boundary regressions for trailing open `\Q`, escaped backslashes, the first `\E` after a quoted literal backslash, and noninitial-position `REGEXP_INSTR`/`REGEXP_SUBSTR`/`REGEXP_REPLACE` in text and binary modes. - Extended the existing func_regular_replace BVT with SQL-visible capture expansion, quote-boundary and position behavior, BINARY/VARBINARY byte preservation, and prepared replacement rebinding. - `go test ./pkg/sql/plan/function -run '^Test_BuiltIn_Regexp' -count=1` passes on the current head; `git diff --check` passes. - `golangci-lint run --timeout=10m ./pkg/sql/plan/function` passed on the same PR diff before the latest base-only rebase; the diff fingerprint is unchanged. - The local distributed BVT and the full function-package UT were not run. Require exact-head full package UT, the func_regular_replace BVT, and incremental SCA before merge; no CI result is claimed here.
XuPeng-SH
force-pushed
the
codex/issues-28304-28305-regexp
branch
from
September 13, 2026 18:10
00a222d to
4d18bee
Compare
1 task done
VioletQwQ-0
pushed a commit
to VioletQwQ-0/matrixone
that referenced
this pull request
Sep 17, 2026
## What type of PR is this? - [x] BUG - [ ] API-change - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Partial follow-up for matrixorigin#28305 — capture replacement only. This PR targets `main`. It depends on the regexp match-type positioning support in matrixorigin#28787, so the current PR diff includes matrixorigin#28787's prerequisite commits as well. Once matrixorigin#28787 merges, rebase this branch onto updated `main` to remove those prerequisite commits from this PR's diff. ## What this PR does / why we need it: REGEXP_REPLACE currently uses literal-replacement APIs and directly appends the replacement for occurrence-specific calls. Thus MySQL/ICU capture references such as $2$1 are returned literally rather than expanded (`REGEXP_REPLACE('ab', '(a)(b)', '$2$1')` should return `ba`). This change adds a bounded replacement-template parser for whole-match, numeric and supported named capture references, and backslash quoting. It preserves unmatched captures as empty and defers template errors until a match is actually selected, so a no-match result remains the original subject. The position-aware matcher exposes captures from the original pattern, and binary match offsets are mapped back to source bytes before captured content is appended. Ordinary replacements without dollar-sign or backslash markers retain the existing optimized literal path. Template execution keeps only the current match, does not cache row-specific templates, checks the final byte length against the engine's 64 MiB blob limit, and returns an error instead of truncating oversized output. Large conservative bounds use a size-only pass before allocating; the streaming path allocates only after its first match and starts with a bounded capacity. ## Scope and known limitations This is intentionally only the capture-replacement part of matrixorigin#28305. It does not add ICU-only pattern constructs (lookaround, pattern backreferences, atomic groups, possessive quantifiers, or grapheme matching), does not replace RE2, and does not claim complete ICU replacement-template parity. Unicode-digit references and ICU-specific Unicode escape forms remain out of scope pending a pinned-version compatibility decision. matrixorigin#28305 should remain open until those pattern-dialect gaps are resolved or explicitly split/closed by the issue owner. The runtime result limit is 64 MiB, matching MatrixOne's current maximum blob size. Results are never silently truncated. This PR does not alter the declared return-type formula. ## Validation and merge gates - Added focused UT coverage for group swapping, whole match, greedy numeric references and fallback, leading zeroes, unmatched and named groups, escaping, invalid/lazy templates, occurrence/position/overlap/anchor/zero-width cases, binary NUL/invalid UTF-8 captures, binary case folding, and output-size boundaries. - Added quote-boundary regressions for trailing open `\Q`, escaped backslashes, the first `\E` after a quoted literal backslash, and noninitial-position `REGEXP_INSTR`/`REGEXP_SUBSTR`/`REGEXP_REPLACE` in text and binary modes. - Extended the existing func_regular_replace BVT with SQL-visible capture expansion, quote-boundary and position behavior, BINARY/VARBINARY byte preservation, and prepared replacement rebinding. - `go test ./pkg/sql/plan/function -run '^Test_BuiltIn_Regexp' -count=1` passes on the current head; `git diff --check` passes. - `golangci-lint run --timeout=10m ./pkg/sql/plan/function` passed on the same PR diff before the latest base-only rebase; the diff fingerprint is unchanged. - The local distributed BVT and the full function-package UT were not run. Require exact-head full package UT, the func_regular_replace BVT, and incremental SCA before merge; no CI result is claimed here.
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #28304
What this PR does / why we need it:
Adds the missing MySQL-compatible
match_typeoverloads forREGEXP_INSTR,REGEXP_SUBSTR, andREGEXP_REPLACE. The flags are applied to both initial and position-aware matching, including the iterator's wrapped-pattern compilation. Row-dependent modes are parsed per row; existing overload IDs and signatures remain unchanged.The implementation preserves existing binary byte-position/result behavior. For explicit case-insensitive matching on binary operands, high bytes use the existing Windows-1252 facade.
Validation
gofmt -dandgit diff --check: passed.golangci-lintagainst base46cf1d24a7d77e7be6060a17e4596da90743b59f: passed, 0 issues.thirdparties/installandcgo/libmo.dylib; the controlled CGo test wrapper rejected the missing native-artifact provenance. No test pass is claimed.Merge gate: run the affected UTs and owning package through the controlled CGo workflow, plus normal-comparison BVT for
func_regular_like,func_regular_instr,func_regular_substr, andfunc_regular_replace. Do not merge unless these pass on the PR head.Performance and scope
Existing call signatures keep their prior execution path. The new overloads add per-row flag parsing and reuse the bounded regexp cache. Explicit binary
imatching on non-ASCII bytes performs linear conversion and temporary allocation; no benchmark was run.This PR accepts
uusing Go RE2's existing LF-only line behavior; it does not implement the full MySQL ICU dialect. Capture-group replacement and the other ICU-only constructs in #28305 are intentionally out of scope. PR #28534 (#27217) separately touches the regex executor/domain area; verify the combined behavior before merge.