Skip to content

fix(frontend): preserve direct integer function wire metadata - #29233

Merged
XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
XuPeng-SH:codex/issue-28909-wire-metadata
Sep 22, 2026
Merged

XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
XuPeng-SH:codex/issue-28909-wire-metadata

Conversation

@XuPeng-SH

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:

Addresses the direct SELECT / binary prepared follow-up in #28909.
Related prior fix: #28915.

What this PR does / why we need it:

#28915 corrected the persisted INT types of FIND_IN_SET and STRCMP, but result-set protocol metadata still exposed INT. MySQL 8.0.45 exposes signed BIGINT for direct calls. Persisted-schema validation alone did not cover this separate client contract.

  • Classify direct projected calls using their retained AST, so constant folding does not erase the presentation distinction. Allow aliases/parentheses and require signed int32 execution output.
  • Apply signed LONGLONG presentation (display lengths 3/2) only to MysqlColumns. Keep execution vectors, internal result ColDefs, View and CTAS schemas unchanged.
  • Use the same classification for normal results, prepare headers, cached headers, schema rebuilds and execute-time specialization. Existing row writers correctly widen the int32 carrier to eight-byte binary values.
  • Deliberately exclude stars, DISTINCT/grouping, set operations, enclosing expressions and forwarded derived/view columns. MySQL presentation varies with materialization in those cases; this PR does not claim complete compatibility for those other query shapes and does not auto-close the issue.

Validation

  • Reproduced both text and real binary prepared failures on main before the fix (expected BIGINT, actual INT).
  • Independently checked MySQL 8.0.45 with text protocol and actual COM_STMT_PREPARE/EXECUTE: BIGINT, signed int64 values 2, -1.
  • Public embedded-cluster regression passed (13.770s): constants, table arguments, parameter reuse across ASCII/UTF8/NULL transitions, neighboring INT column, ALTER TABLE rebuild, persisted View/CTAS INT metadata and CTAS values.
  • Frontend focused and neighboring prepared-metadata tests passed (1.337s). Covers cached/uncached headers, unchanged internal ColDefs, negative classification controls, and both binary row writers with exact negative/NULL/sentinel bytes.
  • Defensive DISTINCT/DISTINCTROW option guard regression passed (1.263s); DISTINCTROW SQL is currently rejected by the keyword table, so this does not add syntax support.
  • Repository-wide license header check passed (5,676 files, zero invalid); git diff --check passed. Remote CI is pending; no performance improvement is claimed. Work is bounded per output column at metadata construction, with no per-row classification or new shared state.
  • Independent GPT-6 medium design and final overall review completed; review corrections covered the option guard and test cleanup.
  • Incremental repository-configured golangci-lint on both changed packages passed with 0 issues.

Commands:

.agents/skills/mo-dev/scripts/mo-cgo-test -run '^TestIssue28909DirectFunctionWireMetadata$' -count=1 -timeout=8m ./pkg/tests/issues
.agents/skills/mo-dev/scripts/mo-cgo-test -run '^(TestDirectInteger|TestPreparedNumericFunctionBinaryProtocolMetadata|TestPreparedRankingWindowBinaryProtocolMetadata|TestPrepared.*GroupConcat)' -count=1 -timeout=5m ./pkg/frontend

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

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

GPT-6 high force review at exact head 4e9cf64 (base bbbfb70): substantive APPROVE. Formal review is COMMENT because this PR is self-authored.

The retained-AST classification correctly covers direct projected FIND_IN_SET/STRCMP with aliases, parentheses, and constant folding while excluding stars, DISTINCT, grouping, set operations, enclosing expressions, and forwarded derived/view columns. MysqlColumns presentation metadata is isolated from execution vectors, internal ColDefs, and View/CTAS schemas. Prepared initial/cache headers, schema rebuild, and execute-time specialization use the same classification, with error/generation handling preserved.

Binary writers, signed negative values, NULL bitmap, neighboring INT alignment, and actual COM_STMT_PREPARE/EXECUTE behavior are covered by the reviewed tests; frontend focused and full-package tests passed, and the public protocol regression passed twice. No new shared mutable state, lock, background task, or resource-lifecycle issue was found.

Current CI shared build is successful, while UT/SCA/BVT are still running and were not counted as passed. The explicitly excluded query shapes remain outside the claim, so this does not by itself close all of #28909. Coverage was not used as a criterion.

@XuPeng-SH
XuPeng-SH merged commit 27ffab6 into matrixorigin:main Sep 22, 2026
18 of 21 checks passed
@XuPeng-SH
XuPeng-SH deleted the codex/issue-28909-wire-metadata branch September 22, 2026 09:20
XuPeng-SH added a commit that referenced this pull request Sep 23, 2026
…29250)

## What type of PR is this?

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

## Which issue(s) this PR fixes:

Refs #29249. The ongoing engineering-quality task remains open.
Fixes #29244.
Related regression work: #29146/#29169, #29228, and IVF INCLUDE/AUTO
retry coverage.

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

Consolidate the confirmed findings from the recent-commit quality review
into this existing PR. Remove redundant work and unused state,
strengthen existing tests at their owning boundary, and fix the parity
harness's delayed validation rather than introducing parallel
frameworks.

| Finding | Change and preserved contract |
| --- | --- |
| Go generated-column regression duplicated SQL PREPARE BVT | Use actual
binary prepare/execute and rebind the same statement after DELETE,
without DDL. Keep direct/index/no-index controls and exact
stored/generated values. Existing BVT retains SQL PREPARE,
TRUNCATE/rebuild, and rollback coverage. Reuse the existing row helper.
|
| Unique-key proof carried provenance nobody consumed | Delete the
source enum, field, and assignments. Keep the proof wrapper,
binding/column identity, SQL-equality checks, and all
primary/secondary/nullable/partition guards. |
| Set-operation text queries repeated inside a prepared-reuse loop | Run
the semantic text matrix once per topology and keep the MINUS ALL alias
smoke outside the full matrix: 96 outer-predicate queries become 40.
Preserve distinct operators, HEX/LENGTH, LIMIT/no-LIMIT, 1/2 CN, remote
ownership, and both genuine prepared-reuse passes. |
| IVF final rows alone did not prove POST-to-exact fallback | Replace
the first standalone SELECT with executed EXPLAIN ANALYZE.
Operator-scoped checks require ANN output, empty filtered POST, nonempty
fallback, and final output. Keep both prepared executions and exact
rows. Regenerate the affected golden through the real BVT runner,
including observed VARCHAR metadata. No production instrumentation. |
| Sirius executed the whole campaign before validation and lost failure
diagnostics | Incrementally validate through a shared owner, compare
against native results as soon as available, stop at the first invalid
run, and retain sanitized failure diagnostics independently of
successful summary generation. Reject occupied output directories before
invoking a runner. |

Sirius failure reporting distinguishes stale directories from this
invocation's partial artifacts: a failed report write can still leave an
exclusively created `failure.json`, without overwriting an existing
diagnostic or following its symlink. Validation and result hashing share
the same schema/rows representation, so ignored fields cannot cause a
late serialization failure. Invalid retained UTF-8 is rejected before
another run; postexecution errors retain their actual counts instead of
being labeled configuration errors.

The implementation removes generic diagnostic revalidation, redundant
accessors and duplicate schedule/count checks. The CLI reuses its
immediately validated results for summary/artifact generation;
independent public summary/writer calls still validate mutable input.
Both use the same private calculation/writing bodies, with no cached
validation state or public skip-validation flag. This reduces repeated
work, not the total line count of the PR against main.

### Findings rechecked without speculative code changes

- Remote terminal test (#29224): the exact Done-count assertion is
coupled to the current fixture, but the recorded mutation proves it
catches the forbidden lifecycle branch. No equally strong simpler
observer was established without adding production hooks; retain it
rather than weaken the regression.
- Metadata paths (#29233): ordinary execution, prepare, rebuild, and
runtime-plan call sites own different lifecycle boundaries. Wire
metadata and stored metadata intentionally differ; preserved AST
identity also serves folded expressions. No additional compatibility
defect was proven, so do not add another provenance layer or claim all
MySQL expression shapes are covered.
- Malformed internal-plan guards and fulltext anchor tests: no
reachability/dead-code proof justifies deleting them. The fulltext
change also moves existing tests; line growth alone was not evidence of
duplicated coverage. Preserve correctness guards and shape-specific
cases.
- Superseded-path retirement remains an ongoing audit item in #29249,
not an identified removable implementation in this reviewed baseline. No
unsupported deletion is claimed here.

These dispositions account for the remaining review concerns in this PR;
they are not claims that hypothetical risks were fixed by adding code.

### Validation

Go 1.26.4, Linux amd64, verified CPU native artifacts:

- Binary generated-column integration: all three cases passed; existing
physical-assignment planner regression passed.
- Unique-key elimination and physical-equality filter-boundary planner
regressions passed.
- Reduced set-operation integration passed on 1 CN and 2 CN, including
remote ownership and both reuse passes (restored run: 29.764s).
- Mutation checks: removing the prepared integer assignment boundary
corrupted stored values in both binary cases while the direct control
passed; removing the set-operation equality barrier produced count 2
instead of 1 for the outer HEX predicate on both CN topologies. Both
mutations were restored and regressions passed again; neither mutation
is included.
- Actual Java mo-tester IVF case: two consecutive runs on the same ready
2-CN instance each passed 21/21 with 0 failures/ignored/abnormal. SQL
verified database teardown after each run, before the next. An initial
embedded-harness attempt failed CN-inventory readiness; passing runs
used an explicit authoritative readiness check, not SQL retries.
Temporary diagnostic harnesses are excluded.
- Planner package build, affected Go package vet, and configured
golangci-lint passed (0 issues). gofmt and git diff --check passed.
- Sirius Python suite passed (21 tests): first/k failure stop counts and
real CLI failure artifacts, both native-oracle arrival orders,
pending-result counters, malformed output/runner exceptions,
incomplete/duplicate/missing-native validation, input-copy isolation,
redaction, stale-output rejection, partial report failures, exclusive
diagnostic writes, process cleanup, and full 1,860-run
success/performance controls. CLI exits remain 0 for PASS, 2 for
complete performance-gate failure, and 1 for invalid evidence. Existing
cases were extended instead of duplicating whole suites.
- Real-subprocess boundary probes: an ignored result field containing
JSON `1e400` permits the full valid campaign and normal artifacts; a
retained lone surrogate stops after one invocation with
`invalid-output`, attempted=1/validated=0; invalid retained
configuration text invokes no runner. Injected report I/O and encoding
failures preserve attempted=validated=1860 and successfully write
diagnostics beside partial artifacts.
- Successful CLI campaign comparison against `dfc09bb778`: output
validations 3,720 → 1,860; parity comparisons 2,976 → 1,488; result
encodings 5,580 → 3,720. All four artifacts are byte-for-byte identical.
Early encoding and final digest encoding remain separate intentionally;
independent calls on returned mutable records still revalidate. This
measures operation counts, not elapsed-time or GPU performance.
- Final independent GPT-6 medium review approved the combined candidate,
diagnostic/serialization repair and CLI single-pass optimization, with
no unresolved material findings. Native-last failure identity and
partial-artifact reporting are tested; same-instance BVT evidence
remains valid for unchanged Go/BVT code.

The #29244 first-result reproduction previously invoked the runner 1,860
times before rejecting forbidden fallback. It now stops after one
invocation and emits only:

```json
{"attempted":1,"category":"invalid-output","route":"mo-native","sequence":1,"status":"invalid","validated":0}
```

This is CPU fake-runner evidence, not a GPU speedup or parity claim. The
shared incremental validator replaces the old delayed validation loop;
its route map serves both oracle comparison and duplicate detection. No
retry, checkpoint, parallel scheduler, or production diagnostic hook is
introduced.

Full repository BVT/CI and live GPU performance are not claimed. The
96-to-40 reduction is a query-count reduction, not a measured suite
wall-time speedup.

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.

2 participants