Skip to content

[Bug]: mo-dump SQL cannot restore max finite FLOAT and loses signed zero #30598

Closed
matrixorigin/mo_dump
#58

Description

@Ariznawlll

Description

The SQL dump of a valid near-maximum finite FLOAT value is marked successful but cannot be restored: the emitted numeric literal is rejected as out of range. The same raw-numeric serialization also loses the sign of stored negative zero. CSV/LOAD DATA LOCAL INFILE roundtrips both values on this commit.

Environment

  • MatrixOne main: 75ff736835c3d00d40dc00a0a1d3b11129388e5b
  • mo_dump main: 324c33dbdc7075cd5d7beaafd1e15c76709dd442
  • Isolated single LOG/TN/CN deployment; MySQL-protocol client.

Reproduce

CREATE DATABASE md_float_boundary_src;
CREATE TABLE md_float_boundary_src.t (id INT PRIMARY KEY, f FLOAT, d DOUBLE);
INSERT INTO md_float_boundary_src.t VALUES
  (1, CAST('-0.0' AS FLOAT), CAST('-0.0' AS DOUBLE)),
  (2, CAST('1e-45' AS FLOAT), CAST('5e-324' AS DOUBLE)),
  (3, CAST('3.4028234e38' AS FLOAT), CAST('1.7976931348623157e308' AS DOUBLE)),
  (4, CAST('-1e-45' AS FLOAT), CAST('-5e-324' AS DOUBLE));

Export with mo-dump -db md_float_boundary_src > dump.sql; retarget only the database name in a copy before importing into an empty database. The dump's data line includes (1,-0,-0) and (3,3.4028235e+38,1.7976931348623157e+308).

Actual / expected

  • Three independent fresh source databases: full SQL export exits 0 with MODUMP SUCCESS 3/3; restore fails ERROR 1690 (22003): data out of range: data type float32, value '3.4028235e+38' at the INSERT 3/3, leaving each recreated table empty. Sources remain four rows and the connection is usable.
  • The source accepts CAST('3.4028234e38' AS FLOAT) and retains the max finite float32 value. CAST('3.4028235e+38' AS FLOAT) also succeeds, but parsing the emitted unquoted numeric literal 3.4028235e+38 as FLOAT fails. A restorable dump must preserve the source value or fail export explicitly.
  • Filtering the same three dumps to id=1 (negative zero only) makes SQL restore succeed 3/3, but both FLOAT and DOUBLE change from source display -0 to restored display 0 3/3. The full CSV exports restore -0 for both columns in all three targets. This is a silent roundtrip representation loss, not the out-of-range error.

Controls and code

  • The same three sources exported to CSV and restored 3/3; each target has four rows, with zero null-safe numeric mismatches for FLOAT/DOUBLE. CSV displays the negative zero sign and max finite FLOAT like the sources.
  • SQL dump filtered to rows 1, 2 and 4 (no max FLOAT) imports; all three numeric row values compare equal, although row 1 loses the sign of zero as noted above.
  • cmd/mo-dump/main.go:739-759 emits finite FLOAT/DOUBLE wire-text values as bare numeric SQL literals. The source wire text for the max FLOAT is rounded to 3.4028235e+38, which is not a safe numeric literal for reinsertion on this server; -0 is parsed as unsigned-signless integer zero. A type-aware, roundtrip-safe representation is needed.

Regression / related

Add real SQL and CSV dump/restore cases for max finite FLOAT, min positive/negative subnormals, signed zero, max finite DOUBLE, and NULL. This is distinct from #30596, where unquoted DOUBLE NaN/Inf causes a different parser error, and from #30521, which concerns general text-wire notation.

Activity

  1. added this to the MO-202610 milestone on Oct 19, 2026
  2. added
    kind/bug
    on Oct 19, 2026
  3. added theissue type on Oct 19, 2026
  4. assigned and unassigned on Oct 26, 2026
  5. slyunnn commented on Oct 27, 2026

    @slyunnn

    Regression and extended verification for #30598 (2026-10-27)

    Verification Environment

    • MatrixOne latest main: 2465dae7a4ada1b277113cca5afff6fe10149b96 — refactor: consolidate unused code and bookkeeping cleanup (#31348); rebuilt binary git_version() was 2465dae7a4 on all routes.
    • mo-dump latest main: d9d6375512620f12ff371b8602cc1d10d6f6caa0 — fix: make SQL/CSV dump scripts restore-safe (#30596 #30598 #30587 #30590 #30628 #30481) (#58). Associated fix: mo_dump PR #58.
    • Isolated topology: 2 CN / 1 TN / 1 Log service / Proxy. Container endpoints Proxy 6001, CN1 16001, CN2 16002 were mapped to host 6601, 16601, 16602; all three were connected and tested independently.
    • Export used the mo-dump MySQL driver; restore used native mysql 9.7.1 over the MySQL text protocol.

    What Was Covered

    • OK — Four source rows covered negative zero in FLOAT and DOUBLE, positive and negative minimum subnormals, maximum finite FLOAT, and maximum finite DOUBLE.
    • OK — SQL dump and native-client restore completed with exit 0 on Proxy, CN1, and CN2; the earlier max-FLOAT out-of-range error did not recur.
    • OK — Source and restored formatted values matched on all 3 routes, including -0 in both types.
    • OK — Source and restored HEX(SERIAL(f)) / HEX(SERIAL(d)) matched exactly for all 4 rows on all 3 routes, providing a bit-sensitive representation check beyond numeric equality.
    • Not covered — Other floating-point payloads and large row counts; they are not needed for these scalar boundary defects.

    Findings

    The tested SQL serializer now emits restorable values without losing signed zero or overflowing maximum finite FLOAT. Large-data regression required: No; this is a numeric encoding boundary, covered by the minimum 4-row type/value matrix.

    MOTR / BVT Coverage

    The owning mo_dump repository's full make test passed at the tested commit, and live export/native-client restore passed through all 3 routes. No duplicate SQL-only MOTR case was added because the dump text and CLI restore status are part of the contract.

    Final Conclusion

    Fixed for #30598 on the tested revisions. No issue-specific PR was created.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bug

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions