You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
MO 可在 VARCHAR 列存储非 UTF-8 原始字节,但 SELECT ... INTO OUTFILE ... FORMAT 'jsonline' 对这类值返回成功,同时把无效字节静默替换为 U+FFFD。导入导出的 JSONLINE 后,原始数据永久改变;相同数据用 CSV 导出/导入则字节完全一致。
环境
MatrixOne main commit 3a1e42b4308bd0098e055ddb9360a07f85201d9c,隔离本地单 TN、双 CN;2026-10-21。
最小复现
将路径换成可写的本地文件。
CREATETABLEsrc(id INTPRIMARY KEY, s VARCHAR(30));
CREATETABLEdstLIKE src;
INSERT INTO src VALUES
(1,CAST(x'FF'ASCHAR)),
(2,CAST(x'61FF62'ASCHAR)),
(3,CAST(x'E4B8AD'ASCHAR));
SELECT id,HEX(s) FROM src ORDER BY id;
-- (1,FF), (2,61FF62), (3,E4B8AD)SELECT id,s FROM src ORDER BY id
INTO OUTFILE '/tmp/rows.jsonl' FORMAT 'jsonline';
LOAD DATA INFILE
{'filepath'='/tmp/rows.jsonl','format'='jsonline','jsondata'='object'}
INTO TABLE dst;
SELECT id,HEX(s) FROM dst ORDER BY id;
-- 实际:(1,EFBFBD), (2,61EFBFBD62), (3,E4B8AD)
QA follow-up on PR #30797 at head ff321a491fe298da4a5a2c08c426d9d92967927d.
The OUTFILE guard covers CHAR/VARCHAR/TEXT, but vectorValueToJSON still returns string(vec.GetBytesAt(i)) for T_datalink without checking UTF-8. constructJSONLine then JSON-marshals that Go string, which replaces invalid UTF-8 with U+FFFD. The cast path appears to preserve raw bytes after ValidateDatalink (strToDatalink → url.Parse / resolveDatalinkURL); I found no UTF-8 validation there.
Please cover DATALINK with the same explicit rejection (or prove invalid bytes cannot be stored), and add a regression using a binary-origin DATALINK URL path. Static call-chain finding only: this environment has no Go toolchain or MatrixOne service, so I could not execute the SQL repro.
The merged change explicitly rejects invalid UTF-8 in CHAR/VARCHAR/TEXT/DATALINK before JSON serialization, and adds binary-origin DATALINK coverage plus same-session recovery with a valid URL. This addresses the earlier DATALINK call-chain concern in the existing comment. The PR's submitted exact-candidate evidence reports the focused frontend and embedded regressions passing on dd6ce76d6a3246fdd941d8d6fad2caf610b3da38; that tested commit is an ancestor of the merged head, and a source diff of the affected export/embed paths between those revisions is empty.
This is reviewer/test evidence from the PR, not a test run I performed here (Go and a runnable MatrixOne service are unavailable). No current merged-head CI pass is claimed: its combined status and visible workflow runs are empty. The defect is fixed with targeted regression evidence; leaving the issue open for tester confirmation.
CREATETABLEsrc(id INTPRIMARY KEY, s VARCHAR(30));
CREATETABLEdstLIKE src;
INSERT INTO src VALUES (1,CAST(x'FF'ASCHAR)),(2,CAST(x'61FF62'ASCHAR)),(3,CAST(x'E4B8AD'ASCHAR));
SELECT id,s FROM src ORDER BY id INTO OUTFILE '/tmp/moqa-out/rows.jsonl' FORMAT 'jsonline';
LOAD DATA INFILE {'filepath'='/tmp/moqa-out/rows.jsonl','format'='jsonline','jsondata'='object'} INTO TABLE dst;
SELECT id,HEX(s) FROM dst ORDER BY id;
Activity
XuPeng-SH commentedon Oct 22, 2026
QA follow-up on PR #30797 at head
ff321a491fe298da4a5a2c08c426d9d92967927d.The OUTFILE guard covers CHAR/VARCHAR/TEXT, but
vectorValueToJSONstill returnsstring(vec.GetBytesAt(i))forT_datalinkwithout checking UTF-8.constructJSONLinethen JSON-marshals that Go string, which replaces invalid UTF-8 with U+FFFD. The cast path appears to preserve raw bytes afterValidateDatalink(strToDatalink→url.Parse/resolveDatalinkURL); I found no UTF-8 validation there.Please cover DATALINK with the same explicit rejection (or prove invalid bytes cannot be stored), and add a regression using a binary-origin DATALINK URL path. Static call-chain finding only: this environment has no Go toolchain or MatrixOne service, so I could not execute the SQL repro.
fix: preserve JSONLine text in OUTFILE round-trips (#30797)
XuPeng-SH commentedon Oct 22, 2026
Verified-fix follow-up for PR #30797, merged 2026-10-22 (head
7a196af243e16e93c2acbec7eb17b04e1db133de; merge commit1daa5e459bf5f58a9b21218a1082cb1a5bdf5562).The merged change explicitly rejects invalid UTF-8 in CHAR/VARCHAR/TEXT/DATALINK before JSON serialization, and adds binary-origin DATALINK coverage plus same-session recovery with a valid URL. This addresses the earlier DATALINK call-chain concern in the existing comment. The PR's submitted exact-candidate evidence reports the focused frontend and embedded regressions passing on
dd6ce76d6a3246fdd941d8d6fad2caf610b3da38; that tested commit is an ancestor of the merged head, and a source diff of the affected export/embed paths between those revisions is empty.This is reviewer/test evidence from the PR, not a test run I performed here (Go and a runnable MatrixOne service are unavailable). No current merged-head CI pass is claimed: its combined status and visible workflow runs are empty. The defect is fixed with targeted regression evidence; leaving the issue open for tester confirmation.
XuPeng-SH commentedon Oct 22, 2026
复核结果:在
main上仍然复现(转测已撤回)在
main@3ad9adbb4c的本地 CGo 构建上按本 issue 的最小复现执行(隔离实例,非 Docker 镜像):实际(HEAD):
导出文件原始字节(
xxd)同样确认:导出与导入都返回成功,行数不变,属静默改写,与本 issue 描述一致。
为什么会被误判为"已修复"
我在转测时依据的是 PR #30797(
fix: preserve JSONLine text in OUTFILE round-trips)的合并状态。核实后:该修复不在main上 ——main最近 100 个提交里与 jsonline 相关的只有9a7ea39bd4(fix(external): decode base64 on jsonline load for binary columns,#30663),没有任何提交修改pkg/frontend/export.go的vectorValueToJSONOUTFILE 路径。也就是说该 PR 合入的目标分支不是main。已采取的动作
main上不存在的修复。main是否也需要同一修复;若main需要,建议重新开 PR 并补一条 main 分支的 BVT。Ariznawlll commentedon Oct 24, 2026
测试版本
main,commit6a9a4e22f94205846b36fcbd7396747c219095e7。PR #30797 merge commit1daa5e459bf5f58a9b21218a1082cb1a5bdf5562已核实为该 SHA 的祖先;当前pkg/frontend/export.go在 JSONLINE 序列化前显式校验文本 UTF-8。vcs.revision与上述 SHA 一致、vcs.modified=false,SHA-256c93327196edb7f6d4b403e687f22327cad46ff145531c9ee510ee6e92af8c056,MySQL 协议直连。原问题验证
原始非法字节
FF、嵌入式61FF62和截断序列C3仍可作为 VARCHAR 原始值读出;JSONLINE OUTFILE 现在对三者逐项明确返回20105 / invalid UTF-8,不再返回成功并写入EFBFBD。手工原路径 3/3;失败后源表每行HEX(s)不变,导出路径无残留文件(3/3)。Happy Path 覆盖
合法多字节
E4B8AD和真 NULL 仍可 JSONLINE 导出/导入,目标分别为E4B8AD和 NULL;同一数据的 CSV OUTFILE/LOAD 对照保留非法原始字节FF、61FF62、C3,逐行差异数 0。Unhappy Path 覆盖
三种位置的非法 UTF-8 分别要求精确错误码
20105;导出失败后不允许静默替换、修改源值或留下部分 JSONLINE 文件;随后合法导出能继续成功。三轮使用独立数据库和文件并完成清理。白盒验证
此前评论在另一
main快照上报告仍复现;本轮不沿用该判断,而是核实 PR merge commit 在此测试 SHA 祖先链,并以vcs.modified=false的同 SHA 实际服务重跑。未修改 MO 产品代码;本轮未另跑 Go UT/race。回归测试
已在用户指定的 MOTR #278 添加 SQL 场景 及 配对期望。定向
./motr --branch main --repeat 3 14_issue_regression.issue_30705_jsonline_invalid_utf83/3;每轮 33 条语句。#278 当前 head 的离线检查 4/4 通过:Actions。未运行全量 MOTR suite 或 MatrixOne 全量 CI。测试证据
配对结果明确保留导出前
FF/61FF62/C3/E4B8AD/NULL,前三种分别得到ERROR 20105,合法与 NULL 往返正确,CSV 目标逐字节一致、差异数0。手工原场景及 MOTR 回归各 3/3。测试结论
测试通过。