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
{{ message }}
Repository navigation
[Compatibility]: TO_BASE64 materializes bounded VARBINARY input as TEXT and prevents indexing #28902
TO_BASE64 exposes every bounded string/binary input as unbounded TEXT. For a small VARBINARY input, this changes the View/CTAS schema and prevents ordinary secondary indexing even though the encoded result has a small deterministic maximum size.
Reproduction
dropdatabase if exists to_base64_type_repro;
createdatabaseto_base64_type_repro;
use to_base64_type_repro;
createtablesrc(id intprimary key, raw varbinary(128));
insert into src values (1,unhex('4100FF7A')),(2,unhex('612C622C2C63')),(3,null);
createviewvasselect id,to_base64(raw) b64 from src;
createtablectasasselect*from v;
select table_name,column_name,data_type,column_type,character_maximum_length
frominformation_schema.columnswhere table_schema=database() and table_name in ('v','ctas')
order by table_name,ordinal_position;
createindexidx_b64on ctas(b64);
MatrixOne result
b64 is declared as TEXT, with character_maximum_length=65535, in both the View and CTAS table.
CREATE INDEX returns not supported: TEXT column 'b64' cannot be in index.
Scalar values themselves are correct (QQD/eg==, YSxiLCxj, and NULL).
MySQL 8.0.45 result
The same expression over VARBINARY(128) is declared as VARCHAR(174) in both the View and CTAS table.
The secondary index is created and an indexed equality lookup returns the expected row.
Controls and scope
NULL and embedded 0x00/0xff bytes are included. Direct selection, View, CTAS, index creation, forced-index lookup, and prepared TO_BASE64/FROM_BASE64 round trips are covered. Three independent executions produced identical results on each database.
The functional impact is not only metadata: bounded encoded values lose index eligibility after materialization.
Code location
The scalar string overload in pkg/sql/plan/function/list_builtIn.go returns types.T_text.ToType() unconditionally. Its return bound can instead be derived from the declared input byte bound and Base64 expansion/line-wrap rules; large inputs may still require a LOB type.
Environment
MatrixOne: official main commit 0c3a04f390adaf6281fd592a49778ea5b1155e67
Activity
fix: preserve expression result metadata and coercion contracts (#28941)
Ariznawlll commentedon Sep 17, 2026
当前 main 复测未通过,转回 @XuPeng-SH 继续处理。
验证环境:本地单机 MatrixOne,由远端 main
0370bb4d6b118da29e164c54aa34ee010ed897bc全新构建;二进制 build info 已核对为该 SHA。声明修复本 issue 的 PR #28941(f6f8c0c885f999cbde3b0d394194b0a4a74176ae)已包含在该提交中。以下场景独立执行 3/3,结果一致。复现:
VARBINARY(128)输入经TO_BASE64进入 View 和 CTAS。两处b64仍为TEXT(0),character_maximum_length=65535;CREATE INDEX idx_b64 ON ctas(b64)稳定报ERROR 20105: not supported: TEXT column 'b64' cannot be in index。包含0x00、非 UTF-8 字节和 NULL 的标量值本身正确,因此问题仍是有实际影响的元数据/索引资格回归。期望是有界输入推导有界结果(MySQL 为
VARCHAR(174)),并允许 CTAS 列建立普通二级索引。当前验收未通过,issue 保持 Open。fix: preserve expression result metadata and coercion contracts (matr…
fix: preserve expression result metadata and coercion contracts (matr…
fix: close expression result contract regressions (#29075)
Ariznawlll commentedon Sep 20, 2026
测试版本
maind8ddce92b1c5c172111b50aefe6b6b200b2589cb原问题验证
验证
TO_BASE64(VARBINARY(128))经 View 和 CTAS 后的元数据。结果列为VARCHAR(174),不再退化为无界 TEXT/BLOB;在 CTAS 结果列上创建索引成功。连续执行 3 次通过。覆盖范围
边界与异常路径
X'00FF10'编码为预期AP8Q。自动化回归
issue_28902_to_base64_metadata.test。33/33成功。测试结论
测试通过。