Skip to content

Commit

Permalink
fix two more maria parser issues
Browse files Browse the repository at this point in the history
  • Loading branch information
osheroff committed Jun 5, 2024
1 parent f83e378 commit 6c25dc7
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/main/antlr4/imports/generate_tokens.rb
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,9 @@

START
TRANSACTION

WAIT
NOWAIT
)


Expand Down
7 changes: 5 additions & 2 deletions src/main/antlr4/imports/mysql_alter_table.g4
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ import mysql_literal_tokens, mysql_idents, column_definitions, mysql_partition;

alter_table: alter_table_preamble alter_specifications? alter_partition_specification? alter_post_flags?;

alter_table_preamble: ALTER alter_flags? TABLE table_name;
alter_table_preamble: ALTER alter_flags? TABLE table_name wait_flag?;
alter_flags: (ONLINE | OFFLINE | IGNORE);
wait_flag:
(WAIT integer | NOWAIT);


alter_specifications: alter_specification (',' alter_specification)*;
alter_specification:
Expand All @@ -31,7 +34,7 @@ change_column: CHANGE COLUMN? full_column_name column_definition col_position?;
if_exists: IF EXISTS;
drop_column: DROP COLUMN? if_exists? full_column_name CASCADE?;
modify_column: MODIFY COLUMN? column_definition col_position?;
drop_key: DROP FOREIGN? (INDEX|KEY) name;
drop_key: DROP FOREIGN? (INDEX|KEY) if_exists? name;
drop_primary_key: DROP PRIMARY KEY;
alter_rename_table: RENAME (TO | AS)? table_name;
convert_to_character_set: CONVERT TO charset_token charset_name collation?;
Expand Down
6 changes: 4 additions & 2 deletions src/main/antlr4/imports/mysql_literal_tokens.g4
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// This file is automatically generated by src/main/antlr4/imports/generate_tokens.rb
grammar mysql_literal_tokens;

tokens_available_for_names: (ACTION | AFTER | ALGORITHM | ALWAYS | ASCII | AUTO_INCREMENT | AVG_ROW_LENGTH | BEGIN | BIT | BOOL | BOOLEAN | BTREE | BYTE | CAST | CHARSET | CHECKSUM | COALESCE | COLUMNS | COLUMN_FORMAT | COMMENT | COMPACT | COMPRESSED | COMPRESSION | CONNECTION | COPY | DATA | DATE | DATETIME | DEFINER | DELAY_KEY_WRITE | DIRECTORY | DISABLE | DISCARD | DISK | DYNAMIC | ENABLE | ENCRYPTION | ENGINE | ENUM | EXCHANGE | EXCLUSIVE | FIRST | FIXED | FULL | GEOMETRY | GEOMETRYCOLLECTION | HASH | IMPORT | INPLACE | INSERT_METHOD | INSTANT | INVISIBLE | INVOKER | JSON | KEY_BLOCK_SIZE | LAST | LINESTRING | LIST | MAX_ROWS | MEMORY | MERGE | MIN_ROWS | MODIFY | MULTILINESTRING | MULTIPOINT | MULTIPOLYGON | NAME | NATIONAL | NCHAR | NO | NOCOPY | NONE | NOW | NVARCHAR | OFFLINE | ONLINE | PACK_KEYS | PARSER | PARTIAL | PARTITIONING | PARTITIONS | PASSWORD | POINT | POLYGON | REBUILD | REDUNDANT | REMOVE | REORGANIZE | REPAIR | ROW_FORMAT | SECURITY | SERIAL | SHARED | SIGNED | SIMPLE | SRID | START | STATS_AUTO_RECALC | STATS_PERSISTENT | STATS_SAMPLE_PAGES | STORAGE | SUBPARTITION | SUBPARTITIONS | TABLES | TABLESPACE | TEMPORARY | TEMPTABLE | TEXT | TIME | TIMESTAMP | TRANSACTION | TRUNCATE | UNDEFINED | UNICODE | UPGRADE | VALIDATION | VIEW | VISIBLE | WITHOUT | YEAR);
all_tokens: (ACTION | ADD | AFTER | ALGORITHM | ALTER | ALWAYS | ANALYZE | AS | ASC | ASCII | AUTO_INCREMENT | AVG_ROW_LENGTH | BEGIN | BIGINT | BINARY | BIT | BLOB | BOOL | BOOLEAN | BTREE | BY | BYTE | CASCADE | CAST | CHANGE | CHAR | CHARACTER | CHARSET | CHECK | CHECKSUM | COALESCE | COLLATE | COLUMN | COLUMNS | COLUMN_FORMAT | COMMENT | COMPACT | COMPRESSED | COMPRESSION | CONNECTION | CONSTRAINT | CONVERT | COPY | CREATE | CURRENT_TIMESTAMP | CURRENT_USER | DATA | DATABASE | DATE | DATETIME | DECIMAL | DEFAULT | DEFINER | DELAY_KEY_WRITE | DELETE | DESC | DIRECTORY | DISABLE | DISCARD | DISK | DOUBLE | DROP | DYNAMIC | ENABLE | ENCRYPTION | ENGINE | ENUM | EXCHANGE | EXCLUSIVE | EXISTS | FALSE | FIRST | FIXED | FLOAT | FLOAT4 | FLOAT8 | FORCE | FOREIGN | FULL | FULLTEXT | GENERATED | GEOMETRY | GEOMETRYCOLLECTION | HASH | IF | IGNORE | IMPORT | INDEX | INPLACE | INSERT_METHOD | INSTANT | INT | INT1 | INT2 | INT3 | INT4 | INT8 | INTEGER | INTO | INVISIBLE | INVOKER | JSON | KEY | KEYS | KEY_BLOCK_SIZE | LAST | LIKE | LINEAR | LINESTRING | LIST | LOCALTIME | LOCALTIMESTAMP | LOCK | LONG | LONGBLOB | LONGTEXT | MATCH | MAX_ROWS | MEDIUMBLOB | MEDIUMINT | MEDIUMTEXT | MEMORY | MERGE | MIDDLEINT | MIN_ROWS | MODIFY | MULTILINESTRING | MULTIPOINT | MULTIPOLYGON | NAME | NATIONAL | NCHAR | NO | NOCOPY | NONE | NOT | NOW | NULL | NUMERIC | NVARCHAR | OFFLINE | ON | ONLINE | OPTIMIZE | OR | ORDER | PACK_KEYS | PARSER | PARTIAL | PARTITION | PARTITIONING | PARTITIONS | PASSWORD | POINT | POLYGON | PRECISION | PRIMARY | RANGE | REAL | REBUILD | REDUNDANT | REFERENCES | REMOVE | RENAME | REORGANIZE | REPAIR | REPLACE | RESTRICT | ROW_FORMAT | SCHEMA | SECURITY | SERIAL | SET | SHARED | SIGNED | SIMPLE | SMALLINT | SPATIAL | SQL | SRID | START | STATS_AUTO_RECALC | STATS_PERSISTENT | STATS_SAMPLE_PAGES | STORAGE | STORED | SUBPARTITION | SUBPARTITIONS | TABLE | TABLES | TABLESPACE | TEMPORARY | TEMPTABLE | TEXT | TIME | TIMESTAMP | TINYBLOB | TINYINT | TINYTEXT | TO | TRANSACTION | TRUE | TRUNCATE | UNDEFINED | UNICODE | UNION | UNIQUE | UNSIGNED | UPDATE | UPGRADE | USING | VALIDATION | VARBINARY | VARCHAR | VARYING | VIEW | VIRTUAL | VISIBLE | WITH | WITHOUT | YEAR | ZEROFILL);
tokens_available_for_names: (ACTION | AFTER | ALGORITHM | ALWAYS | ASCII | AUTO_INCREMENT | AVG_ROW_LENGTH | BEGIN | BIT | BOOL | BOOLEAN | BTREE | BYTE | CAST | CHARSET | CHECKSUM | COALESCE | COLUMNS | COLUMN_FORMAT | COMMENT | COMPACT | COMPRESSED | COMPRESSION | CONNECTION | COPY | DATA | DATE | DATETIME | DEFINER | DELAY_KEY_WRITE | DIRECTORY | DISABLE | DISCARD | DISK | DYNAMIC | ENABLE | ENCRYPTION | ENGINE | ENUM | EXCHANGE | EXCLUSIVE | FIRST | FIXED | FULL | GEOMETRY | GEOMETRYCOLLECTION | HASH | IMPORT | INPLACE | INSERT_METHOD | INSTANT | INVISIBLE | INVOKER | JSON | KEY_BLOCK_SIZE | LAST | LINESTRING | LIST | MAX_ROWS | MEMORY | MERGE | MIN_ROWS | MODIFY | MULTILINESTRING | MULTIPOINT | MULTIPOLYGON | NAME | NATIONAL | NCHAR | NO | NOCOPY | NONE | NOW | NOWAIT | NVARCHAR | OFFLINE | ONLINE | PACK_KEYS | PARSER | PARTIAL | PARTITIONING | PARTITIONS | PASSWORD | POINT | POLYGON | REBUILD | REDUNDANT | REMOVE | REORGANIZE | REPAIR | ROW_FORMAT | SECURITY | SERIAL | SHARED | SIGNED | SIMPLE | SRID | START | STATS_AUTO_RECALC | STATS_PERSISTENT | STATS_SAMPLE_PAGES | STORAGE | SUBPARTITION | SUBPARTITIONS | TABLES | TABLESPACE | TEMPORARY | TEMPTABLE | TEXT | TIME | TIMESTAMP | TRANSACTION | TRUNCATE | UNDEFINED | UNICODE | UPGRADE | VALIDATION | VIEW | VISIBLE | WAIT | WITHOUT | YEAR);
all_tokens: (ACTION | ADD | AFTER | ALGORITHM | ALTER | ALWAYS | ANALYZE | AS | ASC | ASCII | AUTO_INCREMENT | AVG_ROW_LENGTH | BEGIN | BIGINT | BINARY | BIT | BLOB | BOOL | BOOLEAN | BTREE | BY | BYTE | CASCADE | CAST | CHANGE | CHAR | CHARACTER | CHARSET | CHECK | CHECKSUM | COALESCE | COLLATE | COLUMN | COLUMNS | COLUMN_FORMAT | COMMENT | COMPACT | COMPRESSED | COMPRESSION | CONNECTION | CONSTRAINT | CONVERT | COPY | CREATE | CURRENT_TIMESTAMP | CURRENT_USER | DATA | DATABASE | DATE | DATETIME | DECIMAL | DEFAULT | DEFINER | DELAY_KEY_WRITE | DELETE | DESC | DIRECTORY | DISABLE | DISCARD | DISK | DOUBLE | DROP | DYNAMIC | ENABLE | ENCRYPTION | ENGINE | ENUM | EXCHANGE | EXCLUSIVE | EXISTS | FALSE | FIRST | FIXED | FLOAT | FLOAT4 | FLOAT8 | FORCE | FOREIGN | FULL | FULLTEXT | GENERATED | GEOMETRY | GEOMETRYCOLLECTION | HASH | IF | IGNORE | IMPORT | INDEX | INPLACE | INSERT_METHOD | INSTANT | INT | INT1 | INT2 | INT3 | INT4 | INT8 | INTEGER | INTO | INVISIBLE | INVOKER | JSON | KEY | KEYS | KEY_BLOCK_SIZE | LAST | LIKE | LINEAR | LINESTRING | LIST | LOCALTIME | LOCALTIMESTAMP | LOCK | LONG | LONGBLOB | LONGTEXT | MATCH | MAX_ROWS | MEDIUMBLOB | MEDIUMINT | MEDIUMTEXT | MEMORY | MERGE | MIDDLEINT | MIN_ROWS | MODIFY | MULTILINESTRING | MULTIPOINT | MULTIPOLYGON | NAME | NATIONAL | NCHAR | NO | NOCOPY | NONE | NOT | NOW | NOWAIT | NULL | NUMERIC | NVARCHAR | OFFLINE | ON | ONLINE | OPTIMIZE | OR | ORDER | PACK_KEYS | PARSER | PARTIAL | PARTITION | PARTITIONING | PARTITIONS | PASSWORD | POINT | POLYGON | PRECISION | PRIMARY | RANGE | REAL | REBUILD | REDUNDANT | REFERENCES | REMOVE | RENAME | REORGANIZE | REPAIR | REPLACE | RESTRICT | ROW_FORMAT | SCHEMA | SECURITY | SERIAL | SET | SHARED | SIGNED | SIMPLE | SMALLINT | SPATIAL | SQL | SRID | START | STATS_AUTO_RECALC | STATS_PERSISTENT | STATS_SAMPLE_PAGES | STORAGE | STORED | SUBPARTITION | SUBPARTITIONS | TABLE | TABLES | TABLESPACE | TEMPORARY | TEMPTABLE | TEXT | TIME | TIMESTAMP | TINYBLOB | TINYINT | TINYTEXT | TO | TRANSACTION | TRUE | TRUNCATE | UNDEFINED | UNICODE | UNION | UNIQUE | UNSIGNED | UPDATE | UPGRADE | USING | VALIDATION | VARBINARY | VARCHAR | VARYING | VIEW | VIRTUAL | VISIBLE | WAIT | WITH | WITHOUT | YEAR | ZEROFILL);

ACTION: A C T I O N;
ADD: A D D;
Expand Down Expand Up @@ -141,6 +141,7 @@ NOCOPY: N O C O P Y;
NONE: N O N E;
NOT: N O T;
NOW: N O W;
NOWAIT: N O W A I T;
NULL: N U L L;
NUMERIC: N U M E R I C;
NVARCHAR: N V A R C H A R;
Expand Down Expand Up @@ -222,6 +223,7 @@ VARYING: V A R Y I N G;
VIEW: V I E W;
VIRTUAL: V I R T U A L;
VISIBLE: V I S I B L E;
WAIT: W A I T;
WITH: W I T H;
WITHOUT: W I T H O U T;
YEAR: Y E A R;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,10 @@ public void testParsingSomeAlters() {
"alter table test.c ALGORITHM=COPY, STATS_SAMPLE_PAGES=DEFAULT",
"ALTER TABLE vehicles " +
"DROP INDEX IF EXISTS uq_vehicles_oem_id_oem_vin," +
"ALGORITHM=NOCOPY, LOCK=NONE"
"ALGORITHM=NOCOPY, LOCK=NONE",
"ALTER TABLE foo drop foreign key if exists foobar",
"ALTER TABLE table_foo WAIT 30 ADD COLUMN my_column INTEGER, ALGORITHM=INSTANT, LOCK=NONE"


};

Expand Down

0 comments on commit 6c25dc7

Please sign in to comment.