GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix parsing of backtick-enclosed table options by Ryujiyasu · Pull Request #644 · phpmyadmin/sql-parser

Conversation

@Ryujiyasu

@Ryujiyasu Ryujiyasu commented Feb 28, 2026

Copy link
Copy Markdown

Summary

  • Fix parsing of backtick-enclosed table options such as `PAGE_COMPRESSED`=1 produced by MariaDB
  • When a backtick-enclosed symbol token is encountered, a lookahead checks for = to distinguish option assignments from regular quoted identifiers (table/column names)
  • Uses $token->value (without backticks) for the option name lookup only when confirmed as an option

How it works

In OptionsArrays::parse(), the option name lookup used $token->token which includes backticks for quoted symbols. MariaDB outputs table options like `PAGE_COMPRESSED`=1, so the backtick-enclosed name never matched the TABLE_OPTIONS array.

The fix adds a targeted check: if the token is a backtick-enclosed symbol and the next non-whitespace token is =, it uses the unquoted $token->value for the lookup. This prevents false matches where quoted identifiers (e.g. `database` in ALTER TABLE `database`.`table`) could collide with option names like DATABASE.

Test plan

  • Added testBuilderCompressedBackticks test for backtick-enclosed PAGE_COMPRESSED and PAGE_COMPRESSION_LEVEL
  • All 1004 existing tests pass with no regressions

Fixes #643

🤖 Generated with Claude Code

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

williamdes reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@Ryujiyasu @claude
Fix parsing of backtick-enclosed table options
0cd9386
MariaDB encloses some table options in backticks by default
(e.g. `PAGE_COMPRESSED`=1). The option name lookup in
OptionsArrays::parse() used $token->token which includes the
backticks, causing the match against the options array to fail.

This adds a targeted check: when a backtick-enclosed symbol is
followed by '=', its unquoted value is used for the lookup.
A lookahead for '=' prevents regular quoted identifiers (such as
table or column names) from being mistaken for options.

Fixes phpmyadmin#643

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@williamdes

williamdes commented Mar 20, 2026

Copy link
Copy Markdown
Member

Thank you, I will get back to it
The workflows are approved

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@xmaks82

xmaks82 commented Oct 23, 2026

Copy link
Copy Markdown

I tried this branch with a few statements. A quoted identifier that is followed by = and has the name of a flag option is now taken as that option:

SELECT `distinct` = 1 FROM t      ->  SELECT distinct = 1 FROM t
SELECT `sql_no_cache` = 1 FROM t  ->  SELECT sql_no_cache = 1 FROM t

A flag option is never followed by =, so the unquoted name can be accepted only for options that take a value (var / var=):

if (
    isset($options[$unquoted])
    && is_array($options[$unquoted])
    && in_array($options[$unquoted][1], ['var', 'var='], true)
    && $nextToken === '='
) {
    $upper = $unquoted;
}

With this check on master, SELECT `distinct` = 1 FROM t, SELECT `distinct`, `all` FROM t, UPDATE `low_priority` SET a=1, DELETE `quick` FROM `quick` and SELECT @all := 1 are kept as written, `PAGE_COMPRESSED`='1' is parsed, and the test suite passes.

The same code path matters for #651: MariaDB 11.8 prints vector index options quoted, VECTOR KEY `v` (`v`) `M`='8' `DISTANCE`='cosine'.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@xmaks82 xmaks82 mentioned this pull request Oct 23, 2026
Fix #641 - Add VECTOR data type and VECTOR INDEX support #651
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Support PAGE_COMPRESSED=1`

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@Ryujiyasu @williamdes @xmaks82
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.