Skip to content

fix: sql_mode-safe float specials, string and bit literals, LOAD DATA escaping - #60

Closed
aptend wants to merge 1 commit into
mainfrom
fix-sql-serialization-30596-30598-30590-30587
Closed

aptend wants to merge 1 commit into
mainfrom
fix-sql-serialization-30596-30598-30590-30587

Conversation

@aptend

@aptend aptend commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

What

  • matrixone#30596 — convertValue treated double as plain numeric passthrough, so NaN/+Inf/-Inf were emitted as bare SQL tokens and restore failed at the first INSERT (ambiguous column reference 'NaN'). float and double now share one boundary-aware formatter: special values stay quoted.
  • matrixone#30598 — near-max FLOAT wire text (3.4028235e+38, above MaxFloat32) restores as an unquoted literal → data out of range; -0 for float/double loses its sign as a bare numeric. Both are now emitted as quoted literals, which the restore cast reproduces exactly (same path proven by the passing CSV roundtrip in the issue).
  • matrixone#30590 — showLoad interpolated the CSV path and the field delimiter raw into single-quoted LOAD DATA literals. They are now emitted with doubled-quote escaping (sql_mode-independent). A backslash field delimiter has no portable literal form (it parses differently with/without NO_BACKSLASH_ESCAPES) and is now rejected at validation instead of succeeding with an unparsable script.
  • matrixone#30587 — string literals relied on backslash escapes (\\, \'), which break under NO_BACKSLASH_ESCAPES. Literals are now sql_mode-independent: quotes are doubled and backslash bytes are carried by CHAR(92) inside CONCAT. BIT byte-0 uses the same trick with CHAR(0) pieces (also fixing a raw-quote-byte corruption in the old bit branch).

Tests

  • TestConvertValueFloatBoundary, TestConvertValueSqlModeSafe, TestConvertValueBit, TestSqlStringLiteral, TestCheckFieldDelimiterBackslash — all pass.
  • Note: Test_toCsvFields / Test_toCsvLine fail identically on clean main (escapeString already doubles backslashes there; this PR does not touch CSV value escaping).

Closes matrixorigin/matrixone#30596
Closes matrixorigin/matrixone#30598
Closes matrixorigin/matrixone#30590
Closes matrixorigin/matrixone#30587

… escaping

- matrixone#30596: DOUBLE NaN/+-Inf are no longer emitted as bare tokens
  (previously restore failed at the first INSERT); float/double specials
  are now quoted alike.
- matrixone#30598: near-max FLOAT wire text above MaxFloat32 is emitted
  as a quoted literal (unquoted it fails restore, out of range); -0 for
  float/double keeps its sign via quoting instead of numeric passthrough.
- matrixone#30590: LOAD DATA path and field-delimiter are interpolated
  as doubled-quote SQL literals; a backslash field delimiter (no portable
  literal form) is rejected at validation instead of a broken export.
- matrixone#30587: string literals no longer rely on backslash escapes:
  quotes are doubled and backslash bytes go through CHAR(92), so dumps
  restore with and without NO_BACKSLASH_ESCAPES; BIT NUL bytes use the
  same _binary-piece/CHAR(0) join (also fixing raw-quote corruption).

Tests: TestConvertValueFloatBoundary, TestConvertValueSqlModeSafe,
TestConvertValueBit, TestSqlStringLiteral, TestCheckFieldDelimiterBackslash.
(Test_toCsvFields/Test_toCsvLine failures are pre-existing on main:
escapeString already doubles backslashes; untouched here.)
@mergify

mergify Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

@aptend

aptend commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #58, which ships the same four fixes (#30596/#30598/#30590/#30587) in one commit and — unlike this unit-test-only branch — is live-validated end-to-end on dump/restore roundtrips in both sql_modes. The unit tests introduced here (float boundary, sql_mode-safe literal, bit literal, LOAD DATA literal, backslash-delimiter rejection) remain a useful regression matrix if a tests-only follow-up PR is wanted after #58 lands. Closing to avoid a textual conflict post-merge.

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

Labels

None yet

Projects

None yet

1 participant