Skip to content

Correct numeric COALESCE metadata during PREPARE - #30035

Merged
XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
iamlinjunhong:fix/29977-prepare-coalesce-metadata
Oct 12, 2026
Merged

XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
iamlinjunhong:fix/29977-prepare-coalesce-metadata

Conversation

@iamlinjunhong

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:

The issue remains open for reporter verification after merge.

What this PR does / why we need it:

A fresh server-side prepared SELECT COALESCE(?, CAST(0 AS DECIMAL(20,6))) reports VARCHAR to JDBC before execution, then DECIMAL after execution. The unresolved parameter's TEXT transport type selects the string COALESCE overload during PREPARE.

Infer the initial numeric result domain from all concrete numeric COALESCE operands through the existing common-type resolver. Wrap direct unresolved markers in provisional implicit casts so PREPARE exposes numeric metadata while EXECUTE continues to bind actual parameter sources. Preserve concrete string/binary operands, all-unknown operands, explicit casts, and existing runtime conversion behavior; fall back to ordinary binding when the numeric peer union is unsupported.

Validation on macOS arm64, Go 1.27.1, CPU native build:

  • Reproduced the original pre-execution VARCHAR metadata through COM_STMT_PREPARE and real Connector/J 8.4.0; the numeric metadata assertion fails on the baseline.
  • Focused planner and wire metadata regressions pass, covering operand order, numeric types, multiple markers/peers, NULL, string boundaries, unsupported numeric unions, provisional cast provenance, and immutable template specialization.
  • Full pkg/sql/plan and pkg/frontend tests pass with the repository CGo wrapper; incremental gofmt, vet, and repository-pinned lint pass.
  • A locally built isolated service passes the JDBC regression: metadata before binding and before/after execution, DECIMAL/NULL/string bindings, handle reuse, explicit CAST and string/all-unknown controls, exact numeric values, and connection health. The probe is included under test/manual/issue29977.

The added work is bounded by the argument count during PREPARE, with no per-row work or new persistent/session state. MySQL precision/scale parity and propagation through nested marker-only expressions remain outside this focused fix. CI is pending.

@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 commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: 979a09fd12e1b7ec1909cfd73f72abddf986b558

Assessment: approve

Reviewed the complete six-file delta and affected PREPARE, EXECUTE and wire-metadata paths. Numeric inference reuses the existing resolver, remains provisional, and preserves runtime parameter ownership. No actionable defects remain within the stated scope.

Model: gpt-6-astra / xhigh

Session: 01a12d8f-7dea-77c2-a565-38d45b5564e4 · slot 0 · generation 0

Validation:

  • Verified the frozen HEAD, clean checkout and passing git diff --check.

  • Traced numeric-peer inference, NULL/string/binary boundaries, unsupported-union fallback, provisional-cast removal and immutable template specialization.

  • Reviewed planner regressions, binary-protocol metadata assertions and the JDBC probe's value, metadata, reuse, timeout and cleanup checks.

  • Reused exact-head successful UT, SCA, build and BVT CI evidence, plus author-reported owning-package tests and baseline-failing/fixed-passing Connector/J 8.4.0 validation.

  • Recorded the change map and evidence in review-notes.json.

Limitations:

  • No local runtime tests were repeated; the JDBC execution evidence is author-reported.

  • The linked issue body was not supplied; requirements were assessed from the frozen PR description and regression artifacts.

  • MySQL precision/scale parity and propagation through nested marker-only expressions remain outside this focused fix.

@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: 979a09fd12e1b7ec1909cfd73f72abddf986b558

Assessment: approve

Reviewed the complete six-file delta and affected PREPARE, EXECUTE and wire-metadata paths. Numeric inference reuses the existing resolver, remains provisional, and preserves runtime parameter ownership. No actionable defects remain within the stated scope.

Model: gpt-6-astra / xhigh

Session: 01a12d8f-7dea-77c2-a565-38d45b5564e4 · slot 0 · generation 0

Validation:

  • Verified the frozen HEAD, clean checkout and passing git diff --check.

  • Traced numeric-peer inference, NULL/string/binary boundaries, unsupported-union fallback, provisional-cast removal and immutable template specialization.

  • Reviewed planner regressions, binary-protocol metadata assertions and the JDBC probe's value, metadata, reuse, timeout and cleanup checks.

  • Reused exact-head successful UT, SCA, build and BVT CI evidence, plus author-reported owning-package tests and baseline-failing/fixed-passing Connector/J 8.4.0 validation.

  • Recorded the change map and evidence in review-notes.json.

Limitations:

  • No local runtime tests were repeated; the JDBC execution evidence is author-reported.

  • The linked issue body was not supplied; requirements were assessed from the frozen PR description and regression artifacts.

  • MySQL precision/scale parity and propagation through nested marker-only expressions remain outside this focused fix.

@mergify mergify Bot added the queued label Oct 12, 2026
@mergify

mergify Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-12 19:20 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-10-12 20:27 UTC · at 3b76e9a5942cec1bf322a07516f123361eed415f

This pull request spent 1 hour 6 minutes 54 seconds in the queue, with no time running CI.

Reason

Pull request #30035 has been dequeued

Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.

The author needs to enable "Allow edits from maintainers" on this pull request.

Hint

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.
If you do update this pull request, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Waiting for any of
  • check-neutral = CI Required
  • check-skipped = CI Required
  • check-success = CI Required
All conditions

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

  • Requeue this pull request

This branch was previously deployed

1 inactive deployment
ci — 3b76e9a5 Deployed Oct 12, 2026 by mergify[bot]
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.

3 participants