Skip to content

antlr/grammars-v4#4833 Add support for OPTIMIZE TABLES (plural form) to Oracle mysql grammar#4834

Merged
teverett merged 1 commit intoantlr:masterfrom
vsantonastaso:fix-tables-oracle-mysql
May 6, 2026
Merged

antlr/grammars-v4#4833 Add support for OPTIMIZE TABLES (plural form) to Oracle mysql grammar#4834
teverett merged 1 commit intoantlr:masterfrom
vsantonastaso:fix-tables-oracle-mysql

Conversation

@vsantonastaso
Copy link
Copy Markdown
Contributor

closes #4833

Fixes grammar to accept both OPTIMIZE TABLE (singular) and OPTIMIZE TABLES (plural) syntax, which are both valid in MySQL 8.0+ and 9.0+.

Issue

The Oracle MySQL grammar currently only accepts:

OPTIMIZE TABLE t1;
OPTIMIZE TABLE t1, t2;

But rejects the valid plural form:

OPTIMIZE TABLES t1;
OPTIMIZE TABLES t1, t2;

Error:

line 1:9 mismatched input 'TABLES' expecting {LOCAL_SYMBOL, NO_WRITE_TO_BINLOG_SYMBOL, TABLE_SYMBOL}

Verification

Tested against MySQL 8.0.46 and MySQL 9.0.1 - both forms work correctly:

-- Both forms work in real MySQL
mysql> OPTIMIZE TABLE t1;
+---------------+----------+----------+----------+
| Table         | Op       | Msg_type | Msg_text |
+---------------+----------+----------+----------+
| testdb.t1     | optimize | status   | OK       |
+---------------+----------+----------+----------+
1 row in set (0.02 sec)

mysql> OPTIMIZE TABLES t1;
+---------------+----------+----------+----------+
| Table         | Op       | Msg_type | Msg_text |
+---------------+----------+----------+----------+
| testdb.t1     | optimize | status   | OK       |
+---------------+----------+----------+----------+
1 row in set (0.01 sec)

Verification

Before fix:

OPTIMIZE TABLE t1;   -- ✅ Passes
OPTIMIZE TABLES t1;  -- ❌ Fails with parse error

After fix:

OPTIMIZE TABLE t1;   -- ✅ Passes
OPTIMIZE TABLES t1;  -- ✅ Passes

…tatement

Signed-off-by: vsantonastaso <vsantonastaso.dev@gmail.com>
@vsantonastaso
Copy link
Copy Markdown
Contributor Author

vsantonastaso commented May 6, 2026

@mike-lischke @kaby76 @teverett please take a look at it when you can

@teverett
Copy link
Copy Markdown
Member

teverett commented May 6, 2026

@vsantonastaso thanks!

@teverett teverett merged commit 3faede2 into antlr:master May 6, 2026
34 checks passed
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.

MySQL: Oracle grammar rejects valid OPTIMIZE TABLES (plural) syntax

2 participants