Repository navigation
Description
Description
Saving a DATA BRANCH DIFF result silently changes VARCHAR and VARBINARY values into textual byte arrays. The diff displayed to the client is correct, but reading the saved result through RESULT_SCAN returns different values. An INSERT ... SELECT from that saved result succeeds and persists the wrong data.
Environment
- MatrixOne
main:f847803802289b2b2d0df4f0a2f842c2804b823a(git_version()=f847803802) - Isolated local standalone, one CN, macOS arm64
Reproduction
CREATE DATABASE branch_saved_repro;
USE branch_saved_repro;
CREATE TABLE b (id INT PRIMARY KEY, v VARCHAR(40), bin VARBINARY(16));
INSERT INTO b VALUES (1, 'old', X'00FF');
DATA BRANCH CREATE TABLE child FROM b;
UPDATE child SET v = '中文', bin = X'FF000A' WHERE id = 1;
SET save_query_result = ON;
DATA BRANCH DIFF child AGAINST b;
-- Direct result has v = '中文', bin = X'FF000A'
SET @qid = last_query_id();
SELECT * FROM result_scan(@qid) AS r;
-- Actual v = '[228 184 173 230 150 135]', bin = '[255 0 10]'
CREATE TABLE copied (id INT PRIMARY KEY, v VARCHAR(40), bin VARBINARY(40));
INSERT INTO copied SELECT id, v, bin FROM result_scan(@qid) AS r;
SELECT id, v, HEX(bin) FROM copied;
-- Actual: 1, '[228 184 173 230 150 135]', '5B32353520302031305D'
-- Expected: 1, '中文', 'FF000A'Expected
The saved result must contain the same values and types as the diff returned to the client. Reading and inserting that result must preserve the text and binary bytes.
Validation
- Reproduced in 3/3 fresh databases
qbranchreadback_06,_07,_08, and independently with a SQL session variable in_09. - A second row with NULL values remained NULL; DECIMAL and integer controls matched. A normal saved SELECT over the same child table round-tripped correctly.
- The original child table retained
中文and binary hexFF000A; thecopiedtable held the wrong values after the INSERT. An ALTER on the child did not change the already saved wrong result. Session remained usable. - This is a confirmed wrong saved result and downstream wrong persisted copy; it does not overwrite the original source table.
Code analysis
The diff path calls trySaveQueryResult on frontend rows. In convertRowsIntoBatch, the VARCHAR/TEXT case handles strings but formats non-string values using fmt.Sprintf("%v", ...); for a []byte that yields the observed numeric list. The same result metadata conversion maps VAR_STRING to VARCHAR, so binary values also lose their binary type. This is separate from #31534, where JSON/BIT/BLOB cause an explicit unsupported-type error.
Activity
Ariznawlll commentedon Oct 28, 2026
补充:VECF32 的保存结果也发生变化
在同一 commit
f847803802289b2b2d0df4f0a2f842c2804b823a,将分支表的VECF32(2)从[1,1]更新为[2,2]后:三个新建数据库
qbranchmatrix_07/08/09均复现;同组 UUID、DECIMAL、ENUM 结果读回一致。该现象与 issue 中的非字符串值经fmt.Sprintf("%v", ...)转成文本的代码路径相符,建议回归时一并验证向量的类型和内容。gouhongshen commentedon Nov 5, 2026
PR #32269 is trying to fix this issue.
fix(frontend): preserve bytes and binary types in saved query results (…
gouhongshen commentedon Nov 6, 2026
PR #32269 has merged and is awaiting manual validation. The issue remains open.
XuPeng-SH commentedon Nov 6, 2026
QA 交接(main,待验证,不代表验收通过)
PR #32269 于 2026-11-06 00:23 UTC 合入 main,merge SHA
2746f81c36644bfe016743a91f3515471fd8e8da。保存 frontend 结果时,VARCHAR/TEXT/VARBINARY 的 string/[]byte 保留原字节,binary charset 的 VAR_STRING/VARCHAR 保留 VARBINARY 类型;vector 复用客户端显示格式,避免保存成 Go 数值列表。已完整读取 issue 三条评论、PR 讨论及合并文本改动;原 f847803 的 text/binary 和 VECF32 反例均在此次范围内,未发现适用于合并版本的已验证反例或未完成的本 issue 开发 follow-up。原记录明确等待人工验证,未重复已有 QA 交接。
已有证据是作者报告的 focused red→green、conversion/result-save 回归、vet 和公开 BVT 21/21,另补 BF16/Float16/int8/block-scaled coverage。审查在
590331d4...复用成功的对应 head CI与静态/binary-golden audit,没有新的 CGo/SQL 执行或原始运行日志;最终 head 为3b891a69...,合并队列记录 CI Required 成功。本轮只核对远端状态、讨论和源码范围,没有本地实测,未把旧 head CI 当作本轮全套测试。请 @Ariznawlll 在含该 merge 的 main 复测 direct DATA BRANCH DIFF→RESULT_SCAN→INSERT SELECT,核对中文、FF000A、嵌入 NUL/非 UTF-8、空值与 NULL、保存列类型及原表不变;补测 VECF32/F64、窄向量和 block-scaled 的显示文本,及 UUID/ENUM/DECIMAL/integer、普通 saved SELECT 对照。保存的 vector 是显示文本,恢复 vector 类型需要显式 CAST。全 frontend/广泛 BVT、多 CN、升级及历史已保存错误结果的修复未由本轮验证。JSON/BIT/BLOB 不支持保存仍属独立 #31534,本次不自动要求 4.2 backport。
Ariznawlll commentedon Nov 6, 2026
测试版本
65b721e1b93c6b9e05db2063b220e0c35916b335,包含修复 PR fix(frontend): preserve bytes and binary types in saved query results #32269。git_version()均为该 SHA。原问题验证
复测
DATA BRANCH DIFF→RESULT_SCAN→INSERT SELECT:中文中文和二进制FF000A在直接结果、保存结果及插入目标中一致,原始表未改变;三个入口各重复 3 轮通过。Happy Path 覆盖
/* save_result */ SELECT保存和读回也通过。保存的向量是展示文本,恢复向量类型仍须显式 CAST。Unhappy Path 覆盖
无效 query id 被拒绝;连接继续可用,源表、分支表和已保存结果保持预期。三个入口各重复 3 轮。
白盒验证
frontend 的文本/二进制转换、普通向量展示以及窄向量和块缩放转换定向 Go 单测各重复 3 次通过;没有运行完整 frontend 包或完整 CI。
回归测试
主库已有 BVT 和相应 frontend Go 单测,随 #32269 合入。本次未新增 PR。
测试证据
官方 mo-tester
309a0ca650e0c55e90292767fd61e4976818d66d:两个 CN 和 Proxy 各 3 轮,每轮 21/21。未验证升级及历史已保存错误结果的修复;JSON/BIT/BLOB 不支持保存属于独立问题 #31534。测试结论
测试通过。