Skip to content

Commit

Permalink
Alter table local option support
Browse files Browse the repository at this point in the history
  • Loading branch information
djklim87 committed May 9, 2024
1 parent 0cbe7e5 commit 3739fef
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/PHPSQLParser/processors/TableProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ public function process($tokens)
case 'STATS_AUTO_RECALC':
case 'STATS_PERSISTENT':
case 'LOCAL':
case 'AGENT':
case 'KEY_BLOCK_SIZE':
if (in_array($prevCategory, ['CREATE_DEF', 'TABLE_NAME']) ) {
$expr[] = $this->getReservedType($trim);
Expand Down
2 changes: 1 addition & 1 deletion tests/cases/parser/manticoreCasesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public function manticoreQueryProvider(): array
// 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 `dist` local='t1' local='t3'", 'ms_alter_table_6']
["alter table `dist` local='t1' agent='127.0.0.1:9312:remote_index' local='t3'", 'ms_alter_table_6']

];
}
Expand Down
2 changes: 1 addition & 1 deletion tests/expected/parser/ms_alter_table_6.serialized
Original file line number Diff line number Diff line change
@@ -1 +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'";}}}}}}
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:3:{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:35:"agent='127.0.0.1:9312:remote_index'";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:"agent";}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:29:"'127.0.0.1:9312:remote_index'";}}}i:2;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 3739fef

Please sign in to comment.