fix: accept VISIBLE/INVISIBLE index and column attributes in CREATE TABLE and CREATE INDEX - #2449
Open
aparajon wants to merge 1 commit into
Open
Conversation
…ABLE and CREATE INDEX MySQL 8.0 invisible indexes (KEY idx (col) INVISIBLE) and invisible columns failed to parse inside CREATE TABLE, and CREATE INDEX ... INVISIBLE failed too, because CreateParameter() did not accept the K_VISIBLE/K_INVISIBLE tokens. The ALTER TABLE productions already support them (JSQLParser#2076 was fixed for ALTER TABLE only, via JSQLParser#2234); this covers the CREATE statements, which share CreateParameter(). Tests cover index and column visibility, mixing visibility with other index options in either order, and quoted columns named visible/invisible. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Related to #2076
Problem
MySQL 8.0 index and column visibility attributes are valid syntax in CREATE TABLE and CREATE INDEX:
but both fail with
ParseException: Encountered unexpected token: "INVISIBLE". #2076 reported the same problem for ALTER TABLE and was fixed in #2234, but that fix covered the ALTER productions only — the CREATE statements parse their options throughCreateParameter(), which did not accept the two tokens.Making an index invisible is the usual first step before dropping it, so table definitions carrying a bare
INVISIBLEare common; today the only spelling that gets through the parser is the conditional comment/*!80000 INVISIBLE */, which is skipped as a comment.Fix
Adds
K_VISIBLEandK_INVISIBLEto theCreateParameter()alternation, following the same approach as the other MySQL index/column attributes there. The attributes are collected into the index spec / column specs like any other option and round-trip through the deparser. Both tokens already exist and stay supported in the ALTER productions from #2234, which use separate paths (IndexOption(),AlterExpressionColumnSetVisibility()).Tests
testCreateTableIndexVisibility—KEY ... INVISIBLEandUNIQUE KEY ... VISIBLE, asserting the index spectestCreateTableColumnVisibility— column-levelVISIBLE/INVISIBLE, asserting the column specstestCreateTableIndexVisibilityWithOtherIndexOptions— visibility combined withCOMMENTandUSING BTREEin either ordertestCreateTableQuotedColumnNamedVisible— backtick-quoted columns namedvisible/invisiblestill parse as identifierstestCreateIndexVisibility—CREATE INDEX ... VISIBLE/INVISIBLEFull test suite passes (4653 tests, 0 failures). JavaCC parser generation reports the same pre-existing warnings as master with no new choice conflicts.