Description
Description
DATA BRANCH CREATE TABLE stores a branch-protection snapshot whose database_name and table_name no longer match the source object when a legal quoted identifier contains a backslash.
The source catalog preserves the backslash byte (5C), while the snapshot insert treats it as part of a SQL string escape. For example, g4d\db becomes g4ddb, and src\t becomes src<TAB> (09) in mo_snapshots.
Version
- Branch:
main - Commit:
2eb7f523e5a10f352d3e258183ed8440510388de
Reproduction
drop database if exists `g4d\db`;
create database `g4d\db`;
use `g4d\db`;
create table `src\t`(id int primary key);
insert into `src\t` values (1);
data branch create table `dst\t` from `src\t`;
select reldatabase, hex(reldatabase), relname, hex(relname), rel_id
from mo_catalog.mo_tables
where reldatabase like 'g4d%';
select sname, database_name, hex(database_name),
table_name, hex(table_name), obj_id, kind
from mo_catalog.mo_snapshots
where kind = 'branch' and database_name like 'g4d%';This was reproduced 3 out of 3 runs.
Actual result
The object catalog contains:
database: g4d\db hex=6734645C6462
table: src\t hex=7372635C74
The matching branch snapshot contains:
database_name: g4ddb hex=6734646462
table_name: src<TAB> hex=73726309
Expected result
The branch snapshot should preserve the exact source database and table names stored in the catalog.
Code path
createBranchProtectSnapshot interpolates receipt.srcDb and receipt.srcTbl directly into single-quoted SQL literals. Backslashes are therefore interpreted again when the generated INSERT is parsed.
The values should be encoded with the same SQL-literal helper used by other Data Branch generated statements.
Activity
test(frontend): cover branch snapshot identifier bytes (#26196)
Ariznawlll commentedon Jul 29, 2026
已在最新
main分支完成黑盒验证。测试版本:
52ea9f874f492c368a20efef16b46ab8ced2de37测试拓扑:Proxy + 2 CN
重复次数:3 轮
测试过程:
HEX(name),与原始输入逐字节比较。测试结果:
5C字节,没有转换成控制字符。结论:该问题在上述最新 main commit 上验证通过。
Ariznawlll commentedon Jul 30, 2026
已在
main@0ebba1c0c96bbcf0ff4091236e10df7b97e24a0c完成扩展黑盒验证。黑盒验证:
mo_tables与 branch protection snapshot 中数据库名、表名的HEX值,确认5C字节未被二次解释为转义字符。结果:该 case
20/20条 SQL/断言通过;本轮 Data Branch 全集13/13case、280/280条 SQL/断言通过。白盒边界说明:
main没有以 [Bug]: Data Branch snapshot metadata changes backslashes in quoted object names #26073 命名的独立 Go UT。test/distributed/cases/git4data/branch/protect/protect_11.sql;本轮没有把该 SQL/BVT 重复表述为 Go 白盒测试。Unhappy path / 数据一致性边界:
\t等可能被 SQL parser 二次解释的反斜杠组合,直接比较 catalog 和 snapshot 的十六进制字节。结论:反斜杠 identifier 的 metadata 字节保持和清理路径在上述提交验证通过,回归已加入 motr#69。
Ariznawlll commentedon Jul 30, 2026
Unhappy Path / 数据一致性专项验证
测试版本:
main@0ebba1c0c96bbcf0ff4091236e10df7b97e24a0c该问题的异常路径不是 SQL 返回错误,而是“语句成功但 metadata 字节被静默改变”,因此专项检查如下:
\t等可能被 SQL parser 二次解释的组合。mo_tables与 branch protection snapshot 中名称的HEX字节。结果:反斜杠字节保持为
5C,未变成 TAB 或被吞掉;无孤儿 metadata/snapshot,源数据保持可读。专项用例20/20条 SQL/断言通过。test(frontend): cover branch snapshot identifier bytes (matrixorigin#…
test(frontend): cover branch snapshot identifier bytes (matrixorigin#…
test(frontend): cover branch snapshot identifier bytes (matrixorigin#…