Skip to content

fix: accept VISIBLE/INVISIBLE index and column attributes in CREATE TABLE and CREATE INDEX - #2449

Open
aparajon wants to merge 1 commit into
JSQLParser:masterfrom
aparajon:fix/create-table-index-visibility
Open

fix: accept VISIBLE/INVISIBLE index and column attributes in CREATE TABLE and CREATE INDEX#2449
aparajon wants to merge 1 commit into
JSQLParser:masterfrom
aparajon:fix/create-table-index-visibility

Conversation

@aparajon

@aparajon aparajon commented Aug 5, 2026

Copy link
Copy Markdown

Related to #2076

Problem

MySQL 8.0 index and column visibility attributes are valid syntax in CREATE TABLE and CREATE INDEX:

CREATE TABLE t1 (
  id bigint NOT NULL,
  secret varchar(10) INVISIBLE,
  KEY idx_id (id) INVISIBLE
);

CREATE INDEX idx_a ON t1 (a) INVISIBLE;

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 through CreateParameter(), 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 INVISIBLE are 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_VISIBLE and K_INVISIBLE to the CreateParameter() 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

  • testCreateTableIndexVisibilityKEY ... INVISIBLE and UNIQUE KEY ... VISIBLE, asserting the index spec
  • testCreateTableColumnVisibility — column-level VISIBLE/INVISIBLE, asserting the column specs
  • testCreateTableIndexVisibilityWithOtherIndexOptions — visibility combined with COMMENT and USING BTREE in either order
  • testCreateTableQuotedColumnNamedVisible — backtick-quoted columns named visible/invisible still parse as identifiers
  • testCreateIndexVisibilityCREATE INDEX ... VISIBLE/INVISIBLE

Full test suite passes (4653 tests, 0 failures). JavaCC parser generation reports the same pre-existing warnings as master with no new choice conflicts.

…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>
@aparajon aparajon changed the title Accept VISIBLE/INVISIBLE index and column attributes in CREATE TABLE and CREATE INDEX fix: accept VISIBLE/INVISIBLE index and column attributes in CREATE TABLE and CREATE INDEX Aug 5, 2026
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