Skip to content

fix(transfer): coerce values across engines in Table Transfer, Data Sync and SQL export - #4381

Merged
datlechin merged 2 commits into
mainfrom
fix/streaming-transfer-audit
Nov 21, 2026
Merged

datlechin merged 2 commits into
mainfrom
fix/streaming-transfer-audit

Conversation

@datlechin

Copy link
Copy Markdown
Member

Summary

Three cross-engine value-correctness fixes from the #4269 audit (IE-04 plus two the audit review surfaced):

  • IE-04: Table Transfer coerced only bit strings across engines, writing booleans, MySQL zero-dates, zoned timestamps and PostgreSQL arrays raw. It now applies the same CrossEngineValueCoercer Object Copy uses, for every mapped column, whenever the source and target type families differ.
  • Compare & Sync had the same gap, a third fork of the coercion path: cross-engine Data Sync now coerces the same values. Same-engine sync is unchanged.
  • SQL export wrote decode('<hex>','hex') for every PostgreSQL-family engine; KingbaseES reads decode as Oracle's DECODE and Redshift has no bytea, so both restored wrong bytes. They now get '\x..'::bytea and from_hex(..), matching the app's measured CompareSQLLiteral.
  • The per-value coercion is now one shared static, so the three callers (Object Copy, Table Transfer, Data Sync) cannot drift apart again.

SQ-7's SQLite premise does not hold: SQLite already streams the source in bounded batches across Object Copy, Table Transfer and export, so none of them buffers the whole table.

Not in this PR (need a live server)

  • AM-2 (streaming MCP/assistant/export reads): the external read bridge never attempts the bounded read, and the drivers that materialise (Oracle, Snowflake, SQL Server) do not override the context-aware executeBoundedQuery, so the fix is per-driver streaming overrides that only a live server can verify.
  • SQ-7 Dameng (the one materialising SQL source, needs the native bridge), NQ-3 (Kafka), SQ-3 (Teradata) from Streaming and transfer: remaining audit items #4269.

Test plan

  • TableTransferServiceTests: PG boolean to MySQL TINYINT, MySQL zero-date to PostgreSQL NULL, PG timestamptz to MySQL DATETIME, PG array to MySQL JSON. Fail on main (written raw), pass here.
  • DataSyncScriptBuilderTests (DataSyncCrossEngineCoercionTests): the same four, plus a same-engine guard that a MySQL zero-date stays as it came rather than turning into NULL.
  • CrossEngineValueCoercerTests: the shared static matches the row coercer.
  • SQLExportBinaryLiteralTests: KingbaseES '\x..'::bytea, Redshift from_hex(..). postgresUsesDecode updated, since it pinned the buggy Redshift decode, to cover only the engines that take it.
  • build, Unit plan (the named suites), AllPlugins, lint.

Refs #4269

…ync and SQL export

Table Transfer and Data Sync coerced only bit strings across engines, so
booleans, MySQL zero-dates, zoned timestamps and PostgreSQL arrays were written
raw. Both now run the full CrossEngineValueCoercer Object Copy uses, through one
shared per-value helper. SQLite targets keep temporal text verbatim.

SQL export wrote decode('<hex>','hex') for every Postgres-family engine;
KingbaseES and Redshift restored it as the wrong bytes.

Refs #4269
@datlechin
datlechin merged commit c8d7869 into main Nov 21, 2026
11 checks passed
@datlechin
datlechin deleted the fix/streaming-transfer-audit branch November 21, 2026 02:23
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