Fix hex string literal (x'...') parsing in CREATE TABLE DEFAULT values by predictor2718 · Pull Request #650 · phpmyadmin/sql-parser · GitHub
Skip to content

Fix hex string literal (x'...') parsing in CREATE TABLE DEFAULT values#650

Open
predictor2718 wants to merge 5 commits into
phpmyadmin:5.11.xfrom
predictor2718:fix/hex-literal-default
Open

Fix hex string literal (x'...') parsing in CREATE TABLE DEFAULT values#650
predictor2718 wants to merge 5 commits into
phpmyadmin:5.11.xfrom
predictor2718:fix/hex-literal-default

Conversation

@predictor2718

Copy link
Copy Markdown
Contributor

Summary

  • The lexer incorrectly tokenized x'...' hex string literals as two separate tokens (keyword x + string
    '...'), producing invalid SQL x AS '...' on rebuild
  • Added states 11-13 to the number parsing state machine (analogous to states 7-9 for b'...' binary literals) to
    recognize x'...' and X'...' as single hex string literal tokens
  • Added FLAG_NUMBER_HEX_STRING to prevent incorrect hexdec() conversion of the token value

Fixes #649

Signed-off-by: Nicolai Ehrhardt <245527909+predictor2718@users.noreply.github.com>
@codecov

codecov Bot commented Apr 12, 2026

Copy link
Copy Markdown

Signed-off-by: Nicolai Ehrhardt <245527909+predictor2718@users.noreply.github.com>
Signed-off-by: Nicolai Ehrhardt <245527909+predictor2718@users.noreply.github.com>
Signed-off-by: Nicolai Ehrhardt <245527909+predictor2718@users.noreply.github.com>
Signed-off-by: Nicolai Ehrhardt <245527909+predictor2718@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant