Skip to content

Commit 662168e

Browse files
committed
Try to fix #404. Miss some unit tests.
1 parent 9306568 commit 662168e

15 files changed

Lines changed: 49 additions & 4031 deletions

src/Components/AlterOperation.php

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,47 @@ class AlterOperation extends Component
182182
*/
183183
public static $VIEW_OPTIONS = ['AS' => 1];
184184

185+
/**
186+
* All event options.
187+
*
188+
* @var array<string, int|array<int, int|string>>
189+
* @psalm-var array<string, (positive-int|array{positive-int, ('var'|'var='|'expr'|'expr=')})>
190+
*/
191+
public static $EVENT_OPTIONS = [
192+
'ON SCHEDULE' => 1,
193+
'EVERY' => [
194+
2,
195+
'expr',
196+
],
197+
'AT' => [
198+
2,
199+
'expr',
200+
],
201+
'STARTS' => [
202+
3,
203+
'expr',
204+
],
205+
'ENDS' => [
206+
4,
207+
'expr',
208+
],
209+
'ON COMPLETION PRESERVE' => 5,
210+
'ON COMPLETION NOT PRESERVE' => 5,
211+
'RENAME' => 6,
212+
'TO' => [
213+
7,
214+
'var',
215+
],
216+
'ENABLE' => 8,
217+
'DISABLE' => 8,
218+
'DISABLE ON SLAVE' => 8,
219+
'COMMENT' => [
220+
9,
221+
'var',
222+
],
223+
'DO' => 10,
224+
];
225+
185226
/**
186227
* Options of this operation.
187228
*
@@ -299,7 +340,9 @@ public static function parse(Parser $parser, TokensList $list, array $options =
299340
if ($state === 0) {
300341
$ret->options = OptionsArray::parse($parser, $list, $options);
301342

302-
if ($ret->options->has('AS')) {
343+
// Not only when aliasing but also when parsing the body of an event, we just list the tokens of the
344+
// body in the unknown tokens list, as they define their own statements.
345+
if ($ret->options->has('AS') || (isset($options['EVENT']) && $ret->options->has('DO'))) {
303346
for (; $list->idx < $list->count; ++$list->idx) {
304347
if ($list->tokens[$list->idx]->type === Token::TYPE_DELIMITER) {
305348
break;

src/Contexts/ContextMariaDb100000.php

Lines changed: 0 additions & 302 deletions
This file was deleted.

src/Contexts/ContextMariaDb100100.php

Lines changed: 0 additions & 350 deletions
This file was deleted.

src/Contexts/ContextMariaDb100200.php

Lines changed: 0 additions & 350 deletions
This file was deleted.

src/Contexts/ContextMariaDb100300.php

Lines changed: 0 additions & 350 deletions
This file was deleted.

src/Contexts/ContextMariaDb100400.php

Lines changed: 0 additions & 350 deletions
This file was deleted.

src/Contexts/ContextMariaDb100500.php

Lines changed: 0 additions & 350 deletions
This file was deleted.

src/Contexts/ContextMariaDb100600.php

Lines changed: 0 additions & 350 deletions
This file was deleted.

src/Contexts/ContextMySql50000.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ class ContextMySql50000 extends Context
151151
'DEFAULT CHARACTER SET' => 7,
152152
'NATURAL LEFT OUTER JOIN' => 7,
153153
'NATURAL RIGHT OUTER JOIN' => 7, 'WITH CONSISTENT SNAPSHOT' => 7,
154+
'ON COMPLETION PRESERVE' => 7, 'ON COMPLETION NOT PRESERVE' => 7,
155+
'ON SCHEDULE' => 7, 'DISABLE ON SLAVE' => 7,
154156

155157
'BIT' => 9, 'XML' => 9,
156158
'ENUM' => 9, 'JSON' => 9, 'TEXT' => 9,

src/Contexts/ContextMySql50100.php

Lines changed: 0 additions & 297 deletions
This file was deleted.

0 commit comments

Comments
 (0)