Skip to content

fix(sql): accept MySQL numeric prefixes in string functions - #28408

Merged
XuPeng-SH merged 3 commits into
matrixorigin:mainfrom
XuPeng-SH:codex/issue-28396-numeric-prefix-20260908
Sep 8, 2026
Merged

XuPeng-SH merged 3 commits into
matrixorigin:mainfrom
XuPeng-SH:codex/issue-28396-numeric-prefix-20260908

Conversation

@XuPeng-SH

Copy link
Copy Markdown
Contributor

Fixes #28396.

MySQL string functions consume the leading decimal integer from textual numeric arguments (for example, 2tail -> 2); MatrixOne previously used strict implicit casts and rejected these values. This adds a planner-scoped compatibility path using the existing comparison-cast overload, preserves old CN plan compatibility, keeps binary and ordinary/explicit/assignment casts unchanged, and covers zero-prefix, NULL, warnings, and signed/unsigned boundaries.

Validation:

  • ./.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=600s ./pkg/sql/plan/function
  • ./.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=600s ./pkg/sql/plan

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

@matrix-meow matrix-meow added the size/M Denotes a PR that changes [100,499] lines label Sep 8, 2026
@XuPeng-SH
XuPeng-SH force-pushed the codex/issue-28396-numeric-prefix-20260908 branch from 3ff5d88 to 288c516 Compare September 8, 2026 11:05

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Explicit user-override deep review of 288c516 (base f8a690c). COMMENT ONLY for a self-authored PR. No confirmed source blocker found; not a formal approval or a claim that pending CI has passed.

Read every hunk in all seven files. The executable change is the planner's textual numeric-argument whitelist; func_cast.go changes here are explanatory comments, reusing the existing comparison-cast implementation. Traced whitelist argument positions into overload coercion, signed/unsigned integer-prefix conversion and warning production, plus string-result consumers and bounds. Ordinary/explicit/assignment casts and binary physical string families retain their existing paths; nonnumeric function arguments are not rerouted. No new mutable shared state, asynchronous work, resource owner, wire field or function ID is introduced.

The result tests exercise constant plan execution as well as binder acceptance; runtime column coercion uses the same cast and is represented by column binder cases and existing BVT changes. Warning tests distinguish suffix/decimal/exponent/empty/no-prefix input and signed/unsigned boundaries. Changed BVT outputs follow the new zero/prefix result contract, including NULL rows and GROUP BY on an empty substring. SPACE retains its existing count cap; REPEAT/PAD retain length/overflow admission before output allocation. I found no newly unbounded output-allocation path.

Evidence limits/non-blocking follow-up: current Ubuntu UT is still IN_PROGRESS; the override bypasses readiness, not validation truth. Author-reported focused package passes are not my executions; no local native suite was run. Keep full CI and the changed BVT files' selected execution acceptance open. A multirow text-column execution case with warning/NULL assertions and a text PREPARE/EXECUTE case would strengthen coverage beyond constant folding. Reusing an existing overload keeps plans structurally executable on older CNs, but should not be described as proof that an older implementation without the prefix behavior produces identical results. Source conclusion remains no confirmed blocker.

@XuPeng-SH

Copy link
Copy Markdown
Contributor Author

CI failure analysis

The failed UT job 102036981383 was in pkg/fileservice, test TestDiskCacheAsyncCallbacksRemainOrderedAndBounded, and panicked in the asynchronous CheckedAllocator finalizer path with missing free. The PR changes only SQL planner/function files and distributed expected results; it does not touch fileservice.

The failed job was rerun as 102081382211 on the same commit. All other required jobs in that run have passed; the UT rerun is still in progress. No source change is warranted in this PR unless the rerun reproduces a failure in the changed code.

@XuPeng-SH

Copy link
Copy Markdown
Contributor Author

Conflict / branch update

The branch was out of date with main, so I rebased it onto the latest origin/main at 8934da6595 and pushed the rebased head d0dcad957d with --force-with-lease.

The PR is now based on the current main history. The previous CI result belonged to the old head; GitHub will create/evaluate checks for the rebased commit.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Explicit-override re-review of current head d0dcad9, base 8934da6. Self-authored: COMMENT only. No confirmed source blocker found; this is not an assertion that pending CI has passed.

Read all current changed hunks in the seven-file change map and compared against the previously reviewed head 288c516. Six files, including the entire cast implementation and its diagnostics tests, are byte-identical by Git blob SHA. An exact head-to-head comparison of base_binder.go shows only inherited JSON_QUOTE lookup/JSON-result changes; the numeric-argument whitelist and comparison-cast dispatch are unchanged. The JSON_QUOTE-only lookup override does not reroute these string-function arguments. This supports reusing the prior full runtime/resource/compatibility analysis rather than assuming that a new head is identical.

Rechecked the current coercion site: it requires an actual type conversion, textual CHAR/VARCHAR/TEXT input, numeric target, and a whitelisted function argument position; ordinary/explicit/assignment and binary-family conversions retain their existing paths, and cast errors propagate. No new asynchronous work, shared mutable state, serialized function ID, or output-allocation policy is introduced. The existing constant-result tests, warning/range checks, NULL-containing column BVT expectations, and previous bounds review remain applicable.

Non-blocking acceptance remains: run the complete selected CI/BVT paths for this rebased head, and preferably add multirow textual numeric-argument execution plus PREPARE/EXECUTE with warning/NULL assertions. No MatrixOne native suite was run by this reviewer during this re-review; author-reported test passes are attributed evidence. Existing-overload wire compatibility should not be confused with proof of identical coercion semantics on older CN implementations.

@XuPeng-SH
XuPeng-SH merged commit b7eca64 into matrixorigin:main Sep 8, 2026
17 of 20 checks passed
@XuPeng-SH
XuPeng-SH deleted the codex/issue-28396-numeric-prefix-20260908 branch September 8, 2026 15:17
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…igin#28408)

Fixes matrixorigin#28396.

MySQL string functions consume the leading decimal integer from textual
numeric arguments (for example, `2tail` -> 2); MatrixOne previously used
strict implicit casts and rejected these values. This adds a
planner-scoped compatibility path using the existing comparison-cast
overload, preserves old CN plan compatibility, keeps binary and
ordinary/explicit/assignment casts unchanged, and covers zero-prefix,
NULL, warnings, and signed/unsigned boundaries.

Validation:
- `./.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=600s
./pkg/sql/plan/function`
- `./.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=600s
./pkg/sql/plan`
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…igin#28408)

Fixes matrixorigin#28396.

MySQL string functions consume the leading decimal integer from textual
numeric arguments (for example, `2tail` -> 2); MatrixOne previously used
strict implicit casts and rejected these values. This adds a
planner-scoped compatibility path using the existing comparison-cast
overload, preserves old CN plan compatibility, keeps binary and
ordinary/explicit/assignment casts unchanged, and covers zero-prefix,
NULL, warnings, and signed/unsigned boundaries.

Validation:
- `./.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=600s
./pkg/sql/plan/function`
- `./.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=600s
./pkg/sql/plan`
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…igin#28408)

Fixes matrixorigin#28396.

MySQL string functions consume the leading decimal integer from textual
numeric arguments (for example, `2tail` -> 2); MatrixOne previously used
strict implicit casts and rejected these values. This adds a
planner-scoped compatibility path using the existing comparison-cast
overload, preserves old CN plan compatibility, keeps binary and
ordinary/explicit/assignment casts unchanged, and covers zero-prefix,
NULL, warnings, and signed/unsigned boundaries.

Validation:
- `./.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=600s
./pkg/sql/plan/function`
- `./.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=600s
./pkg/sql/plan`

This branch was previously deployed

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

Labels

size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Compatibility]: string position and count functions reject MySQL numeric-prefix arguments

2 participants