Skip to content

fix(plan): preserve replayable defaults and dump fingerprints - #31067

Merged
XuPeng-SH merged 5 commits into
matrixorigin:mainfrom
MatrixAdventurer:fix/show-create-default-quote
Oct 26, 2026
Merged

XuPeng-SH merged 5 commits into
matrixorigin:mainfrom
MatrixAdventurer:fix/show-create-default-quote

Conversation

@MatrixAdventurer

@MatrixAdventurer MatrixAdventurer commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • BUG
  • Improvement
  • Test and CI

Which issue(s) this PR fixes:

Fixes #31066.

What this PR does / why we need it:

Preserve string defaults when replaying SHOW CREATE TABLE, while keeping existing DUMP TABLE schema fingerprints compatible. Executable DDL uses canonical default SQL; historical fingerprint rendering retains its exact previous escaping and whitespace rules. Legacy charset normalization copies changed column shells instead of mutating shared catalog metadata.

Also fix the ALTER COPY regression exposed by CI: under NO_BACKSLASH_ESCAPES, adding DEFAULT 'a\b' generated session-mode SQL that the ordinary-mode internal executor decoded as a backspace. Both COLUMN_DEFAULT and actual inserted values were wrong. The shared renderer now takes its target parser mode explicitly: COPY uses ordinary mode; SHOW and existing AST consumers keep their matching reader/parser modes. No executor, protocol, stored format, cache or retry changes.

Rebased onto main 6c53cf0ce2. The identical public SQL passed on exact-main source, failed on the unfixed rebased PR (HEX 6108), and passed after correction (HEX 615C62 for both metadata and inserted values).

Local validation (macOS arm64, Go 1.27.1):

  • Complete short-mode SQL planner and frontend owner suites in normal and race modes; focused public SQL regression in normal and race modes.
  • Four SQL modes cover ADD, genuinely changed MODIFY defaults, COPY/charset rebuild, CREATE LIKE, repeated SHOW replay, actual value bytes, metadata, unchanged source definitions and rejected ALTER. Existing historical DUMP/LOAD, 12 frozen hash cases and negative schema/hash controls remain covered.
  • Existing metadata and SHOW BVT scripts: 39/39; repeated twice on one owned instance without changing golden results.
  • Incremental formatting, vet and golangci-lint passed; molint reports the same 12 diagnostics as exact-main source, with no additions or suppressions.

No work is added to ordinary SELECT/DML. The mode flag is computed once per rendering; COPY avoids the unnecessary per-default mode conversion. No throughput benchmark is claimed. Historical fixtures certify their captured archive format, not every historical release. New-head CI remains pending.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

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

XuPeng-SH commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: fe4684700bef44d24786b4fd9b6ff562bc9abd7a

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: fe4684700bef44d24786b4fd9b6ff562bc9abd7a

Assessment: request_changes

Reviewed the complete four-file delta and affected callers. Removing duplicate escaping is sound, but changing this shared formatter breaks compatibility with existing DUMP TABLE archives.

Model: gpt-6-astra / xhigh

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

  • P1 pkg/sql/plan/build_show_util.go:1689: Create a DUMP TABLE archive before this change for a table containing DEFAULT 'it''s' or a backtick-containing string default, then upgrade and LOAD it into an identically defined empty table.
    Impact: LOAD rejects the existing archive with "target table schema does not match table dump" despite unchanged schema. Preserve legacy fingerprint compatibility alongside the SHOW fix and add a pre-fix archive/current-version LOAD regression.
    Evidence: tableSchemaHashWithOptions hashes ConstructCreateTableSQL output (pkg/frontend/table_dump.go:357–367); DUMP persists that hash, and LOAD requires exact equality at lines 1722–1723 without a compatibility fallback. This change replaces DEFAULT 'it''''s' with DEFAULT 'it''s' in the hash input. The source-extracted base/head probe confirms fingerprint drift for apostrophe and backtick defaults, with seven unaffected controls.

Validation:

  • Isolation preflight passed; receipt checks/1792911564992648349-2.json matches preflight.log.

  • Source-extracted Go probe passed nine named cases using the supplied test-exec; receipt checks/1792911625154745710-2.json matches default_hash_probe.log and the retained source/probe fingerprint ledger.

  • Independently audited commands, exit codes, logs, fingerprints and clean source status. Evidence and review notes are retained under /home/xupeng/.local/state/mo-bot/jobs/c892eb982311a480903fad9c/attempt-1.

  • Frozen exact-head evidence records successful UT, SCA, coverage and proxy/pessimistic BVT checks; local_validation contains no retained worker gates.

Limitations:

  • The local probe executes extracted formatting helpers with a fixture envelope, not the production DUMP/LOAD entrypoint. The rejection is established by tracing the unchanged production hash comparison.

  • Native package tests and a cross-version server restore were not run; raw CI logs were not supplied.

  • Removing escaping scans should reduce formatting work; no performance benchmark was run. Ordinary SELECT/DML execution does not call this helper.

Resolve table_dump.go conflict with matrixorigin#31069: a single
ConstructCreateTableSQLForSchemaHash now keeps both legacy comment bytes and
legacy string-default bytes for DUMP fingerprints.
@MatrixAdventurer

Copy link
Copy Markdown
Contributor Author

@XuPeng-SH thanks for the P1. It's addressed on the current head:

Local: go test ./pkg/sql/plan/ ./pkg/frontend/ pass; TestQuotedDefaultDumpRoundTrip pass. Please take another look.

本操作由 LW 授权的 Grok Bot 智能体执行。

@XuPeng-SH

XuPeng-SH commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: 34c28052c0439eefe8e52020c333e3ccda10556f

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: 34c28052c0439eefe8e52020c333e3ccda10556f

Assessment: approve

Reviewed the complete 19-file delta and affected callers. The shared renderer correctly separates replayable DDL from historical DUMP fingerprint bytes, uses the actual consumer’s parser mode, and preserves shared metadata ownership. The previous archive-compatibility finding is resolved. No actionable defects remain.

Model: gpt-6-astra / xhigh

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

Validation:

  • Isolation preflight and native provenance verification passed; 192 native inputs matched this revision.

  • Fourteen focused planner/frontend tests passed, covering four SQL modes, malformed defaults, metadata immutability, historical default/comment hashes and fallback paths. Receipt checks/1792983129419388710-4.json matches focused-tests.log.

  • TestQuotedDefaultDumpRoundTrip and all 11 subtests passed through the real SQL frontend: historical archive LOAD, current DUMP hashes, incompatible-schema/hash rejection, repeated SHOW replay, CREATE LIKE and ALTER COPY/charset conversion. Package duration: 8.204s. Receipt checks/1792983178153537132-3.json matches public-sql.log.

  • Frozen exact-head evidence records successful UT, SCA, coverage and proxy/pessimistic BVT checks. Broad CI coverage was reused.

  • Final audit reconciled commands, source fingerprints, exit receipts and retained logs; source remained clean. Evidence is retained in /home/xupeng/.local/state/mo-bot/jobs/3494f94ddca8a528a7493152/attempt-1/review-audit.json. Fixture checksums passed; the separate whitespace diagnostic flagged only intentional trailing empty BVT result fields.

Limitations:

  • Raw CI logs and retained author gates were not supplied; local checks independently verified the changed behavioral paths. The linked issue body was absent from the frozen evidence.

  • Historical compatibility validation covers the captured pre-fix archive and frozen hash cases, not every historical release or a live mixed-version upgrade.

  • No throughput benchmark was run. Ordinary SELECT/DML execution gains no new work; additional scalar parsing is confined to rendering backslash-containing defaults for NO_BACKSLASH_ESCAPES.

@mergify mergify Bot added the queued label Oct 26, 2026
@mergify

mergify Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-26 02:56 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-10-26 03:45 UTC · at 79577b4cb9b11652b1ac9c221c373df691df7084

This pull request spent 49 minutes in the queue, with no time running CI.

Reason

Pull request #31067 has been dequeued

Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.

The author needs to enable "Allow edits from maintainers" on this pull request.

Hint

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.
If you do update this pull request, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Waiting for any of
  • check-neutral = CI Required
  • check-skipped = CI Required
  • check-success = CI Required
All conditions

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request

@XuPeng-SH
XuPeng-SH merged commit 4769417 into matrixorigin:main Oct 26, 2026
26 of 28 checks passed
@mergify mergify Bot added dequeued and removed queued labels Oct 26, 2026
gouhongshen added a commit to gouhongshen/matrixone that referenced this pull request Oct 26, 2026
…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.
mergify Bot pushed a commit that referenced this pull request Nov 13, 2026
…ts (#32449)

## What type of PR is this?

- [x] BUG
- [x] Test and CI

## Which issue(s) this PR fixes

Backport of #31067 for #31066 on `4.2-dev`.

## Why

128 nightly [run 42641191428](https://github.com/matrixorigin/mo-nightly-regression/actions/runs/42641191428/job/129245352973), MO `ba2a0caee86dd0f660776560a2a68943abb11df2`, passed the actual TPCH 10G dump/import row and schema checks, but failed the independent post-restore default-value oracle: apostrophes and backticks were doubled after replaying SHOW CREATE TABLE.

## Branch-specific backport

Originally based on `4.2-dev@bf15b1c`, subsequently synchronized by Mergify to `9dd4d33e2bf3353ac66f62105f9093c8032e6ed2`; adapted from main commit `4769417cdce5531c9771644eca49f1e71d8f654c` rather than importing unrelated main-only charset/DDL infrastructure.

- Executable DDL preserves the canonical stored default SQL; NO_BACKSLASH_ESCAPES rendering and the returned AST use the same target mode.
- ALTER COPY renders for its ordinary-mode internal executor, not the caller's session mode.
- DUMP TABLE hashing keeps **the exact existing 4.2 escaping policy** through a separate hash-only renderer. Main's newer logical/physical hash fixtures are not substituted for 4.2's schema hash.
- Backport the SHOW CREATE BVT and focused planner tests; add 4.2-specific frozen SQL/hash assertions, metadata immutability and genuine-schema-change controls. Cover repeated replay, empty/quoted/backslash/NULL/BINARY defaults and four SQL modes.

## Validation

- Go formatting and `git diff --check` for Go/SQL passed. The copied upstream BVT `.result` deliberately preserves trailing spaces for its empty-string output column.
- On exact PR SHA `30295d25dfc032e6b4966648b907a5fe321d3075`, the following focused tests passed with `-count=3` on macOS arm64 / Go 1.26.5:
  - `TestShowCreateTableStringDefaultRoundTrip`
  - `TestDefaultWithoutBackslashEscapesRejectsInvalidScalar`
  - `TestAlterCopyDefaultUsesInternalParserMode`
  - `TestTableDumpDefaultHashesPreserve42`
  - `TestTableSchemaHashIgnoresIdentity`, `TestTableSchemaHashExpandsCreateLike`, `TestTableSchemaHashFallback`
- The final frontend test link initially exhausted local disk; its successful retry used `-ldflags=-w` only to omit local test-binary debug symbols. No product build flags, assertions or timeouts were weakened. Native dependencies came from the existing local MatrixOne build. The BVT file has been backported but not independently executed yet.
- Dispatched [targeted acceptance run 42750895237](https://github.com/matrixorigin/mo-nightly-regression/actions/runs/42750895237) using exact PR SHA `30295d25dfc032e6b4966648b907a5fe321d3075` from `Ariznawlll/matrixone`, regression workflow `main@d00e9351280da05a4d7f88e059a60e6c77a9e8f0`, `Run_Mode=modump-only`. It covers default-value SQL dump/restore plus TPCH 10G nation/customer/orders export, ordinary-tenant import, full row/schema checksums and owner-scoped cleanup. Status: in progress, not yet accepted.
- No full regression, TPCC/Sysbench/SSB/Vector/CDC test is requested. No timeout increase or weakened assertion.

Remote verification results will be linked when available. Remote acceptance is pending; this is not a claim that the PR or mo-dump run is fully green.


Approved-by: XuPeng-SH <[email protected]>

This branch had an error being deployed

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

Labels

dequeued kind/bug Something isn't working kind/enhancement kind/test-ci size/L Denotes a PR that changes [500,999] 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

3 participants