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.
Bug
The lexer incorrectly tokenizes hex string literals
x'...'as two separate tokens (keywordx+ string'...'),causing the builder to produce invalid SQL
x AS '...'instead ofx'...'.This affects
CREATE TABLEstatements with binary column defaults on MariaDB 11.8+ which outputsDEFAULT x'...'in
SHOW CREATE TABLE.The
b'...'binary string literal format is handled correctly — onlyx'...'is affected.To Reproduce
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.