Skip to content

Commit

Permalink
Alter table local option support (#7)
Browse files Browse the repository at this point in the history
* Alter table local option support

---------

Co-authored-by: djklim87 <[email protected]>
  • Loading branch information
djklim87 and djklim87 authored May 9, 2024
1 parent 2e0901f commit 0cbe7e5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/PHPSQLParser/processors/TableProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion tests/cases/parser/manticoreCasesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']

];
}
Expand Down
1 change: 1 addition & 0 deletions tests/expected/parser/ms_alter_table_6.serialized
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a:2:{s:5:"ALTER";a:3:{s:9:"expr_type";s:5:"table";s:9:"base_expr";s:5:"table";s:8:"sub_tree";a:1:{i:0;a:2:{s:9:"expr_type";s:8:"reserved";s:9:"base_expr";s:5:"table";}}}s:5:"TABLE";a:5:{s:9:"base_expr";s:6:"`dist`";s:4:"name";s:6:"`dist`";s:9:"no_quotes";a:2:{s:5:"delim";b:0;s:5:"parts";a:1:{i:0;s:4:"dist";}}s:10:"create-def";b:0;s:7:"options";a:2:{i:0;a:4:{s:9:"expr_type";s:10:"expression";s:9:"base_expr";s:10:"local='t1'";s:5:"delim";s:1:" ";s:8:"sub_tree";a:3:{i:0;a:2:{s:9:"expr_type";s:8:"reserved";s:9:"base_expr";s:5:"local";}i:1;a:2:{s:9:"expr_type";s:8:"operator";s:9:"base_expr";s:1:"=";}i:2;a:2:{s:9:"expr_type";s:5:"const";s:9:"base_expr";s:4:"'t1'";}}}i:1;a:4:{s:9:"expr_type";s:10:"expression";s:9:"base_expr";s:10:"local='t3'";s:5:"delim";s:1:" ";s:8:"sub_tree";a:3:{i:0;a:2:{s:9:"expr_type";s:8:"reserved";s:9:"base_expr";s:5:"local";}i:1;a:2:{s:9:"expr_type";s:8:"operator";s:9:"base_expr";s:1:"=";}i:2;a:2:{s:9:"expr_type";s:5:"const";s:9:"base_expr";s:4:"'t3'";}}}}}}

0 comments on commit 0cbe7e5

Please sign in to comment.