From 0f502ac18b70b12892ae402a12bb6ddfae06b896 Mon Sep 17 00:00:00 2001 From: djklim87 Date: Thu, 9 May 2024 14:50:47 +0200 Subject: [PATCH] Alter table local option support --- src/PHPSQLParser/processors/TableProcessor.php | 3 ++- tests/cases/parser/manticoreCasesTest.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/PHPSQLParser/processors/TableProcessor.php b/src/PHPSQLParser/processors/TableProcessor.php index 155edf2c..35baf6d4 100644 --- a/src/PHPSQLParser/processors/TableProcessor.php +++ b/src/PHPSQLParser/processors/TableProcessor.php @@ -235,8 +235,9 @@ public function process($tokens) case 'TYPE': case 'STATS_AUTO_RECALC': case 'STATS_PERSISTENT': + case 'LOCAL': case 'KEY_BLOCK_SIZE': - if ($prevCategory === 'CREATE_DEF') { + if (in_array($prevCategory, ['CREATE_DEF', 'TABLE_NAME']) ) { $expr[] = $this->getReservedType($trim); $currCategory = $prevCategory = 'TABLE_OPTION'; continue 2; diff --git a/tests/cases/parser/manticoreCasesTest.php b/tests/cases/parser/manticoreCasesTest.php index e06841a3..18e1e979 100644 --- a/tests/cases/parser/manticoreCasesTest.php +++ b/tests/cases/parser/manticoreCasesTest.php @@ -129,7 +129,8 @@ public function manticoreQueryProvider(): array ["ALTER MV view_name suspended=1", 'ms_alter_table_3'], // End aliases ["ALTER TABLE old_table RENAME new_table", 'ms_alter_table_4'], - ["ALTER TABLE `old_table` RENAME `new_table`", 'ms_alter_table_5'] + ["ALTER TABLE `old_table` RENAME `new_table`", 'ms_alter_table_5'], + ["alter table `dist` local='t1' local='t3'", 'ms_alter_table_6'] ]; }