Hex string literal x'...' incorrectly parsed as keyword + string
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 70/100
Research direction
Start in the Lexer's number-parsing state machine, especially states 7-9 that handle b'...' literals, and compare them with how x is currently matched as a keyword. Re-run the provided Parser reproduction and confirm that the built CREATE TABLE statement preserves DEFAULT x'...' rather than producing x AS followed by a string.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- PHP
- Stars
- 485
- Forks
- 119
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from phpmyadmin/sql-parser
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
phpmyadmin/sql-parser#655 · 1 reaction ·
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
phpmyadmin/sql-parser#666 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 65/100
phpmyadmin/sql-parser#662 · 2 reactions ·
-
kind/support
Difficulty 3/5 1-2 days Newbie friendliness 45/100
phpmyadmin/sql-parser#653 · 1 reaction ·
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 25/100
phpmyadmin/sql-parser#643 · 1 comment ·
All issues in phpmyadmin/sql-parser
Similar issues
-
sync-en
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
-
sync-en
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
-
Перевод устарел
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
-
priority: p3
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
googleapis/librarian#7636 ·
-
0. Needs triage bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
nextcloud/fulltextsearch#1011 ·