| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
…tion MySQL allows a key part to carry both a prefix length and a sort direction, e.g. "CREATE INDEX i ON t (c1(20) DESC)". IndexColumnWithParams() accepted at most one optional CreateParameter() per key part, so the prefix length consumed it and the following ASC/DESC could not be matched. Collect the parameters in a loop instead. IndexColumnsWithParamsList() is shared by the CREATE INDEX and the ALTER TABLE ADD INDEX paths, so both are fixed. Refs JSQLParser#2490
Several valid MySQL index DDL statements were rejected because their option keywords are tokens of their own and were therefore not reachable from the option lists that CREATE INDEX and DROP INDEX use: CREATE INDEX i ON t (c1) KEY_BLOCK_SIZE = 8 CREATE INDEX i ON t (c1) ALGORITHM = INPLACE LOCK = NONE CREATE FULLTEXT INDEX i ON t (body) WITH PARSER ngram CREATE SPATIAL INDEX i ON t (g) DROP INDEX i ON t ALGORITHM = INPLACE LOCK = NONE The keywords are added to the existing flat token lists of CreateParameter() and Drop() rather than as new grammar alternatives, so no new choice is introduced and the JavaCC warning count is unchanged. LOCK is the one exception: it also starts a LOCK TABLE statement, so taking it unconditionally as a DROP argument would be ambiguous with the next statement. It is guarded by a semantic lookahead that only accepts it when it is not followed by TABLE. Refs JSQLParser#2490
…mnWithParams Rename the accumulator to columnParams and keep parameter for the result of a single CreateParameter(), matching how the other CreateParameter() loops in the grammar name them. Collect eagerly and pass null only when no option was parsed, because ColumnParams renders a separating space for a non-null list.
|
Much nicer now, thank you for work and effort! |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Refs #2490
Description
Fixes five of the six groups of MySQL index DDL reported in #2490. These now parse:
Two causes:
No new grammar ambiguity
Those keywords all live in NonReservedWord(), so adding them as new alternatives to the trailing (...)* loops pushed JavaCC from 13 to 15 choice-conflict warnings, and explicit syntactic LOOKAHEAD did not help. They are instead added to the existing flat token lists of CreateParameter() and Drop(), which adds no new choice point and leaves the warning count unchanged.
LOCK is the one real ambiguity, since it also starts a LOCK TABLE statement. It is guarded so it is only taken as a DROP argument when it cannot begin the next statement:
Scope
Group 6 (CAST(... AS UNSIGNED ARRAY) for multi-valued indexes) is not included: it needs an ARRAY marker on the public ColDataType model, and K_ARRAY_LITERAL is already used in six other places. Better as its own PR, so #2490 stays open.
Testing
Deparsing follows the existing conventions: c1 (20) DESC (matching the mycol2 (75) output already asserted in CreateIndexTest) and KEY_BLOCK_SIZE = 8. All statements above were verified against MySQL 8.4.11 while writing #2490.
PR Checklist