Skip to content

fix(function): expose ASCII as signed INT - #28746

Merged
XuPeng-SH merged 4 commits into
matrixorigin:mainfrom
XuPeng-SH:codex/issue-28455-ascii
Sep 12, 2026
Merged

XuPeng-SH merged 4 commits into
matrixorigin:mainfrom
XuPeng-SH:codex/issue-28455-ascii

Conversation

@XuPeng-SH

@XuPeng-SH XuPeng-SH commented Sep 11, 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 #28455

What this PR does / why we need it:

ASCII() returned the correct byte value but exposed TINYINT UNSIGNED
metadata. That leaks into CTAS, views, UNION/set-operation type resolution,
prepared consumers, and client metadata; MySQL exposes the result as signed
INT.

The function registry now declares all ASCII overloads as signed T_int32 and
the normal executor writes INT32 results. A compatibility path retains legacy
UINT8 function-result wrappers and old serialized plans. A MORPC v65 feature
fence rejects a new INT32 ASCII plan when the peer cannot decode it, while new
peers continue to accept legacy plans.

Validation

  • Rebased onto origin/main at efb2c5084957ac90273a3f625668fc6a784562c4.
  • Isolated make cgo -j12 completed.
  • Focused ASCII executor, legacy-wrapper, plan-feature, and remote-protocol
    tests passed; the corresponding focused suites also passed with -race.
  • Full owning package tests passed for pkg/sql/plan/function, pkg/pb/plan,
    and pkg/sql/compile.
  • The distributed metadata BVT covers scalar values, CTAS/view metadata,
    UNION widening, NULL/empty input, and cleanup.
  • git diff --check passed.
  • GPT-6 medium final review passed:
    MO-ISSUE-TO-PR-FINAL-REVIEW-G6M-20260912-28738-46-47-r2.

The prior partition/logservice timeout CI failure was an embedded-cluster
heartbeat/connection failure and did not exercise ASCII code; it was unrelated
to this change.

Compatibility and performance

The algorithm is unchanged. Normal execution writes one 4-byte INT32 result
instead of a 1-byte UINT8 result, with no extra per-row lookup or scan. Legacy
plans remain usable and the protocol fence prevents a new INT32 result contract
from reaching an older peer.

@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 11, 2026
@mergify mergify Bot added the kind/bug Something isn't working label Sep 11, 2026
@XuPeng-SH
XuPeng-SH force-pushed the codex/issue-28455-ascii branch from a9d64b5 to f962643 Compare September 12, 2026 01:43

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

Reviewed head 4bcaae0217cc961574bca46d37c11672f55bdfd4 against base 10ce23e7423d690ece19098e39a78b17236aa771 with GPT-6 (Astra), medium reasoning.

No blocking issue found. The direction is appropriate for the reported metadata bug: all 11 ASCII overloads now advertise and produce signed INT32 while preserving their serialized overload identities.

Review covered the complete diff and these behavioral closures:

  • Registry -> expression result allocation -> string/signed/unsigned execution -> CTAS/view/UNION consumers. Result wrappers are allocated from the expression's declared type, so the UINT8 compatibility branch also matches how legacy plans actually execute. First-byte/numeric conversion algorithms, NULL handling and selection behavior remain unchanged.
  • Serialized expression feature detection -> remote sender -> receiver. The v65 check includes the result type, rejects the new physical contract below v65, and leaves UINT8 ASCII plans admissible. The protocol tests cover rejection before sending, acceptance/decoding at v65, and receiver rejection below v65.
  • Boundary and performance review: empty strings, NULL and multibyte first bytes are covered in the public case; integer overload IDs remain stable. The normal result payload grows from 1 to 4 bytes per row, but the patch introduces no additional per-row scan, allocation, retry, shared mutable state, or wait. Feature detection extends the existing expression traversal.
  • Tests preserve prior value checks and add overload metadata, legacy wrappers, compatibility fencing, and SQL/catalog metadata checks with small deterministic data and teardown.

Validation reused: this head's successful CI run 34681512840, including SCA, UT, UT Coverage, shared build, and both enabled multi-CN BVT configurations; the PR also records focused normal/race and owning-package results. This review did not rerun those suites locally. The head and open state were rechecked before submission.

Posting COMMENT because this is the requesting user's own PR; the review recommendation is no blocker.

@XuPeng-SH
XuPeng-SH merged commit 8074b4c into matrixorigin:main Sep 12, 2026
20 checks passed
@XuPeng-SH
XuPeng-SH deleted the codex/issue-28455-ascii branch September 12, 2026 09:08
XuPeng-SH added a commit that referenced this pull request Sep 12, 2026
## What type of PR is this?

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

## Which issue(s) this PR fixes:

Closes #28665

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

`GROUP_CONCAT()` truncation diagnostics used local
aggregate-finalization order as the warning row number. With multiple
groups, partial aggregation, or spill/rebuild, that order can differ
from input order, so the result can be correct while `SHOW WARNINGS`
reports the wrong source row.

The fix carries source-row metadata across batches, ordered and
unordered DISTINCT state, partial merges, and local spill/rebuild. It
combines warnings across spill buckets before publication and preserves
existing H0/single-group behavior and NULL handling.

Distributed provenance is explicit. Independent remote CN processes mark
their row ordinals untrusted instead of exporting local ordinals. The
coordinator and legacy readers fall back to a deterministic aggregate
ordinal domain for untrusted or marker-free partials, including empty
and NULL-only partials. Mixed state is never re-exported with partially
trusted row metadata.

Upstream main now contains #28746, which assigns MORPC v65 to ASCII's
signed INT result. This PR uses MORPC v66 for the GROUP_CONCAT
source-row diagnostics extension and gates the payload and provenance
marker on v66. The duplicate ASCII compatibility commit is no longer
part of this branch.

## Validation

- Rebased on current upstream `main` at
`0d701bb966f3dbc313d6659baec1c47762d1c186`; MORPC v65 remains assigned
to ASCII and GROUP_CONCAT metadata requires v66.
- Before this latest rebase, targeted GROUP_CONCAT and ASCII tests
passed in `pkg/sql/colexec/aggexec`, `pkg/sql/colexec/group`,
`pkg/vm/process`, `pkg/sql/compile`, and `pkg/sql/plan/function`;
`TestIssue28665WarningRowsFollowInputOrder` passed in
`pkg/tests/issues`.
- At current head `6551997865b616b07fa50eecf53e2c124604b604`, GPT-6
medium final review passed and `git diff --check` passed. CI reruns are
in progress; local runtime tests were not rerun after this rebase.
- Before this rebase, the full UT suites for `pkg/sql/colexec/aggexec`,
`pkg/sql/colexec/group`, `pkg/vm/process`, `pkg/sql/compile`,
`pkg/sql/plan/function`, and `pkg/pb/plan` passed; the public
distributed BVT, focused `-race` cases, `make cgo -j12`, and incremental
`golangci-lint --new-from-rev=origin/main` also passed.
- A previous same-head CI run had one
`TestIssue26640ClusterRestoreRebindsSubscriptionPrivileges` deadline
failure; the same test passed on the next run of that exact SHA and in
another run. Issue #28763 tracks this intermittent restore-test
behavior. That later run failed overall in the separate
`TestBackupProtectionCheckpointProtection` case; that checkpoint timeout
is not classified as flaky.

## Compatibility and performance

The local path adds a small state-level marker at the v66 partial
boundary. Trusted local values retain source rows; remote or legacy
mixed states use a bounded fallback counter. No new goroutine, RPC wait,
or unbounded retention path is introduced.
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## What type of PR is this?

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

## Which issue(s) this PR fixes:

Fixes matrixorigin#28455

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

`ASCII()` returned the correct byte value but exposed `TINYINT UNSIGNED`
metadata. That leaks into CTAS, views, UNION/set-operation type
resolution,
prepared consumers, and client metadata; MySQL exposes the result as
signed
`INT`.

The function registry now declares all ASCII overloads as signed
`T_int32` and
the normal executor writes INT32 results. A compatibility path retains
legacy
UINT8 function-result wrappers and old serialized plans. A MORPC v65
feature
fence rejects a new INT32 ASCII plan when the peer cannot decode it,
while new
peers continue to accept legacy plans.

## Validation

- Rebased onto `origin/main` at
`efb2c5084957ac90273a3f625668fc6a784562c4`.
- Isolated `make cgo -j12` completed.
- Focused ASCII executor, legacy-wrapper, plan-feature, and
remote-protocol
tests passed; the corresponding focused suites also passed with `-race`.
- Full owning package tests passed for `pkg/sql/plan/function`,
`pkg/pb/plan`,
  and `pkg/sql/compile`.
- The distributed metadata BVT covers scalar values, CTAS/view metadata,
  UNION widening, NULL/empty input, and cleanup.
- `git diff --check` passed.
- GPT-6 medium final review passed:
  `MO-ISSUE-TO-PR-FINAL-REVIEW-G6M-20260912-28738-46-47-r2`.

The prior partition/logservice timeout CI failure was an
embedded-cluster
heartbeat/connection failure and did not exercise ASCII code; it was
unrelated
to this change.

## Compatibility and performance

The algorithm is unchanged. Normal execution writes one 4-byte INT32
result
instead of a 1-byte UINT8 result, with no extra per-row lookup or scan.
Legacy
plans remain usable and the protocol fence prevents a new INT32 result
contract
from reaching an older peer.
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## What type of PR is this?

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

## Which issue(s) this PR fixes:

Closes matrixorigin#28665

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

`GROUP_CONCAT()` truncation diagnostics used local
aggregate-finalization order as the warning row number. With multiple
groups, partial aggregation, or spill/rebuild, that order can differ
from input order, so the result can be correct while `SHOW WARNINGS`
reports the wrong source row.

The fix carries source-row metadata across batches, ordered and
unordered DISTINCT state, partial merges, and local spill/rebuild. It
combines warnings across spill buckets before publication and preserves
existing H0/single-group behavior and NULL handling.

Distributed provenance is explicit. Independent remote CN processes mark
their row ordinals untrusted instead of exporting local ordinals. The
coordinator and legacy readers fall back to a deterministic aggregate
ordinal domain for untrusted or marker-free partials, including empty
and NULL-only partials. Mixed state is never re-exported with partially
trusted row metadata.

Upstream main now contains matrixorigin#28746, which assigns MORPC v65 to ASCII's
signed INT result. This PR uses MORPC v66 for the GROUP_CONCAT
source-row diagnostics extension and gates the payload and provenance
marker on v66. The duplicate ASCII compatibility commit is no longer
part of this branch.

## Validation

- Rebased on current upstream `main` at
`0d701bb966f3dbc313d6659baec1c47762d1c186`; MORPC v65 remains assigned
to ASCII and GROUP_CONCAT metadata requires v66.
- Before this latest rebase, targeted GROUP_CONCAT and ASCII tests
passed in `pkg/sql/colexec/aggexec`, `pkg/sql/colexec/group`,
`pkg/vm/process`, `pkg/sql/compile`, and `pkg/sql/plan/function`;
`TestIssue28665WarningRowsFollowInputOrder` passed in
`pkg/tests/issues`.
- At current head `6551997865b616b07fa50eecf53e2c124604b604`, GPT-6
medium final review passed and `git diff --check` passed. CI reruns are
in progress; local runtime tests were not rerun after this rebase.
- Before this rebase, the full UT suites for `pkg/sql/colexec/aggexec`,
`pkg/sql/colexec/group`, `pkg/vm/process`, `pkg/sql/compile`,
`pkg/sql/plan/function`, and `pkg/pb/plan` passed; the public
distributed BVT, focused `-race` cases, `make cgo -j12`, and incremental
`golangci-lint --new-from-rev=origin/main` also passed.
- A previous same-head CI run had one
`TestIssue26640ClusterRestoreRebindsSubscriptionPrivileges` deadline
failure; the same test passed on the next run of that exact SHA and in
another run. Issue matrixorigin#28763 tracks this intermittent restore-test
behavior. That later run failed overall in the separate
`TestBackupProtectionCheckpointProtection` case; that checkpoint timeout
is not classified as flaky.

## Compatibility and performance

The local path adds a small state-level marker at the v66 partial
boundary. Trusted local values retain source rows; remote or legacy
mixed states use a bounded fallback counter. No new goroutine, RPC wait,
or unbounded retention path is introduced.
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## What type of PR is this?

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

## Which issue(s) this PR fixes:

Fixes matrixorigin#28455

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

`ASCII()` returned the correct byte value but exposed `TINYINT UNSIGNED`
metadata. That leaks into CTAS, views, UNION/set-operation type
resolution,
prepared consumers, and client metadata; MySQL exposes the result as
signed
`INT`.

The function registry now declares all ASCII overloads as signed
`T_int32` and
the normal executor writes INT32 results. A compatibility path retains
legacy
UINT8 function-result wrappers and old serialized plans. A MORPC v65
feature
fence rejects a new INT32 ASCII plan when the peer cannot decode it,
while new
peers continue to accept legacy plans.

## Validation

- Rebased onto `origin/main` at
`efb2c5084957ac90273a3f625668fc6a784562c4`.
- Isolated `make cgo -j12` completed.
- Focused ASCII executor, legacy-wrapper, plan-feature, and
remote-protocol
tests passed; the corresponding focused suites also passed with `-race`.
- Full owning package tests passed for `pkg/sql/plan/function`,
`pkg/pb/plan`,
  and `pkg/sql/compile`.
- The distributed metadata BVT covers scalar values, CTAS/view metadata,
  UNION widening, NULL/empty input, and cleanup.
- `git diff --check` passed.
- GPT-6 medium final review passed:
  `MO-ISSUE-TO-PR-FINAL-REVIEW-G6M-20260912-28738-46-47-r2`.

The prior partition/logservice timeout CI failure was an
embedded-cluster
heartbeat/connection failure and did not exercise ASCII code; it was
unrelated
to this change.

## Compatibility and performance

The algorithm is unchanged. Normal execution writes one 4-byte INT32
result
instead of a 1-byte UINT8 result, with no extra per-row lookup or scan.
Legacy
plans remain usable and the protocol fence prevents a new INT32 result
contract
from reaching an older peer.
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## What type of PR is this?

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

## Which issue(s) this PR fixes:

Closes matrixorigin#28665

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

`GROUP_CONCAT()` truncation diagnostics used local
aggregate-finalization order as the warning row number. With multiple
groups, partial aggregation, or spill/rebuild, that order can differ
from input order, so the result can be correct while `SHOW WARNINGS`
reports the wrong source row.

The fix carries source-row metadata across batches, ordered and
unordered DISTINCT state, partial merges, and local spill/rebuild. It
combines warnings across spill buckets before publication and preserves
existing H0/single-group behavior and NULL handling.

Distributed provenance is explicit. Independent remote CN processes mark
their row ordinals untrusted instead of exporting local ordinals. The
coordinator and legacy readers fall back to a deterministic aggregate
ordinal domain for untrusted or marker-free partials, including empty
and NULL-only partials. Mixed state is never re-exported with partially
trusted row metadata.

Upstream main now contains matrixorigin#28746, which assigns MORPC v65 to ASCII's
signed INT result. This PR uses MORPC v66 for the GROUP_CONCAT
source-row diagnostics extension and gates the payload and provenance
marker on v66. The duplicate ASCII compatibility commit is no longer
part of this branch.

## Validation

- Rebased on current upstream `main` at
`0d701bb966f3dbc313d6659baec1c47762d1c186`; MORPC v65 remains assigned
to ASCII and GROUP_CONCAT metadata requires v66.
- Before this latest rebase, targeted GROUP_CONCAT and ASCII tests
passed in `pkg/sql/colexec/aggexec`, `pkg/sql/colexec/group`,
`pkg/vm/process`, `pkg/sql/compile`, and `pkg/sql/plan/function`;
`TestIssue28665WarningRowsFollowInputOrder` passed in
`pkg/tests/issues`.
- At current head `6551997865b616b07fa50eecf53e2c124604b604`, GPT-6
medium final review passed and `git diff --check` passed. CI reruns are
in progress; local runtime tests were not rerun after this rebase.
- Before this rebase, the full UT suites for `pkg/sql/colexec/aggexec`,
`pkg/sql/colexec/group`, `pkg/vm/process`, `pkg/sql/compile`,
`pkg/sql/plan/function`, and `pkg/pb/plan` passed; the public
distributed BVT, focused `-race` cases, `make cgo -j12`, and incremental
`golangci-lint --new-from-rev=origin/main` also passed.
- A previous same-head CI run had one
`TestIssue26640ClusterRestoreRebindsSubscriptionPrivileges` deadline
failure; the same test passed on the next run of that exact SHA and in
another run. Issue matrixorigin#28763 tracks this intermittent restore-test
behavior. That later run failed overall in the separate
`TestBackupProtectionCheckpointProtection` case; that checkpoint timeout
is not classified as flaky.

## Compatibility and performance

The local path adds a small state-level marker at the v66 partial
boundary. Trusted local values retain source rows; remote or legacy
mixed states use a bounded fallback counter. No new goroutine, RPC wait,
or unbounded retention path is introduced.
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## What type of PR is this?

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

## Which issue(s) this PR fixes:

Fixes matrixorigin#28455

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

`ASCII()` returned the correct byte value but exposed `TINYINT UNSIGNED`
metadata. That leaks into CTAS, views, UNION/set-operation type
resolution,
prepared consumers, and client metadata; MySQL exposes the result as
signed
`INT`.

The function registry now declares all ASCII overloads as signed
`T_int32` and
the normal executor writes INT32 results. A compatibility path retains
legacy
UINT8 function-result wrappers and old serialized plans. A MORPC v65
feature
fence rejects a new INT32 ASCII plan when the peer cannot decode it,
while new
peers continue to accept legacy plans.

## Validation

- Rebased onto `origin/main` at
`efb2c5084957ac90273a3f625668fc6a784562c4`.
- Isolated `make cgo -j12` completed.
- Focused ASCII executor, legacy-wrapper, plan-feature, and
remote-protocol
tests passed; the corresponding focused suites also passed with `-race`.
- Full owning package tests passed for `pkg/sql/plan/function`,
`pkg/pb/plan`,
  and `pkg/sql/compile`.
- The distributed metadata BVT covers scalar values, CTAS/view metadata,
  UNION widening, NULL/empty input, and cleanup.
- `git diff --check` passed.
- GPT-6 medium final review passed:
  `MO-ISSUE-TO-PR-FINAL-REVIEW-G6M-20260912-28738-46-47-r2`.

The prior partition/logservice timeout CI failure was an
embedded-cluster
heartbeat/connection failure and did not exercise ASCII code; it was
unrelated
to this change.

## Compatibility and performance

The algorithm is unchanged. Normal execution writes one 4-byte INT32
result
instead of a 1-byte UINT8 result, with no extra per-row lookup or scan.
Legacy
plans remain usable and the protocol fence prevents a new INT32 result
contract
from reaching an older peer.

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

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.

[Compatibility]: ASCII exposes TINYINT UNSIGNED result metadata instead of MySQL INT

2 participants