Skip to content

fix: serialize FLOAT/DOUBLE NaN/±Inf via bit_cast so SQL dumps restore (matrixorigin/matrixone#30596) - #71

Merged
mergify[bot] merged 1 commit into
mainfrom
fix/astra-meow-30596
Oct 28, 2026
Merged

mergify[bot] merged 1 commit into
mainfrom
fix/astra-meow-30596

Conversation

@aptend

@aptend aptend commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Problem

After mo_dump#58 quoted the FLOAT/DOUBLE NaN/±Inf tokens and MatrixOne changed text-to-float semantics in strict sessions (matrixorigin/matrixone#31191), a mo-dump SQL script can no longer recreate stored IEEE special values: the default MySQL-compatible strict restore aborts at the first INSERT with

ERROR 1265 (01000): Data truncated for DOUBLE value: 'NaN'

and the target table stays empty. This is the end-to-end dump/restore regression tracked in matrixorigin/matrixone#30596; it is still reproducible on current mo_dump main and current MatrixOne main.

Change

  • Serialize the FLOAT/DOUBLE wire text NaN/+Inf/-Inf as bit_cast(unhex('<LE hex>') as <float|double>): the expression rebuilds the canonical IEEE word from raw bytes, so the strict-mode text rule does not apply. The hex words are fixed little-endian constants taken from the MatrixOne special-value fixtures; no row data is interpolated.
  • Unknown non-numeric wire text keeps the legacy quoted form.
  • Finite passthrough, -0 (cast form, from mo_dump#58) and NULL handling are unchanged; the CSV mode is unchanged.

Tests

  • UT cmd/mo-dump TestConvertValueFloatSpecials pins the serialization matrix: specials x float/double -> bit_cast tokens, unknown non-numeric text keeps quotes, a string column storing 'NaN' remains a plain string literal, -0 and float32-overflow wire text keep their cast forms, finite values pass through, NULL stays NULL. make test passes on this branch.
  • Live round-trip on a private single-node MatrixOne main build (MySQL text protocol; MariaDB 11.8.3 client):
    • the pre-fix binary (current mo_dump main) reproduces the failure: strict restore exits rc=1 with ERROR 1265 ... Data truncated for DOUBLE value: 'NaN', target rows 0, connection stays usable;
    • this branch restores 6/6 rows (NaN/+Inf/-Inf on FLOAT and DOUBLE, 1.25, -0, NULL) under the default strict session, with client-identical text rendering and value-level checks (NaN via <>self, +/-Inf by sign and magnitude), and a second export of the restored table emits a byte-identical INSERT row;
    • controls pass: CSV LOCAL INFILE round-trip 6/6, MATRIXONE_NATIVE session 6/6, a NO_BACKSLASH_ESCAPES session 6/6 (the script's sql_mode pin), and an intentionally quoted 'NaN' INSERT still raises 1265 with the same connection reusable afterwards.

Limits

Quoted 'NaN'/'+Inf'/'-Inf' literals abort strict-mode restores with
ERROR 1265 Data truncated since matrixorigin/matrixone#31191: the SQL
script fails at the first INSERT and the target stays empty, so nothing
of a stored IEEE special round-trips (matrixorigin/matrixone#30596).

Serialize the FLOAT/DOUBLE wire text of NaN/±Inf as
bit_cast(unhex('<LE hex>') as <float|double>) expressions that rebuild
the canonical IEEE word from raw bytes, so the strict-mode text rule
does not apply. The hex words are fixed little-endian constants taken
from the server's own special-value fixtures; no user data is
interpolated. Restore is verified live under the default strict,
MATRIXONE_NATIVE and NO_BACKSLASH_ESCAPES sessions.

Unknown non-numeric wire text keeps the legacy quoted form; finite
passthrough, -0 (cast form, mo_dump#58) and NULL handling are
unchanged; CSV mode is unchanged. The text wire carries no NaN payload
bits, so the canonical quiet-NaN word is restored — the same canonical
value the CSV roundtrip restores.

Tests: cmd/mo-dump TestConvertValueFloatSpecials (specials ×
float/double, unknown-text fallback, string-column 'NaN' stays quoted,
-0/float32-overflow cast forms, finite passthrough, NULL);
go test ./... passes. Live single-node round-trip on current MatrixOne
main: this branch restores 6/6 rows with identical text rendering and
a byte-identical second export, CSV LOCAL and native/NO_BACKSLASH
sessions pass, and the pre-fix dump still fails with ERROR 1265 while
the connection stays reusable.
@mergify

mergify Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

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

@mergify

mergify Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

✅ Merged into main as 4090716 at 08:12 UTC

1 min in the queue, less than a minute of it CI.

So far

Times in UTC · dashboard · how the merge queue works

@mergify mergify Bot added the queued label Oct 28, 2026
@aptend

aptend commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

Reviewed exact head 723f10618dfdde2ed17e5a76f90e2a2d9de7559c against 1fe1d16fe9f47467b395c8c50c44b2bb765ed074.

No blocking issues found; recommendation: APPROVE.

The six fixed IEEE words decode to the correct FLOAT/DOUBLE NaN and signed infinities and match MatrixOne's bit_cast behavior on the supported platforms. The change is confined to special-value SQL serialization; finite values, negative zero, NULL, string columns, the existing unknown-token fallback and the CSV path retain their prior behavior.

Validation:

  • Independently ran make test in a detached worktree at this head, using its pinned Go 1.26.4 toolchain and locally built native dependency; passed.
  • Focused conversion and INSERT-output tests passed: 5 roots, 28 test/subtest executions, no failures or skips. Independently decoded all six IEEE constants.
  • Audited and reused the author's real single-CN dump/restore evidence after matching relevant source files and the tested binary hash. It demonstrates the pre-fix strict-mode failure and successful restoration of all six rows with this fix, plus value checks, identical re-exported INSERTs, CSV/native/NO_BACKSLASH_ESCAPES controls and connection reuse after the expected legacy quoted-NaN error.

The stated limits are appropriate: these expressions target MatrixOne, and the text wire permits restoring a canonical NaN rather than preserving its payload bits. The live evidence is single-CN; this review does not claim a new multi-CN/Proxy run.

This comment records the review recommendation; it is not a GitHub approval.

@mergify
mergify Bot merged commit 4090716 into main Oct 28, 2026
2 checks passed
@mergify mergify Bot removed the queued label Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant