Skip to content

fix: align explicit CAST overflow behavior with MySQL - #25898

Merged
mergify[bot] merged 12 commits into
matrixorigin:mainfrom
ck89119:issue-25252-main
Jul 21, 2026
Merged

mergify[bot] merged 12 commits into
matrixorigin:mainfrom
ck89119:issue-25252-main

Conversation

@ck89119

@ck89119 ck89119 commented Jul 20, 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 #25252

What this PR does / why we need it:

Explicit SQL CAST and CONVERT expressions previously reused the ordinary internal cast overload, whose strict overflow errors differ from MySQL's explicit-cast behavior.

This change:

  • routes only MySQL SIGNED, UNSIGNED, and DECIMAL cast targets through a dedicated overload, keeping MatrixOne extension integer targets and planner-inserted casts unchanged;
  • applies MySQL-compatible signed/unsigned overflow handling across string, integer, float, Decimal64, Decimal128, and Decimal256 sources;
  • clamps explicit decimal casts across Decimal64, Decimal128, and Decimal256 target precisions;
  • preserves errors for invalid numeric strings;
  • adds planner/function unit tests, column-vector coverage, extension-target regression tests, and BVT coverage for the reported cases and boundaries.

User impact: overflow cases such as large integer strings, negative-to-unsigned casts, and oversized decimals now produce MySQL-compatible values without changing existing strict semantics for implicit casts or MatrixOne extension integer targets.

Validation:

  • go test ./pkg/sql/plan/function ./pkg/sql/plan
  • go test -race ./pkg/sql/plan/function ./pkg/sql/plan
  • go vet ./pkg/sql/plan/function ./pkg/sql/plan
  • make build
  • func_cast.test BVT: 226/226 passed
  • boundary_comprehensive.sql BVT: 241/241 passed
  • changed helper coverage: 75.0%-100%
  • git diff --check

@mergify mergify Bot added the kind/bug Something isn't working label Jul 20, 2026
@matrix-meow matrix-meow added the size/L Denotes a PR that changes [500,999] lines label Jul 20, 2026
@matrix-meow matrix-meow added size/XL Denotes a PR that changes [1000, 1999] lines and removed size/L Denotes a PR that changes [500,999] lines labels Jul 20, 2026
@mergify

mergify Bot commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-07-21 06:06 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🚫 Left the queue — 2026-07-21 06:51 UTC · at fe95b262dd5177ef4af339ffb8a49b5b87b1155f

This pull request spent 44 minutes 51 seconds in the queue, with no time running CI.

Reason

The pull request can't be updated

For security reasons, Mergify can't update this pull request. Try updating locally.
GitHub response: refusing to allow a GitHub App to create or update workflow .github/workflows/iceberg-connector.yml without workflows permission

Hint

You should update or rebase your pull request manually. If you do, this pull request will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Requeued — the merge queue status continues in this comment ↓.

@mergify mergify Bot added dequeued and removed queued labels Jul 21, 2026
@mergify

mergify Bot commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-07-21 08:04 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • ✅ Checks skipped · PR is already up-to-date
  • ✅ Merged — 2026-07-21 08:05 UTC · at 6b4eb5f6fdd1065189fb58a9ba7844cfc5f93293 · squash

This pull request spent 44 seconds in the queue, including 2 seconds running CI.

Required conditions to merge
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection] (documentation)
  • github-review-decision = APPROVED [🛡 GitHub branch protection] (documentation)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-neutral = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-skipped = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Utils CI / Coverage
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / SCA Test on Linux/arm64
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64

@mergify
mergify Bot merged commit 3046f14 into matrixorigin:main Jul 21, 2026
24 of 25 checks passed
@mergify mergify Bot removed the queued label Jul 21, 2026
@ck89119
ck89119 deleted the issue-25252-main branch July 21, 2026 08:09

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/XL Denotes a PR that changes [1000, 1999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: CAST overflow handling differs from MySQL clamp/wrap behavior

3 participants