Skip to content

[Bug]: mo-dump cannot export ordinary tables whose names contain apostrophes or backticks #30560

Closed
matrixorigin/mo_dump
#53

Description

@Ariznawlll

Description

mo-dump 无法导出 MatrixOne 合法的带标点表名:表名含单引号时,-tbl 的 catalog 过滤 SQL 语法错误;表名含反引号时,单表和整库导出都在 SHOW CREATE TABLE 语法错误。整库只因存在这样一张普通表便无法完成逻辑备份。问题发生在导出阶段,与 #30554–#30559 的导入或类型问题不同。

Environment

  • MatrixOne main commit:75ff736835c3d00d40dc00a0a1d3b11129388e5b;隔离 LOG/TN/CN,SQL frontend 127.0.0.1:26011,SELECT @@version 为 8.0.30-MatrixOne-v1.3.0。
  • mo_dump main commit:324c33dbdc7075cd5d7beaafd1e15c76709dd442,本地构建的 macOS arm64 二进制。
  • 日期:2026-10-19。

Steps to reproduce

在独立测试库 d 中执行:

CREATE TABLE d.plain(id INT PRIMARY KEY, v VARCHAR(20));
INSERT INTO d.plain VALUES(1,'plain');
CREATE TABLE d.`a'b`(id INT PRIMARY KEY, v VARCHAR(20));
INSERT INTO d.`a'b` VALUES(2,'apostrophe');
CREATE TABLE d.`a``b`(id INT PRIMARY KEY, v VARCHAR(20));
INSERT INTO d.`a``b` VALUES(3,'backtick');

三张表均创建、写入和读取成功。之后分别运行:

./mo-dump -u root -h 127.0.0.1 -P 26011 -db d > full.sql
./mo-dump -u root -h 127.0.0.1 -P 26011 -db d -tbl "a'b" > apostrophe.sql
./mo-dump -u root -h 127.0.0.1 -P 26011 -db d -tbl 'a`b' > backtick.sql
./mo-dump -u root -h 127.0.0.1 -P 26011 -db d -tbl plain > plain.sql

Actual behavior

  • 前三条命令均退出 1,报 MatrixOne ERROR 1064。-tbl "a'b" 错误位置为 b');含反引号的单表及整库导出错误位置为 `b``。
  • 整库输出只有约 206 字节的 SET foreign_key_checks 和 DROP/CREATE/USE DATABASE 头部,没有数据和成功标记,不能作为可恢复备份。
  • -tbl plain 退出 0,输出完整 DDL、数据和 MODUMP SUCCESS。

Expected behavior

合法普通表的导出应正确引用/转义对象名。整库导出不应仅因存在带标点的合法表名而失败;单表导出和导入后应保留表名与行值。

Stability and controls

  • 使用三个独立新库 exp_modump_ident_1019_a/b/c,每库相同三张表;整库失败 3/3,单引号表 -tbl 失败 3/3,反引号表 -tbl 失败 3/3。
  • 正常对照:plain 单表导出成功,并导入另一新库后读到 (1,'plain')。
  • 失败后源库三张表仍在,三行分别为 (1,'plain')、(2,'apostrophe')、(3,'backtick'),连接可继续查询;没有发现源数据修改或进程崩溃。

Code analysis

  • cmd/mo-dump/main.go 的 getTables 直接把 tbl.Name 拼入单引号 SQL (relname in ('...')),没有转义单引号。
  • getCreateTable 直接把数据库名和表名拼入反引号标识符 show create table \db`.`tbl``,没有对名字中的反引号进行双写。
  • dumpData 在输出数据库 DROP/CREATE/USE 头部后才逐表读取 DDL,因此此类失败留下看似可用但不完整的输出文件;程序正确地退出非零且未打印成功标记。

Evidence

Regression coverage

建议 mo_dump 集成测试覆盖普通/单引号/反引号表名的整库与 -tbl 导出→导入→精确行值核对,并增加错误退出时不得把半截文件当作成功备份的断言。

Activity

  1. added this to the MO-202610 milestone on Oct 19, 2026
  2. added
    kind/bug
    on Oct 19, 2026
  3. added theissue type on Oct 19, 2026
  4. added
    severity/s0
    and removed on Oct 20, 2026
  5. assigned and unassigned on Oct 23, 2026
  6. slyunnn commented on Oct 26, 2026

    @slyunnn

    Regression and extended verification for #30560 (2026-10-26)

    Verification Environment

    • MatrixOne main: b466f4ae9b74813a4ff93eaf43a6c81e6cbb8b0b — fix: acknowledge ISCP drain before executor runtime starts (#31167). The binary was rebuilt and restarted; git_version() returned b466f4a on all tested routes.
    • mo-dump main: d9d6375512620f12ff371b8602cc1d10d6f6caa0, locally rebuilt. Associated fix: identifier quoting from mo_dump PR #56 was integrated into merged PR #53, merge commit f33f68e554e2d8fb41c8746414e4b12bdc3c1e33; implementation commit 17b7f37488ef72127c2f2d96f600e08899c0e074 (fix: quote dump object names throughout export and restore). PR Add bag difference #56 itself closed without a separate merge.
    • Topology: 2 CN / 1 TN / 1 Log service / Proxy. Setup, export, native mysql 9.7.1 restore, catalog checks, and value queries ran independently over MySQL text-protocol routes Proxy 6001, CN1 16001, and CN2 16002.

    What Was Covered

    • OK — The issue's ordinary table plain, apostrophe table a'b, and backtick table a`b were created, populated, and queried before export on all 3 routes.
    • OK — Full-database export containing all special-name tables returned 0 with MODUMP SUCCESS; native-client restore into an empty target returned 0 and preserved every table name and its exact row value on all 3 routes.
    • OK — Each -tbl export for plain, a'b, and a`b returned 0 with MODUMP SUCCESS; each table-only script restored into a pre-created, explicitly selected database and preserved its exact row on all 3 routes.
    • OK — Boundary identifier a'`b (both punctuation characters) passed both selected-table and full-database export/restore.
    • OK — Unhappy path: -tbl "a'b_missing" exited 1, reported that the table does not exist, emitted no MODUMP SUCCESS, and left the existing source table queryable on all 3 routes.
    • Not covered — Arbitrary Unicode/very-long identifiers, concurrent DDL, and CSV-mode export. The table-only script's omission of CREATE DATABASE is its existing contract; the restore client was given a target database explicitly.

    Findings

    The original 1064 failures from unescaped apostrophes/backticks no longer reproduce. All 15 positive endpoint/export combinations restored with exact catalog names and rows, and all 3 missing-name negative checks returned a non-success status without altering source data.

    Large-data regression required: No. The defect is catalog-string and SQL-identifier quoting, independent of row count, block/batch size, spill, or network scale. One row per named table and a combined-quote boundary reach the relevant parser paths.

    MOTR / BVT Coverage

    The owning mo-dump repository contains focused identifier/catalog error tests; its full go test -count=1 ./... suite passed on the tested revision. The live CLI/native-client checks above provide end-to-end confirmation. No duplicate SQL-only MOTR case, issue commit, or weekly PR change was made because the behavior under test is the tool's emitted SQL and exit status.

    Final Conclusion

    Fixed for #30560 on the tested MatrixOne and mo-dump revisions. Full and selected-table exports now preserve the reported punctuation-bearing ordinary table names and data.

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

Metadata

Metadata

Assignees

Labels

kind/bugseverity/s0

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions