Skip to content

[Bug]: mo-dump SQL export of GEOMETRY cannot be restored even with binary-mode client #30581

Closed as not planned

Description

@Ariznawlll

问题

mo-dump 导出包含 GEOMETRY 值的普通表时退出 0,文件带 MODUMP SUCCESS;但该 SQL 无法导入空的 MatrixOne 数据库。即使客户端使用 --binary-mode=1 接受文件中的原始 NUL,导入仍报 invalid geometry payload,表结构已创建而数据为 0 行。

环境

  • MatrixOne main:75ff736835c3d00d40dc00a0a1d3b11129388e5b
  • mo_dump main:324c33dbdc7075cd5d7beaafd1e15c76709dd442
  • 本地隔离 LOG/TN/CN;MySQL 协议端口 26011;2026-10-19

最小复现

CREATE DATABASE geo_src;
CREATE TABLE geo_src.g(id INT PRIMARY KEY, g GEOMETRY);
INSERT INTO geo_src.g VALUES(1, ST_GeomFromText('POINT(1 2)'));
SELECT id, ST_AsText(g) FROM geo_src.g;
-- 1 | POINT(1 2)
mo-dump -u root -h 127.0.0.1 -P 26011 -db geo_src -tbl g > g.sql
mysql -h 127.0.0.1 -P 26011 -e 'CREATE DATABASE geo_restore'
mysql --binary-mode=1 -h 127.0.0.1 -P 26011 -D geo_restore < g.sql

实际导入返回 ERROR 20301 (HY000) at line 9: invalid input: invalid geometry payload。导出的 INSERT 把几何值作为含原始 NUL 的单引号字节串输出;geo_restore.g 已存在但为 0 行。期望导入成功,恢复后 ST_AsText(g)=POINT(1 2);若无法生成可恢复脚本,导出不应报告成功。

验证与定位

  • 三套独立新建源库各含一行 POINT(1 2) 和普通对照表。三份整库导出均退出 0,三份导入均在几何 INSERT 处失败,geo_restore.g 在失败当时均为 0 行;源表仍为一行且可读,连接可执行 SELECT 1。
  • 只导出几何表的更小脚本也复现。只导出普通表 plain(1,'ok') 在相同目标连接中导入成功;失败目标表可通过 INSERT ... ST_GeomFromText(...) 正常写入,排除几何类型本身或连接故障。
  • 源端 HEX(CAST(g AS VARBINARY))=0101000000000000000000F03F0000000000000040;SQL dump 中单引号值开头包含原始 00 00 00 00 01... 字节。cmd/mo-dump/main.go:729-781 的 convertValue 对 GEOMETRY 走默认字符串引号路径,没有生成可重建几何值的表达式。这是源码线索,不能代替运行时复现。
  • CSV 模式对同一表也在 LOAD DATA 处报错,字节流出现 UTF-8 替换字符;这与已知的 mo_dump#45 二进制 CSV 损坏同类,本单重点是 SQL 模式在 --binary-mode=1 下仍无法恢复 GEOMETRY。

已检索 matrixone/mo_dump 的 open、closed issue 与相关 PR,以及 mysql-compatibility-contract,未发现同一 GEOMETRY SQL 恢复问题。相关但不相同:matrixone#30554 是 VARBINARY 原始 NUL 导致默认客户端拒绝;本问题即使绕过客户端 NUL 检查,服务端仍拒绝几何 payload。

修复后建议增加几何/GEOMETRY32 的 SQL 导出→空库导入→WKB/WKT、SRID、NULL、元数据核对回归;CSV 二进制修复应同时覆盖几何字节。

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. Ariznawlll commented on Oct 19, 2026

    @Ariznawlll
    CollaboratorAuthor

    补充同根边界:将列改为 GEOMETRY32、写入 POINT(1 2) 后,mo-dump -tbl g32 同样退出 0;用 mysql --binary-mode=1 导入空目标表时在 INSERT 报 ERROR 20203 ... cast_geometry_to_subtype, bad value [VARCHAR VARCHAR]。原表仍为 1 行,目标表 0 行。这与正文的 GEOMETRY 失败属于同一条几何值序列化路径,不另提单。

  5. XuPeng-SH commented on Oct 22, 2026

    @XuPeng-SH
    Contributor

    This report is now tracked together with #30673. The canonical issue retains explicit acceptance cases for the behavior described here. This is an administrative duplicate/consolidation closure only; the underlying defect is not claimed fixed. The original description and discussion remain available on this issue.

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

Metadata

Metadata

Assignees

Labels

kind/bug

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions