Skip to content

test(plan): pin padded binary default replay and dump fingerprint parity (#31066) - #31147

Closed
gouhongshen wants to merge 1 commit into
matrixorigin:mainfrom
gouhongshen:agent/issue-31066-main-c5c3f501
Closed

gouhongshen wants to merge 1 commit into
matrixorigin:mainfrom
gouhongshen:agent/issue-31066-main-c5c3f501

Conversation

@gouhongshen

@gouhongshen gouhongshen commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Note

Rebased onto the merged #31067 (4769417cd, "Fixes #31066"): main now
renders executable DDL defaults from the stored OriginString and keeps the
historical DUMP fingerprint rendering, which supersedes this branch's
previous competing re-quote implementation (whose padded BINARY restore
regression the review confirmed). The old head is e73f3a365c; this PR now
carries test-only additions on top of that merged fix: the padded-binary
replay/manifest-hash regression the review asked for, plus the e2e
default-text parity BVT pair.

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

Related to #31066

What this PR does / why we need it:

The once-escaped SHOW CREATE TABLE default fix for #31066 landed on main via
#31067, so this PR rebases onto it: the superseded re-quote implementation,
its ALTER parser-mode pin (already in #31067) and the tests it duplicated are
dropped. What remains is the coverage merged main still lacks, answering the
review's P2 request ("Preserve the original default representation for
assignment-padded binary values and add a replay/hash regression test"):

  • pkg/sql/plan/show_create_table_default_test.go
    (TestShowCreateReplayKeepsAssignmentPaddedBinaryDefault): binary(8) DEFAULT 'a' binds a NUL-padded Sval while the stored default SQL text
    stays 'a'. SHOW CREATE must print the stored text (the padded spelling
    must not leak into replayable DDL), replaying the printed DDL re-binds the
    same OriginString/Sval, a second SHOW cycle is idempotent, and the
    persisted schema-hash input of the replayed table stays equal to the
    source's, so a DUMP archive keeps loading into a target rebuilt from SHOW
    output.
  • pkg/frontend/table_dump_default_hash_test.go
    (TestTableDumpPaddedBinaryDefaultReplayHashMatchesManifest,
    TestTableDumpPaddedBinaryDefaultRejectsPaddedSpelling): the manifest/hash
    gate the P2 broke — the context-free replay render (dump/CDC/publication
    consumers) must not print the padded bound literal, a SHOW-replay rebuild of
    the target recomputes the manifest's schema hash and
    tableDumpRelationSchemaMatches accepts it, while the padding-spelling
    default text the superseded rendering produced binds the same default bytes
    but hashes differently and is rejected.
  • BVT test/distributed/cases/dml/show/show_create_table_default_quote.{sql,result}:
    SHOW CREATE prints the once-escaped defaults, the replayed DDL stores the
    same defaults, and information_schema column_default/hex values are
    identical between source and replayed tables — complementing the merged
    cases/ddl/show_create_table_default_quote pair with backslash, integer
    and NULL columns plus the catalog-parity checks.

Issue-to-test proof

  • Red/green at the defect: the same planner test fails on the superseded
    re-quote head e73f3a365c — it prints binary(8) DEFAULT 'a\0\0\0\0\0\0\0'
    — and passes on this head; the frontend gate test fails there the same way
    (Context-free render prints the padded spelling) and passes here.
  • The merged implementation's own neighbors stay green together with the new
    tests: TestShowCreateTableStringDefaultRoundTrip,
    TestAlterCopyDefaultUsesInternalParserMode (planner) and
    TestTableDumpDefaultHashesMatchPre31067 (frontend frozen parent-parity
    hashes); related sweeps stay green (TestTableDump|TestShowCreate| TestConstructCreateTable in pkg/sql/plan, the dump-relation family in
    pkg/frontend).
  • BVT against an isolated single-node launch of this head's binary (fresh
    mo-service build, mo-tester run method): the pair 14/14 with the legacy
    show_create_table suite 64/64 in the same directory, fix(plan): preserve replayable defaults and dump fingerprints #31067's own
    cases/ddl pair 12/12, and the metadata/information_schema family 81/81
    (the previously corrupted hex(column_default) rows included); golden
    results matched, no result file was edited.

Test commands

UT (CGo-transitive packages, repository wrapper):

  • .agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout 600s -run '^TestShowCreateReplayKeepsAssignmentPaddedBinaryDefault$|^TestShowCreateTableStringDefaultRoundTrip$|^TestAlterCopyDefaultUsesInternalParserMode$' ./pkg/sql/plan/
  • .agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout 600s -run '^TestTableDumpPaddedBinaryDefault|^TestTableDumpDefaultHashesMatchPre31067$' ./pkg/frontend/
  • sweeps: -run 'TestTableDump|TestShowCreate|TestConstructCreateTable' ./pkg/sql/plan/,
    -run 'TestTableDump|TestTableSchemaHash|TestGetTableDumpRelations|TestReadTableDumpManifest' ./pkg/frontend/

Static: go vet (exit 0) and golangci-lint --new-from-rev <merge-base> ./pkg/sql/plan/... ./pkg/frontend/... (0 issues).

BVT: isolated mo-service -launch (port plan 41xxx, fresh /tmp data dirs) +
shared mo-tester jars with isolated config/report under /tmp.

Risks

  • Test-only change on top of merged main; no production code is modified.
  • The BVT golden result was verified against this head's binary rather than
    regenerated, so no expected output was edited.

@mergify mergify Bot added the kind/bug Something isn't working label Oct 25, 2026
@matrix-meow matrix-meow added the size/M Denotes a PR that changes [100,499] lines label Oct 25, 2026
@gouhongshen

gouhongshen commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor Author

CI follow-up on head b45b9eebea: unrelated coverage-lane flakes tracked; compose-BVT regression fixed in e73f3a365c

Three jobs of run 40247682659 (attempt 1) failed; dispositions:

  1. UT Coverage on Ubuntu/x86: two unrelated-to-this-PR failures.
  2. multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC): one failed statement in metadata/information_schema.sql — the ALTER ... ADD COLUMN mode_value ... DEFAULT 'a\b' probe under NO_BACKSLASH_ESCAPES — caused by this PR: the [Bug]: SHOW CREATE TABLE double-escapes quotes and backticks in string column defaults, so replaying it changes the default #31066 session-mode-aware default rendering emitted a raw backslash into the ALTER copy-table CREATE, which the CN internal SQL executor re-parses at the fixed default SQL mode (\b → BEL, hex 615C62 → 6108). Fixed in e73f3a365c (copy-table CREATE rendered via constructCreateTableSQLForInternalExecutor), proven by a new regression UT plus service-level information_schema.sql 27/27 and show_create_table_default_quote.sql 14/14; details in the PR description (CI follow-up 2).
  3. Coverage: deterministic projection of the failed UT Coverage on Ubuntu/x86 producer (fail-closed input guard), no separate root cause.

No rerun was issued (the workflow run was still pending its other jobs when handled); the fix push created a fresh CI wave on the new head. No base update was needed.

@matrix-meow matrix-meow added size/L Denotes a PR that changes [500,999] lines and removed size/M Denotes a PR that changes [100,499] lines labels Oct 26, 2026
@XuPeng-SH
XuPeng-SH marked this pull request as ready for review October 26, 2026 02:20
@XuPeng-SH

XuPeng-SH commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: e73f3a365cbea83e507bbfeab4aa73800b03775a

Review completed. Read the assessment.

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

mo-bot review · mo-bot-local · review

Commit: e73f3a365cbea83e507bbfeab4aa73800b03775a

Assessment: request_changes

Reviewed the complete six-file delta and affected consumers. Reusing the SQL formatter and preserving historical hash rendering are sound choices, but re-quoting padded BINARY defaults introduces a restore-compatibility regression.

Model: gpt-6-astra / xhigh

Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1

  • P2 pkg/sql/plan/build_show_util.go:1782: Recreate a table containing BINARY(8) DEFAULT 'a' from generated CREATE SQL. This also occurs when DUMP reconstructs manifest SQL for a table containing legacy text metadata.
    Impact: The bound Sval includes seven padding NUL bytes. Emitting those bytes changes the replayed Default.OriginString and therefore the persisted schema hash, despite preserving the default value. LOAD's schema comparison consequently rejects the recreated target. Preserve the original default representation for assignment-padded binary values and add a replay/hash regression test.
    Evidence: A real planner roundtrip confirms that OriginString changes from 'a' to 'a' plus seven NUL bytes. TestReviewBinaryDefaultManifestReplayHash then fails through the frontend manifest/hash helpers: hash 587ed28b… becomes a0489c91…. The identical probe passes with exact merge-base versions of both changed production files. Retained logs: candidate-manifest-replay.log and base-manifest-replay.log.

Validation:

  • Isolation preflight passed; reused native inputs, build receipt and library hashes were audited.

  • Four added planner tests and reviewer probes covering 40 boundary/excluded-form cases passed. Receipt: checks/1792985509092679061-6.json.

  • All three added frontend hash tests passed; the reviewer binary replay/hash probe failed in the same run.

  • Manifest regression: candidate receipt checks/1792985920147330185-4.json records exit 1; base-production control checks/1792985979322664248-3.json records exit 0.

  • Frozen current-head CI reports successful unit, static-analysis, coverage and compose BVT checks.

  • Commands, source fingerprints, exits and logs were reconciled in /home/xupeng/.local/state/mo-bot/jobs/51fc567abc2678c1d0513100/attempt-1/evidence-audit.json. Source remains unchanged.

Limitations:

  • The regression was verified through planner replay and frontend manifest/hash helpers, without running a live SQL DUMP/LOAD service.

  • local_validation was empty; author-reported service runs had no supplied retained artifacts for independent reconciliation.

  • No performance benchmark was run: added work is confined to generated CREATE text, with no new I/O, synchronization or ordinary SELECT/DML execution work.

@gouhongshen

Copy link
Copy Markdown
Contributor Author

Review P2 (padded BINARY defaults) — reproduced on head e73f3a365c; this PR is now superseded by merged main.

1. The finding is valid for this head. A planner-roundtrip probe on e73f3a365c (same mock harness as this PR's tests) confirms the reviewer's mechanism exactly:

  • binary(8) DEFAULT 'a' binds Sval = "a\x00\x00\x00\x00\x00\x00\x00" (assignment padding) while Default.OriginString stays 'a'.
  • ConstructCreateTableSQL prints `b_bin` binary(8) DEFAULT 'a\0\0\0\0\0\0\0', and the replayed table stores OriginString = "'a\x00\x00\x00\x00\x00\x00\x00'", so the DUMP/LOAD schema fingerprint computed over the recreated target no longer matches the archived hash and LOAD rejects it.
  • Only T_binary is affected (char(5), varchar, varbinary, datetime all print their stored origin spelling unchanged).

2. This PR no longer fixes something main lacks. origin/main now contains 4769417cdc — fix(plan): preserve replayable defaults and dump fingerprints (#31067), merged 2026-10-26T03:45:04Z listing "Fixes #31066" (same issue, co-authored by the same reviewer). It implements the replay contract differently: executable DDL prints the stored Default.OriginString (canonical default SQL, mode-corrected for NO_BACKSLASH_ESCAPES), while the DUMP fingerprint keeps the historical rendering through a separate legacy path. Because it never re-renders defaults from the bound literal, the padded-Sval defect class this review found does not exist there. It also pins the same ALTER COPY internal-parser-mode regression that e73f3a365c pinned here (TestAlterCopyDefaultUsesInternalParserMode).

Probe on origin/main (6c1942f3cf, includes 4769417cdc): binary(8) DEFAULT 'a' prints DEFAULT 'a' and replays with unchanged OriginString; the apostrophe/backtick/backslash defaults from #31066 replay once-escaped. The paired probe evidence: head vs origin/main logs are pr-event-1793030440255-probe-head-padding.log and -probe-main-padding.log in the loop artifacts.

3. The conflict is real and has the same root. git merge-tree origin/main HEAD conflicts exactly on pkg/sql/plan/build_show_util.go — the same functions this PR rewrote. Resolving it honestly means adopting upstream's implementation wholesale; this PR's production delta has no remaining differential value and its tests are dominated by the merged snapshots (replay roundtrip over a stored archive in pkg/tests/sqlintegration/default_quote_dump_roundtrip_test.go, 12 frozen hash cases in default_quote_hashes_pre31067.json, plan tests in show_create_default_quote_test.go, and BVT cases/ddl/show_create_table_default_quote.sql + show_columns_default_quote.sql).

Recommendation: close this PR as superseded by #31067 and verify/close #31066 against main. Pushing a rebase that resurrects a second implementation of an already-merged fix — this one carrying the confirmed padded-binary regression — adds no user-facing value. One small follow-up worth keeping from this probe: a binary(8) DEFAULT 'a' case would be cheap defense-in-depth for #31067's origin-only rendering.

4. The CI Required failure in the same event batch (run 40258122824, attempt 1) was already dispositioned by the previous turn: workflow-supersession cancellation at the 02:20 draft→ready transition, with the successor run 40258611196 on the byte-identical head completing green. No rerun or base update follows from it; being BEHIND merge freshness is now moot given the supersession.

…ity (matrixorigin#31066)

The once-escaped SHOW CREATE TABLE string-default fix for matrixorigin#31066 landed on
main in matrixorigin#31067 (4769417), which renders executable DDL defaults from the
stored OriginString and keeps the historical DUMP fingerprint rendering.
That supersedes this branch's previous competing re-quote rendering, which
the review showed corrupted assignment-padded binary defaults, so the branch
now rebases onto the merged implementation and carries test-only deltas on
top of it.

Added on top of main:

- planner: TestShowCreateReplayKeepsAssignmentPaddedBinaryDefault pins the
  review P2 for matrixorigin#31066. `binary(8) DEFAULT 'a'` binds a NUL-padded Sval while
  the stored default text stays 'a'; SHOW CREATE must print the stored text,
  replaying the printed DDL re-binds the same OriginString/Sval, the second
  SHOW cycle is idempotent, and the schema-hash input of the replayed table
  stays equal to the source's, so an archive keeps loading into a target
  rebuilt from SHOW output. The same test fails on the superseded re-quote
  head (e73f3a3), which printed and re-bound the padded spelling.
- frontend: TestTableDumpPaddedBinaryDefaultReplayHashMatchesManifest and
  TestTableDumpPaddedBinaryDefaultRejectsPaddedSpelling pin the manifest/hash
  gate the P2 broke: a replayed target hashes equal to the manifest and is
  accepted, while the padding-spelling default text the superseded rendering
  produced is a genuinely different schema and is rejected.
- BVT: keeps show_create_table_default_quote (dml/show), whose
  information_schema column_default/hex parity between source and replayed
  tables complements the merged cases/ddl pair.
@gouhongshen
gouhongshen force-pushed the agent/issue-31066-main-c5c3f501 branch from e73f3a3 to 0952288 Compare October 26, 2026 22:18
@gouhongshen gouhongshen changed the title fix(plan): print string column defaults once-escaped in SHOW CREATE TABLE (#31066) test(plan): pin padded binary default replay and dump fingerprint parity (#31066) Oct 26, 2026
@matrix-meow matrix-meow removed the size/L Denotes a PR that changes [500,999] lines label Oct 26, 2026
@mergify mergify Bot added the kind/test-ci label Oct 26, 2026
@matrix-meow matrix-meow added the size/M Denotes a PR that changes [100,499] lines label Oct 26, 2026
@XuPeng-SH

XuPeng-SH commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: 095228839f5204d5d99832ffaac8525a4e35e9c9

Review completed. Read the assessment.

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

mo-bot review · mo-bot-local · review

Commit: 095228839f5204d5d99832ffaac8525a4e35e9c9

Assessment: request_changes

Reviewed the complete four-file tests-only delta and frozen discussion. Reusing the merged renderer and historical hash implementation is sound; the earlier padded-BINARY production defect is resolved. One actionable test-oracle defect remains. No production performance changes are introduced.

Model: gpt-6-astra / xhigh

Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1

  • P2 pkg/frontend/table_dump_default_hash_test.go:70: TestTableDumpPaddedBinaryDefaultReplayHashMatchesManifest creates replay with proto.Clone(def), rather than rebuilding it from replaySQL.
    Impact: The positive manifest assertion compares identical metadata and does not establish the promised replay-to-manifest compatibility. Parse and bind the emitted replaySQL, then hash that resulting TableDef and check manifest acceptance. Retain the mismatched-origin negative control.
    Evidence: Lines 63–65 use replaySQL only for substring assertions; lines 70–78 hash the source and its clone. The separate planner test performs real replay but does not exercise the frontend normalization/hash gate. oracle-audit.log confirms this AST provenance; receipt checks/1793056704943431435-4.json records the assigned head and exit 0. This is a test-quality defect, not an observed production LOAD failure.

Validation:

  • Static checks passed for the exact head/base, clean source, frozen patch, Go formatting, all four changed files and correspondence of 14 SQL/result statements.

  • Both check receipts match the assigned source fingerprint, retained logs and exit 0. Mapping: /home/xupeng/.local/state/mo-bot/jobs/41531446b15169f8493e56a8/attempt-1/receipt-log-map.json.

  • All six nonempty discussion items were reconciled, including the earlier bot finding and author counterevidence. Saved discussion-assessment.json in the diagnostic directory.

  • Frozen exact-head CI reports successful unit, static-analysis, coverage and compose BVT checks. Detailed scope and evidence are retained in review-scope.json and review-evidence.json.

Limitations:

  • No local product tests or native builds were executed; local validation comprised static audits.

  • local_validation contains no retained worker artifacts. Current CI outcomes are reported statuses; per-test CI logs and author-local execution claims were not independently verified.

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

Request changes on this commit for the inline finding. This is based on source and control-flow review; I did not run a local reproduction.

// The candidate target a replay of that output rebuilds keeps the same
// stored default text, so its fingerprint is the manifest's and the LOAD
// gate accepts it.
replay := proto.Clone(def).(*plan.TableDef)

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.

[P2] Hash a definition actually rebuilt from the emitted DDL

replay is a clone of def, so comparing their hashes and passing them to tableDumpRelationSchemaMatches succeeds regardless of whether replaySQL can recreate the same frontend DUMP/LOAD fingerprint. The planner test separately exercises DDL replay and the canonical hash input, but it does not run this frontend hash/normalization boundary on that reconstructed definition.

Please build the target definition from the emitted CREATE TABLE, or exercise DUMP/LOAD end to end, and pass that target to tableSchemaHash. Keep the different-default negative control.

@XuPeng-SH

XuPeng-SH commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: 095228839f5204d5d99832ffaac8525a4e35e9c9

Review completed. Read the assessment.

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

mo-bot review · mo-bot-local · review

Commit: 095228839f5204d5d99832ffaac8525a4e35e9c9

Assessment: request_changes

The earlier production regression is resolved. The existing P2 test-oracle finding remains valid; no additional actionable issues were found.

Model: gpt-6-astra / xhigh

Session: 01a13dcf-1586-7a01-9000-d45e20995cf8 · slot 1 · generation 1

  • P2 pkg/frontend/table_dump_default_hash_test.go:70: The positive replay/manifest test constructs replay with proto.Clone(def), rather than rebuilding it from replaySQL.
    Impact: The hash comparison proves equality of identical metadata, leaving the claimed replay-to-manifest compatibility untested. Parse and bind the emitted DDL, then hash that reconstructed target and check acceptance. Retain the mismatched-origin negative control.
    Evidence: Lines 58–65 only render and substring-check replaySQL; lines 70–78 hash the source and its clone. The separate planner test performs replay but does not pass its reconstructed definition through the frontend hash/normalization boundary. This confirms the unchanged prior finding, not a production LOAD failure.

Validation:

  • Static audit passed: frozen head and patch, clean source, Go formatting, 14 SQL/result statements and independent literal/hex expectations. Receipt checks/1793199918688276326-5.json matches static-audit.log.

  • All 10 discussion entries reconciled in discussion-assessment.json.

  • Frozen CI reports successful unit, static-analysis, coverage and compose-BVT checks.

Limitations:

  • No local Go or BVT execution; per-test CI logs and author-local execution artifacts were not supplied.

@mergify

mergify Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

This pull request is closed, so it cannot be queued. Reopen it to get the box back.

This branch was previously deployed

1 inactive 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/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: SHOW CREATE TABLE double-escapes quotes and backticks in string column defaults, so replaying it changes the default

4 participants