Hex string literal x'...' incorrectly parsed as keyword + string
还没有人认领这个 Issue。
评估
调研方向
从 Lexer 的数字解析状态机入手,尤其关注处理 b'...' 字面量的状态 7-9,并将其与当前将 x 匹配为关键字的方式进行比较。重新运行提供的 Parser 复现,并确认生成的 CREATE TABLE 语句保留 DEFAULT x'...',而不是生成 x AS 后跟一个字符串。
由索引模型根据 Issue 内容生成。
描述
Bug
The lexer incorrectly tokenizes hex string literals x'...' as two separate tokens (keyword x + string '...'),
causing the builder to produce invalid SQL x AS '...' instead of x'...'.
This affects CREATE TABLE statements with binary column defaults on MariaDB 11.8+ which outputs DEFAULT x'...'
in SHOW CREATE TABLE.
The b'...' binary string literal format is handled correctly — only x'...' is affected.
To Reproduce
$parser = new Parser("CREATE TABLE test (IP binary(16) NOT NULL DEFAULT x'00000000000000000000000000000000')");
echo $parser->statements[0]->build();
// Output: ... DEFAULT x AS `00000000000000000000000000000000`
// Expected: ... DEFAULT x'00000000000000000000000000000000'
Affected versions
Both 5.11.x and master.
Root cause
The Lexer's number parsing state machine has states 7-9 for b'...' binary literals, but no equivalent states for
x'...' hex string literals. The x is instead matched as a keyword.
- 主要语言
- PHP
- 星标
- 485
- 派生
- 119
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
phpmyadmin/sql-parser 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
phpmyadmin/sql-parser#655 · 1 个 reaction ·
-
难度 3/5 1-2 天 新手友好度 55/100
phpmyadmin/sql-parser#666 ·
-
难度 3/5 1-2 天 新手友好度 65/100
phpmyadmin/sql-parser#662 · 2 个 reaction ·
-
kind/support
难度 3/5 1-2 天 新手友好度 45/100
phpmyadmin/sql-parser#653 · 1 个 reaction ·
-
bug
难度 3/5 1-2 天 新手友好度 25/100
phpmyadmin/sql-parser#643 · 1 条评论 ·
查看 phpmyadmin/sql-parser 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 85/100
-
a11y admissions.uiowa.edu needs grooming SiteImprove best practice
难度 2/5 1-3 小时 新手友好度 70/100
-
Save States Menu 未关闭
难度 2/5 1-3 小时 新手友好度 68/100
-
难度 2/5 1-3 小时 新手友好度 68/100
-
难度 2/5 1-3 小时 新手友好度 84/100
pluginsGLPI/datainjection#673 ·