Skip to content

test(plan): pin backslash comment replay and dump fingerprint regressions - #31143

Merged
XuPeng-SH merged 4 commits into
matrixorigin:mainfrom
gouhongshen:agent/issue-31068-main-2966905a
Oct 26, 2026
Merged

XuPeng-SH merged 4 commits into
matrixorigin:mainfrom
gouhongshen:agent/issue-31068-main-2966905a

Conversation

@gouhongshen

@gouhongshen gouhongshen commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

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 #31068

What this PR does / why we need it:

The production repair for #31068 has already merged into main as #31069:
stored column/table comments keep their already-doubled quotes and get their
backslashes doubled for replay while backslash escapes are active (verbatim
under NO_BACKSLASH_ESCAPES), and the persisted DUMP schema fingerprints keep
hashing the historical raw comment spelling through
ConstructCreateTableSQLForSchemaHash.

While that merged upstream, this branch had independently developed the same
regression theme. This PR rebases onto the merged fix, drops the duplicate
production implementation in favor of the merged one, and keeps the
complementary regression coverage this branch produced, adapted to the merged
API:

  • pkg/sql/plan/show_create_comment_backslash_replay_test.go (new): pins the
    exact catalog-stored comment bytes through render+replay in both SQL modes
    for plain, empty, trailing-backslash and quote-adjacent columns, asserts the
    rendered fragments plus their negation, requires replay idempotence
    (re-rendering is byte-stable), non-mutation of the rendered TableDef, and
    that the displayed DDL survives single-literal transport encoding.
  • pkg/frontend/table_dump_comment_fingerprint_test.go (new): freezes the
    pre-fix schema and logical-index fingerprints for a backslash-comment
    fixture, accepts an old manifest (legacy fingerprint) for an unchanged table
    after the escaping fix, and rejects genuine mismatches: the corrupted
    comment bytes the pre-fix bug produced and an altered column type.
  • test/distributed/cases/comment/comment_backslash_roundtrip.sql + .result:
    replay SHOW CREATE TABLE output with information_schema hex checks on both
    columns plus the table comment in both SQL modes, the plain-comment control
    and the NO_BACKSLASH_ESCAPES controls, merged with the upstream
    immutable legacy dump-fixture LOAD and metadata-only DUMP/LOAD
    fingerprint-mismatch blocks. The case owns and drops its database and stages,
    so it is re-runnable, and it saves the incoming sql_mode into a user
    variable around its NO_BACKSLASH_ESCAPES control block and restores it
    afterwards (the pattern information_schema.sql and
    table_func_json_table.sql already use), so the shared mo-tester session is
    left in its incoming state for every later script of the same BVT
    generation.

All production behavior now comes unchanged from main; this PR is test-only.

Validation

All verification ran on the rebased tree 07876cfdab = origin/main@b160a3895c (which already contains merged #31069) plus this commit; the produced binary contains CommitID 07876cfdab (sha256 968e0617...). CGo test runs use the repository mo-cgo-test wrapper.

  • go test -list selection proof: TestShowCreateTableCommentBackslashStoredByteRoundTrip, TestShowCreateTableCommentIsNotMutated, TestShowCreateTableCommentTransport (new in pkg/sql/plan), the merged upstream TestShowCreateTableCommentBackslashRoundTrip, and TestDumpSchemaHashKeepsLegacyBackslashCommentSpelling, TestOldDumpManifestMatchesUnchangedTableAfterCommentEscapingFix (new in pkg/frontend) plus the upstream TestTableSchemaHashStoredCommentCompatibility, TestTableSchemaHashStillRejectsCommentAndSchemaDifferences all listed (non-empty selection).
  • go test -run 'TestShowCreateTableComment' ./pkg/sql/plan - ok 2.527s, exit 0 (replay round trip in both sql modes, fragment/negation asserts, idempotent re-render, non-mutation, transport re-encode).
  • go test -run 'TestDumpSchemaHashKeepsLegacyBackslashCommentSpelling|TestOldDumpManifestMatchesUnchangedTableAfterCommentEscapingFix|TestTableSchemaHashStoredCommentCompatibility|TestTableSchemaHashStillRejectsCommentAndSchemaDifferences' ./pkg/frontend - ok 7.847s, exit 0. The pre-fix fixture fingerprint stays d0f7fd53926c805dd05af3d5dcd2f4f148d8861d539db9a7490aa77e07b061bd under the merged ConstructCreateTableSQLForSchemaHash path (schema and logical-index hashes), an old manifest still matches an unchanged table, and corrupted-comment/altered-type mismatches are still rejected.
  • Owning packages in normal mode: go test ./pkg/sql/plan - ok 256.339s exit 0; go test ./pkg/frontend - ok 54.640s exit 0.
  • BVT on an isolated single-node instance (fresh runtime, separate port plan): genrs regenerated comment_backslash_roundtrip.result byte-identical to the committed file (zero-diff, every row reviewed against the union of the two upstream expectations); normal comparison run 42/42 exit 0; same-instance repeat run 42/42 exit 0; full test/distributed/cases/comment group 116/116 exit 0 (annotion 18, comment 56, comment_backslash_roundtrip 42, mo-tester error.txt empty). The legacy $resources dump fixture loads with rows intact, FORCE INDEX is honored, LOAD rejects the changed-schema target with target table schema does not match table dump and the mismatched table stays empty. Post-run teardown verified: comment_bs_rt database, both stages, /tmp metadata files all absent; the instance was stopped with SIGTERM and confirmed exited with its listeners released.
  • Static: gofmt -l on all changed Go files - clean; go vet and go vet -vettool=molint on ./pkg/frontend ./pkg/sql/plan with the repository CGo environment - exit 0; golangci-lint run -c .golangci.yml --new-from-rev origin/main on the two packages - 0 issues (see golangci-rebased log).

Follow-up (2026-10-26): fix the compose-proxy BVT failure this branch introduced

CI run
40232128784
('multi cn e2e bvt test docker compose(PROXY)') failed exactly 2 of 49746
statements, both in test/distributed/cases/cte/local_outer_reference.sql
(rows 379/382) with correlated columns in aggregate function is not yet implemented; every other script in the generation stayed green, including
comment_backslash_roundtrip.sql itself (42/42).

Root cause: the case's NO_BACKSLASH_ESCAPES control block ended with
set sql_mode = '', mo-tester reuses one session for every script of a
generation (CI log shows con[id=0] throughout), so the CTE case and
everything later lost ONLY_FULL_GROUP_BY. pkg/sql/plan/having_binder.go
only rebinds correlated columns in aggregate/HAVING predicates under
mysqlFullGroupByCompat, which requires ONLY_FULL_GROUP_BY in sql_mode;
without it the binder returns the NYI error. Commit 57f93b5873 therefore
saves the incoming sql_mode before the block and restores it afterwards.
The same run's UT Coverage failure (TestCrossTargetUpgradeRecovery/manual-4.0.13,
pkg/embed upgrade-recovery budget flake) is the known family flake tracked in
#31044 and is unrelated to this test-only diff.

New verification for 57f93b5873 ran on a fresh isolated instance of the same
produced binary (07876cfdab; 57f93b5873 changes only the two comment BVT
files, so production behavior is identical):

  • Direct session probe on the same binary: the controlled statement returns the
    expected rows (1|1, 2|NULL, 3|0) under the platform default sql_mode
    (ONLY_FULL_GROUP_BY,...), fails with the exact NYI error under
    sql_mode='', and passes again after the save/restore pattern.
  • Ordered pair through mo-tester (CI compare semantics: $resources mapping +
    nometa), exactly as the CI group orders them: pre-fix reproduction =
    comment_backslash_roundtrip.sql 42/42 and
    cte/local_outer_reference.sql 266/268 with only rows 379/382 failing
    (mo-tester exit 1); post-fix = comment 43/43, cte 268/268, 311/311 and exit 0.
  • genrs on the fixed case regenerates comment_backslash_roundtrip.result
    byte-identical to the committed file (zero-diff).
  • Full test/distributed/cases/comment group with metadata comparison on:
    117/117 exit 0 (annotion 18, comment 56, comment_backslash_roundtrip 43).

Residual risk

  • The case writes DUMP metadata to /tmp/mo-comment-backslash-roundtrip-31068/
    and removes it again in the same script (remove files from stage ...), the
    same path and cleanup the merged upstream case already carries.
  • No CI, workflow, or configuration files are touched; the diff is limited to
    the two new UT files and the reworked comment BVT case.

…ions

Main already carries the production repair for matrixorigin#31068: the merged PR matrixorigin#31069
renders stored column/table comments with backslashes doubled for replay
(verbatim under NO_BACKSLASH_ESCAPES) through ConstructCreateTableSQL, keeps
the historical raw spelling for persisted DUMP fingerprints via
ConstructCreateTableSQLForSchemaHash, and pins the display and legacy-archive
regressions with its own UT and BVT.

Rebase this branch onto that fix: the duplicate production changes and the
signature churn of the private constructCreateTableSQL parameter are dropped
in favor of the merged implementation, while the regression coverage this
branch developed stays, adapted to the merged API:

- pkg/sql/plan/show_create_comment_backslash_replay_test.go: catalog-stored
  comment bytes pinned across default and NO_BACKSLASH_ESCAPES modes
  including plain, empty, trailing-backslash and quote-adjacent columns;
  rendered fragment asserts plus their negation, replay idempotence,
  non-mutation of the input TableDef, and single-literal transport
  re-parsing.
- pkg/frontend/table_dump_comment_fingerprint_test.go: the frozen pre-fix
  schema and logical-index fingerprints for backslash comments, old-manifest
  acceptance after the escaping fix, and corrupted-comment/altered-type
  mismatch controls on tableDumpRelationSchemaMatches.
- comment_backslash_roundtrip BVT: replay SHOW output with both-column hex
  asserts, the NO_BACKSLASH_ESCAPES and plain-comment controls, merged with
  the upstream legacy dump-fixture and metadata-only DUMP/LOAD blocks.

Related to matrixorigin#31068
@gouhongshen
gouhongshen force-pushed the agent/issue-31068-main-2966905a branch from 16783fc to 07876cf Compare October 25, 2026 20:43
@matrix-meow matrix-meow added size/M Denotes a PR that changes [100,499] lines and removed size/L Denotes a PR that changes [500,999] lines labels Oct 25, 2026
@gouhongshen gouhongshen changed the title fix(plan): escape backslashes in SHOW CREATE TABLE comments test(plan): pin backslash comment replay and dump fingerprint regressions Oct 25, 2026
@mergify mergify Bot added the kind/test-ci label Oct 25, 2026
The BVT runner executes every case script on one shared session, and this
script left sql_mode at '' after its NO_BACKSLASH_ESCAPES block, so all
later scripts in the same generation lost ONLY_FULL_GROUP_BY. In the
'multi cn e2e bvt docker compose(PROXY)' run that made
cte/local_outer_reference.sql rows 379/382 fail with 'correlated columns
in aggregate function is not yet implemented': having_binder.go only
rebinds aggregate/HAVING correlated columns under mysqlFullGroupByCompat,
which requires ONLY_FULL_GROUP_BY in sql_mode.

Save the incoming sql_mode before the block and restore it afterwards,
the same pattern information_schema.sql and table_func_json_table.sql
already use.

Verified locally against a 07876cf head instance: running the ordered
pair comment_backslash_roundtrip.sql -> local_outer_reference.sql with
the CI compare semantics (resource map + nometa) reproduces the CI
failure pre-fix (comment 42/42, cte 266/268, rows 379/382) and passes
311/311 post-fix (43/43 + 268/268); genrs output is byte-identical to
the committed .result; the full comment group passes 117/117 (18+56+43)
with metadata comparison on.
@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 →

@XuPeng-SH

XuPeng-SH commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: 57f93b5873d8b67ac3626b32eec39279e569cb28

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: 57f93b5873d8b67ac3626b32eec39279e569cb28

Assessment: approve

Reviewed the complete four-file test-only delta and supplied discussions. The tests strengthen stored-byte, replay, nonmutation and legacy dump compatibility coverage through existing owners. Restoring the incoming SQL mode addresses the reported BVT session leak. No actionable defects or production runtime costs were identified.

Model: gpt-6-astra / xhigh

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

Validation:

  • Reused the frozen exact-head successful UT, UT Coverage, PROXY BVT and PESSIMISTIC BVT statuses; checked repository selectors against the affected packages and SQL suite.

  • Local static audit passed: exact head, unchanged source, complete test-only scope, git diff --check, patch correspondence, SQL-mode restoration order and golden hexadecimal values.

  • Reconciled exit-0 receipt checks/1792973359738985169-4.json with review-static-audit.log and review-static-audit.json under the assigned attempt directory. The earlier audit assertion failed only because the supplied patch omitted its terminal newline; original evidence and diagnosis are retained.

  • Detailed design, coverage and evidence assessment retained in review-notes.txt.

Limitations:

  • No local Go tests or BVT were repeated. CI evidence consists of the coordinator’s frozen status snapshot and checked-in selectors; raw CI logs were unavailable.

  • local_validation is empty. Author-local timings, test counts and historical hash-capture provenance were not independently verified.

@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 00:11 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • ❌ Checks failed · in-place
  • 🚫 Left the queue — 2026-10-26 01:00 UTC · at 337c3d03be0960e065f2aba5d8fa58ea9aff38d0

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

Reason

The merge conditions cannot be satisfied due to failing checks

  • CI Required

Failing checks:

Hint

You may have to fix your CI before adding the pull request to the queue again.
If you update this pull request, to fix the CI, 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 24bebb9 into matrixorigin:main Oct 26, 2026
16 of 21 checks passed
@mergify mergify Bot removed the dequeued label Oct 26, 2026

This branch was successfully deployed

No deployments
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.

3 participants