Skip to content

[4.2-dev] fix: preserve prepared numeric semantics for BIT casts - #26754

Merged
mergify[bot] merged 10 commits into
matrixorigin:4.2-devfrom
jiangxinmeng1:agent/backport-bit64-prepared-to-4.2-dev
Aug 6, 2026
Merged

mergify[bot] merged 10 commits into
matrixorigin:4.2-devfrom
jiangxinmeng1:agent/backport-bit64-prepared-to-4.2-dev

Conversation

@jiangxinmeng1

@jiangxinmeng1 jiangxinmeng1 commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • BUG
  • Test and CI

Which issue(s) this PR fixes:

Fixes #26740.

Follow-up for #26728 and backport of #26748 to 4.2-dev.

What this PR does / why we need it:

MatrixOne transports prepared parameters internally through a transient text vector. That transport erased the source conversion semantics before assignment to BIT(M), so the same value could be interpreted as ASCII bytes instead of a number.

This PR preserves the source conversion category across binary COM_STMT_EXECUTE, SQL EXECUTE USING, normal user-variable evaluation, process serialization, remote compile, and shard reads:

  • signed and unsigned integers, including YEAR, use numeric BIT conversion;
  • negative signed integers preserve their two-complement payload only for BIT(64);
  • FLOAT/DOUBLE round with the existing numeric BIT rules;
  • DECIMAL/NEWDECIMAL truncate the fractional part and keep exact uint64 range checks;
  • Boolean values convert to 0/1;
  • MYSQL_TYPE_BIT and string/blob parameters retain byte-string semantics;
  • INSERT IGNORE retains the existing zero/max adjustment policy.

The metadata uses the existing process transport with backward decoding for legacy/no-metadata and the prior integer-only layout. Mixed-commit shard reads use the versioned method and are rejected before execution.

Validation

  • real database/sql binary prepared coverage for signed/unsigned integers, MaxUint64, DOUBLE rebinding, strings, BIT(63), and INSERT IGNORE;
  • SQL PREPARE/EXECUTE USING and direct user-variable coverage for decimal, integer, string, Boolean, and BIT values;
  • frontend protocol/type classification, parameter reuse/reset, Process ownership/codec, remote compile, shard version gating, and typed cast boundary tests;
  • all affected package tests, focused embedded integration, go vet, golangci-lint, and git diff --check passed.

@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

Choose a reason for hiding this comment

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

Post-push review of exact head fbc2ecf found that the provenance model still closes only the integer subset of the underlying text-tunnel bug. A real database/sql binary prepared INSERT binding float64(5) to BIT(64) succeeds but stores 53 (ASCII 0x35), while numeric semantics require 5. This follows the same public path as setLong: MYSQL_TYPE_DOUBLE is decoded numerically, converted to canonical text, then loses its source category and falls into string-to-BIT byte semantics. Simply adding FLOAT/DOUBLE to isInteger would be wrong because floating BIT conversion rounds and rejects negative values instead of preserving a two-complement integer pattern; DECIMAL/NEWDECIMAL also have their own truncation/range rules. Please preserve the numeric source category (integer, floating, decimal) across the existing process/remote metadata boundary and dispatch to the corresponding BIT semantics, while keeping MYSQL_TYPE_BIT and string/blob types byte-oriented. Add a public DOUBLE prepared control plus typed classification/cast controls that distinguish integer -1, float -1, decimal fractions, and string "5".

@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 Aug 6, 2026
@XuPeng-SH XuPeng-SH changed the title [4.2-dev] fix: preserve signed prepared values for BIT(64) [4.2-dev] fix: preserve prepared numeric semantics for BIT casts Aug 6, 2026

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

Deep-reviewed exact head c0dda620ae76 after the final push in a fresh worktree. The earlier integer-only blocker is closed at the root: prepared values retain their source conversion category across binary execute, SQL EXECUTE USING, direct user-variable evaluation, Process/remote transport, reuse, and shard version gating. Integer, float, Decimal, and Boolean inputs now follow their corresponding typed BIT semantics, while MYSQL_TYPE_BIT and strings remain byte-oriented; INSERT IGNORE and signed BIT(64) behavior stay aligned with the direct numeric paths.

The post-push review also checked ownership/error cleanup, legacy metadata decoding, mixed-commit protection, malformed Decimal input, null/default zero-allocation paths, and stale metadata reset. Full affected-package tests, vet, lint, diff checks, focused metadata/cast tests, and the real database/sql embedded regression pass. No blocking findings remain.

@mergify

mergify Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-08-06 13:53 UTC · Rule: release-4.2 · triggered by rule Automatic queue on approval for release-4.2
  • ✅ Checks skipped · PR is already up-to-date
  • ✅ Merged — 2026-08-06 13:53 UTC · at c0dda620ae76b7e0d102a9583e377235eb054998 · squash

This pull request spent 22 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]
  • 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
  • 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 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 Utils CI / Coverage
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)

@mergify
mergify Bot merged commit 4066fff into matrixorigin:4.2-dev Aug 6, 2026
45 of 48 checks passed
@mergify mergify Bot removed the queued label Aug 6, 2026

This branch had an error being deployed

1 failed 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 kind/test-ci size/XL Denotes a PR that changes [1000, 1999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants