Skip to content

[Bug]: SHOW CREATE TABLE drops backslashes in column and table comments, so replaying it changes the comment #31068

Closed

Description

@MatrixAdventurer

Description

SHOW CREATE TABLE prints column and table comments without escaping backslashes, so replaying its output stores different comments.

  • Column comment C:\dir\new is printed as COMMENT 'C:\dir\new'. Replaying gives C:dir + newline + ew (\d → d, \n → LF).
  • Table comment x\ty is printed as COMMENT='x\ty'. Replaying gives x + TAB + y.

Any schema copy that goes through SHOW CREATE TABLE (mo-dump, migration tools, copying DDL between accounts) silently changes these comments. Index comments are already escaped correctly (#27079). MySQL 8.0 prints COMMENT 'C:\\dir\\new' and COMMENT='x\\ty'.

Reproduction (main 80ea60a, single node, default sql_mode)

create database cbs; use cbs;
create table bs(a int comment 'C:\\dir\\new') comment 'x\\ty';
show create table bs;
--   `a` int DEFAULT NULL COMMENT 'C:\dir\new'
-- ) COMMENT='x\ty'
select hex(column_comment) from information_schema.columns where table_name='bs' and column_name='a';
-- 433A5C6469725C6E6577  (C:\dir\new, stored correctly)

-- replay the SHOW CREATE TABLE output
create table bs2(a int comment 'C:\dir\new') comment 'x\ty';
select hex(column_comment) from information_schema.columns where table_name='bs2' and column_name='a';
-- 433A6469720A6577  (C:dir<LF>ew)
select hex(table_comment) from information_schema.tables where table_name in ('bs','bs2');
-- 785C7479 (x\ty) vs 780979 (x<TAB>y)

Expected

SHOW CREATE TABLE prints COMMENT 'C:\\dir\\new' and COMMENT='x\\ty' (unchanged under NO_BACKSLASH_ESCAPES), and the replayed table has the same comments.

Cause

The parser stores column and table comments with single quotes already doubled (util.DealCommentString) but backslashes raw. constructCreateTableSQL (pkg/sql/plan/build_show_util.go) writes col.Comment and the table comment property between quotes verbatim, so the quotes survive the round trip and the backslashes do not.

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

Activity

  1. added
    kind/bug
    on Oct 25, 2026
  2. added
    severity/s0
    ai-easy
    and removed on Oct 25, 2026
  3. gouhongshen commented on Oct 25, 2026

    @gouhongshen
    Contributor

    PR #31143 is trying to fix this issue.

  4. added a commit that references this issue on Oct 25, 2026
    b160a38
  5. gouhongshen commented on Oct 26, 2026

    @gouhongshen
    Contributor

    PR #31143 has merged and is awaiting manual validation. The issue remains open.

  6. Ariznawlll commented on Oct 26, 2026

    @Ariznawlll
    Collaborator

    测试版本

    • 分支:官方 main;commit:7b80dbdbd398d171a47875f2a6196bf195a535eb。产品修复 PR #31069 已 MERGED(b160a3895c7368f7daf0f3263ea55d26d5bc4b9d),补充回归 PR #31143 亦已 MERGED(24bebb912f62aebf8a1186ba7c757fde3eef9d67);两者均为该 main 祖先。
    • 部署方式:隔离 1 LOG/1 TN/2 CN,实际二进制 git_version()=7b80dbdbd3,SHA-256 0549f8b3fcb4303f8220a15163e8b44b9c8c834e3c1ab1b19ce7ced84da999e2。日期:2026-10-27。

    原问题验证

    交替 CN1/CN2/CN1,新库 3 轮:建立列注释 C:\dir\new、表注释 x\ty 的表,读取实际 SHOW CREATE TABLE 产物并直接换表名重放。原表和重放表的列 HEX(column_comment) 均为 433A5C6469725C6E6577,表 HEX(table_comment) 均为 785C7479,3/3 完全相同;不再把反斜线解释成 LF/TAB。

    Happy Path 覆盖

    1. 逐轮检查展示 DDL 含双反斜线的可重放 SQL,重放后列/表注释字节一致。已有 BVT 还覆盖 NO_BACKSLASH_ESCAPES、普通注释与 DUMP 历史指纹;本轮没有将这些 BVT 分支冒充为独立本地复测。

    Unhappy Path 覆盖

    1. 未闭合注释字面量的 DDL 被拒绝,原表列注释字节仍为 433A5C6469725C6E6577;每轮测试库已清理。

    白盒验证

    问题可经公共 SQL 直接判定,本轮未重复 Go 内部测试;PR #31143 包含 render/replay 和旧 DUMP 指纹的定向 UT。

    回归测试

    现有 comment BVT 与配对结果已覆盖原 SQL、模式变体和 DUMP;未向 MOTR #278 重复追加。产品修复 PR #31069 的 CI Required 通过;补充测试 PR #31143 的一次 CI Required 标红,未声称其全部 CI 运行通过。

    测试证据

    • 本地隔离探针 qa-night/verify_new_five.py 3/3;上述完整 SHA、十六进制值、PR/BVT/CI 链接可供复查。

    测试结论

    测试通过。

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

Metadata

Metadata

Assignees

Labels

ai-easykind/bugseverity/s0

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions