From f56b0273e011b3a22ad57365973f7437159d43f2 Mon Sep 17 00:00:00 2001 From: "Fawzi E. Abdulfattah" Date: Sun, 5 Dec 2021 23:57:41 +0200 Subject: [PATCH 01/12] Refactoring and improving the support of the WITH statement and making other statements aware of it Signed-off-by: Fawzi E. Abdulfattah --- src/Statements/CreateStatement.php | 46 +- src/Statements/InsertStatement.php | 2 + src/Statements/WithStatement.php | 157 +- tests/Builder/CreateStatementTest.php | 36 +- tests/Parser/WithStatementTest.php | 3 +- tests/data/parser/parseCreateViewAsWithAs.out | 1297 ++++++------ tests/data/parser/parseWithStatement.in | 1 + tests/data/parser/parseWithStatement.out | 1547 +++++++++++++++ tests/data/parser/parseWithStatement2.in | 1 + tests/data/parser/parseWithStatement2.out | 1731 +++++++++++++++++ tests/data/parser/parseWithStatement3.in | 1 + tests/data/parser/parseWithStatement3.out | 1408 ++++++++++++++ 12 files changed, 5510 insertions(+), 720 deletions(-) create mode 100644 tests/data/parser/parseWithStatement.in create mode 100644 tests/data/parser/parseWithStatement.out create mode 100644 tests/data/parser/parseWithStatement2.in create mode 100644 tests/data/parser/parseWithStatement2.out create mode 100644 tests/data/parser/parseWithStatement3.in create mode 100644 tests/data/parser/parseWithStatement3.out diff --git a/src/Statements/CreateStatement.php b/src/Statements/CreateStatement.php index 3a5bffef3..694a5e79f 100644 --- a/src/Statements/CreateStatement.php +++ b/src/Statements/CreateStatement.php @@ -310,6 +310,17 @@ class CreateStatement extends Statement */ public $fields; + /** + * If `CREATE TABLE WITH`. + * If `CREATE TABLE AS WITH`. + * If `CREATE VIEW AS ` WITH`. + * + * Used by `CREATE TABLE`, `CREATE VIEW` + * + * @var WithStatement|null + */ + public $with; + /** * If `CREATE TABLE ... SELECT`. * If `CREATE VIEW AS ` ... SELECT`. @@ -465,10 +476,17 @@ public function build() . OptionsArray::build($this->entityOptions) . $partition; } elseif ($this->options->has('VIEW')) { + $builtStatement = ''; + if ($this->select) { + $builtStatement = $this->select->build(); + } elseif ($this->with) { + $builtStatement = $this->with->build(); + } + return 'CREATE ' . OptionsArray::build($this->options) . ' ' . Expression::build($this->name) . ' ' - . $fields . ' AS ' . ($this->select ? $this->select->build() : '') + . $fields . ' AS ' . $builtStatement . (! empty($this->body) ? TokensList::build($this->body) : '') . ' ' . OptionsArray::build($this->entityOptions); } elseif ($this->options->has('TRIGGER')) { @@ -546,14 +564,22 @@ public function parse(Parser $parser, TokensList $list) if (($token->type === Token::TYPE_KEYWORD) && ($token->keyword === 'SELECT')) { /* CREATE TABLE ... SELECT */ $this->select = new SelectStatement($parser, $list); + } elseif (($token->type === Token::TYPE_KEYWORD) && ($token->keyword === 'WITH')) { + /* CREATE TABLE WITH */ + $this->with = new WithStatement($parser, $list); } elseif ( ($token->type === Token::TYPE_KEYWORD) && ($token->keyword === 'AS') && ($list->tokens[$nextidx]->type === Token::TYPE_KEYWORD) - && ($list->tokens[$nextidx]->value === 'SELECT') ) { - /* CREATE TABLE ... AS SELECT */ - $list->idx = $nextidx; - $this->select = new SelectStatement($parser, $list); + if ($list->tokens[$nextidx]->value === 'SELECT') { + /* CREATE TABLE ... AS SELECT */ + $list->idx = $nextidx; + $this->select = new SelectStatement($parser, $list); + } elseif ($list->tokens[$nextidx]->value === 'SELECT') { + /* CREATE TABLE WITH */ + $list->idx = $nextidx; + $this->select = new WithStatement($parser, $list); + } } elseif ($token->type === Token::TYPE_KEYWORD && $token->keyword === 'LIKE') { /* CREATE TABLE `new_tbl` LIKE 'orig_tbl' */ $list->idx = $nextidx; @@ -711,10 +737,14 @@ public function parse(Parser $parser, TokensList $list) $token->type === Token::TYPE_KEYWORD && $token->keyword === 'AS' && $list->tokens[$nextidx]->type === Token::TYPE_KEYWORD - && $list->tokens[$nextidx]->value === 'SELECT' ) { - $list->idx = $nextidx; - $this->select = new SelectStatement($parser, $list); + if ($list->tokens[$nextidx]->value === 'SELECT') { + $list->idx = $nextidx; + $this->select = new SelectStatement($parser, $list); + } elseif ($list->tokens[$nextidx]->value === 'WITH') { + ++$list->idx; + $this->with = new WithStatement($parser, $list); + } } // Parsing all other tokens diff --git a/src/Statements/InsertStatement.php b/src/Statements/InsertStatement.php index 48df4730c..6ecc982f8 100644 --- a/src/Statements/InsertStatement.php +++ b/src/Statements/InsertStatement.php @@ -210,6 +210,8 @@ public function parse(Parser $parser, TokensList $list) $this->set = SetOperation::parse($parser, $list); } elseif ($token->keyword === 'SELECT') { $this->select = new SelectStatement($parser, $list); + } elseif ($token->keyword === 'WITH') { + $this->select = new WithStatement($parser, $list); } else { $parser->error('Unexpected keyword.', $token); break; diff --git a/src/Statements/WithStatement.php b/src/Statements/WithStatement.php index 92cfb79b0..186da3287 100644 --- a/src/Statements/WithStatement.php +++ b/src/Statements/WithStatement.php @@ -66,26 +66,34 @@ final class WithStatement extends Statement */ public function parse(Parser $parser, TokensList $list) { - ++$list->idx; // Skipping `WITH`. - - // parse any options if provided - $this->options = OptionsArray::parse($parser, $list, static::$OPTIONS); - ++$list->idx; - /** * The state of the parser. * * Below are the states of the parser. * * 0 ---------------- [ name ] -----------------> 1 - * 1 -------------- [( columns )] AS ----------------> 2 - * 2 ------------------ [ , ] --------------------> 0 + * + * 1 ------------------ [ ( ] ------------------> 2 + * + * 2 ------------------ [ AS ] -----------------> 3 + * + * 3 ------------------ [ ( ] ------------------> 4 + * + * 4 ------------------ [ , ] ------------------> 1 + * + * 4 ----- [ SELECT/UPDATE/DELETE/INSERT ] -----> 5 * * @var int */ $state = 0; $wither = null; + ++$list->idx; // Skipping `WITH`. + + // parse any options if provided + $this->options = OptionsArray::parse($parser, $list, static::$OPTIONS); + ++$list->idx; + for (; $list->idx < $list->count; ++$list->idx) { /** * Token parsed at this moment. @@ -99,57 +107,126 @@ public function parse(Parser $parser, TokensList $list) continue; } - if ($token->type === Token::TYPE_NONE) { - $wither = $token->value; - $this->withers[$wither] = new WithKeyword($wither); - $state = 1; - continue; - } - - if ($state === 1) { - if ($token->value === '(') { + if ($state === 0) { + if ($token->type === Token::TYPE_NONE) { + $wither = $token->value; + $this->withers[$wither] = new WithKeyword($wither); + $state = 1; + } else { + $parser->error('The name of the CTE was expected.', $token); + } + } elseif ($state === 1) { + if ($token->type === Token::TYPE_OPERATOR && $token->value === '(') { $this->withers[$wither]->columns = Array2d::parse($parser, $list); - continue; + $state = 2; + } elseif ($token->type === Token::TYPE_KEYWORD && $token->keyword === 'AS') { + $state = 3; + } else { + $parser->error('Unexpected token.', $token); + break; + } + } elseif ($state === 2) { + if (! ($token->type === Token::TYPE_KEYWORD && $token->keyword === 'AS')) { + $parser->error('AS keyword was expected.', $token); + break; } - if ($token->keyword === 'AS') { - ++$list->idx; - $state = 2; + $state = 3; + } elseif ($state === 3) { + if ($token->value !== '(') { + $parser->error('Subquery of the CTE was expected.', $token); + break; + } + + ++$list->idx; + $subList = $this->getSubTokenList($list); + if ($subList instanceof ParserException) { + $parser->errors[] = $subList; continue; } - } elseif ($state === 2) { - if ($token->value === '(') { - ++$list->idx; - $subList = $this->getSubTokenList($list); - if ($subList instanceof ParserException) { - $parser->errors[] = $subList; - continue; - } - $subParser = new Parser($subList); + $subParser = new Parser($subList); - if (count($subParser->errors)) { - foreach ($subParser->errors as $error) { - $parser->errors[] = $error; - } + if (count($subParser->errors)) { + foreach ($subParser->errors as $error) { + $parser->errors[] = $error; } - - $this->withers[$wither]->statement = $subParser; - continue; } - // There's another WITH expression to parse, go back to state=0 + $this->withers[$wither]->statement = $subParser; + + $state = 4; + } elseif ($state === 4) { if ($token->value === ',') { - $list->idx++; + // There's another WITH expression to parse, go back to state=0 $state = 0; continue; } - // No more WITH expressions, we're done with this statement + if ( + $token->type === Token::TYPE_KEYWORD && ( + $token->value === 'SELECT' + || $token->value === 'INSERT' + || $token->value === 'UPDATE' + || $token->value === 'DELETE' + ) + ) { + $state = 5; + --$list->idx; + continue; + } + + $parser->error('An expression was expected.', $token); + break; + } elseif ($state === 5) { + /** + * We need to parse all of the remaining tokens becuase mostly, they are only the CTE expression + * which's mostly is SELECT, or INSERT, UPDATE, or delete statement. + * e.g: INSERT .. ( SELECT 1 ) SELECT col1 FROM cte ON DUPLICATE KEY UPDATE col_name = 3. + * The issue is that, `ON DUPLICATE KEY UPDATE col_name = 3` is related to the main INSERT query + * not the cte expression (SELECT col1 FROM cte) we need to determine the end of the expression + * to parse `ON DUPLICATE KEY UPDATE` from the InsertStatement parser instead. + */ + + // Index of the last parsed token by default would be the last token in the $list, because we're + // assuming that all remaining tokens at state 4, are related to the expression. + $idxOfLastParsedToken = $list->count - 1; + // Index before search to be able to restore the index. + $idxBeforeSearch = $list->idx; + // Length of expression tokens is null by default, in order for the $subList to start + // from $list->idx to the end of the $list. + $lengthOfExpressionTokens = null; + + if ($list->getNextOfTypeAndValue(Token::TYPE_KEYWORD, 'ON')) { + // (-1) because getNextOfTypeAndValue returned ON and increased the index. + $idxOfOn = $list->idx - 1; + // Index of the last parsed token will be the token before the ON Keyword, therefore $idxOfOn - 1. + $idxOfLastParsedToken = $idxOfOn - 1; + // The length of the expression tokens would be the position of + $lengthOfExpressionTokens = $idxOfOn - $idxBeforeSearch; + } + + // Restore the index + $list->idx = $idxBeforeSearch; + + $subList = new TokensList(array_slice($list->tokens, $list->idx, $lengthOfExpressionTokens)); + $subParser = new Parser($subList); + if (count($subParser->errors)) { + foreach ($subParser->errors as $error) { + $parser->errors[] = $error; + } + } + + $list->idx = $idxOfLastParsedToken; break; } } + // 5 is the only valid end state + if ($state !== 5) { + $parser->error('Unexpected end of WITH CTE.', $token); + } + --$list->idx; } diff --git a/tests/Builder/CreateStatementTest.php b/tests/Builder/CreateStatementTest.php index 84c5601e6..0e8ac655c 100644 --- a/tests/Builder/CreateStatementTest.php +++ b/tests/Builder/CreateStatementTest.php @@ -343,16 +343,11 @@ public function testBuilderViewComplex(): void $stmt = $parser->statements[0]; $this->assertEquals( - 'CREATE VIEW withclause AS ' . "\n" - . "\n" - . 'WITH cte AS (' . "\n" - . 'SELECT p.name, p.shape' . "\n" - . 'FROM gis_all as p' . "\n" - . ')' . "\n" - . "\n" - . 'SELECT cte.*' . "\n" - . 'FROM cte' . "\n" - . 'CROSS JOIN gis_all ', + 'CREATE VIEW withclause AS ' + . 'WITH cte AS (' + . 'SELECT p.name, p.shape' + . ' FROM gis_all AS `p`' + . ') ', $stmt->build() ); $parser = new Parser( @@ -373,19 +368,14 @@ public function testBuilderViewComplex(): void $stmt = $parser->statements[0]; $this->assertEquals( - 'CREATE VIEW withclause2 AS ' . "\n" - . "\n" - . 'WITH cte AS (' . "\n" - . "\t" . 'SELECT p.name, p.shape' . "\n" - . "\t" . 'FROM gis_all as p' . "\n" - . '), cte2 AS (' . "\n" - . "\t" . 'SELECT p.name as n2, p.shape as sh2' . "\n" - . "\t" . 'FROM gis_all as p' . "\n" - . ')' . "\n" - . "\n" - . 'SELECT cte.*,cte2.*' . "\n" - . 'FROM cte,cte2' . "\n" - . 'CROSS JOIN gis_all ', + 'CREATE VIEW withclause2 AS ' + . 'WITH cte AS (' + . 'SELECT p.name, p.shape' + . ' FROM gis_all AS `p`' + . '), cte2 AS (' + . 'SELECT p.name AS `n2`, p.shape AS `sh2`' + . ' FROM gis_all AS `p`' + . ') ', $stmt->build() ); } diff --git a/tests/Parser/WithStatementTest.php b/tests/Parser/WithStatementTest.php index e6b0764c4..8e1a7110e 100644 --- a/tests/Parser/WithStatementTest.php +++ b/tests/Parser/WithStatementTest.php @@ -30,7 +30,7 @@ public function testWith(): void $parser = new Parser($lexer->list); $parserErrors = $this->getErrorsAsArray($parser); $this->assertCount(0, $parserErrors); - $this->assertCount(2, $parser->statements); + $this->assertCount(1, $parser->statements); // phpcs:disable Generic.Files.LineLength.TooLong $expected = <<assertEquals($expected, $parser->statements[0]->build()); - $this->assertEquals('SELECT * FROM categories', $parser->statements[1]->build()); } public function testWithHasErrors(): void diff --git a/tests/data/parser/parseCreateViewAsWithAs.out b/tests/data/parser/parseCreateViewAsWithAs.out index 12415be87..db43cdd6e 100644 --- a/tests/data/parser/parseCreateViewAsWithAs.out +++ b/tests/data/parser/parseCreateViewAsWithAs.out @@ -1910,7 +1910,8 @@ "OR": 1, "XOR": 1, "NOT": 1, - "MOD": 1 + "MOD": 1, + "OVER": 2 }, "database": null, "table": "withclause", @@ -1922,397 +1923,655 @@ }, "entityOptions": null, "fields": null, - "select": null, - "like": null, - "partitionBy": null, - "partitionsNum": null, - "subpartitionBy": null, - "subpartitionsNum": null, - "partitions": null, - "table": null, - "return": null, - "parameters": null, - "body": [ - { - "@type": "@11" - }, - { - "@type": "@12" - }, - { - "@type": "@13" - }, - { - "@type": "@14" - }, - { - "@type": "@15" - }, - { - "@type": "@16" - }, - { - "@type": "@17" - }, - { - "@type": "@18" - }, - { - "@type": "@19" - }, - { - "@type": "@20" - }, - { - "@type": "@21" - }, - { - "@type": "@22" - }, - { - "@type": "@23" - }, - { - "@type": "@24" - }, - { - "@type": "@25" - }, - { - "@type": "@26" - }, - { - "@type": "@27" - }, - { - "@type": "@28" - }, - { - "@type": "@29" - }, - { - "@type": "@30" - }, - { - "@type": "@31" - }, - { - "@type": "@32" - }, - { - "@type": "@33" - }, - { - "@type": "@34" - }, - { - "@type": "@35" - }, - { - "@type": "@36" - }, - { - "@type": "@37" - }, - { - "@type": "@38" - }, - { - "@type": "@39" - }, - { - "@type": "@40" - }, - { - "@type": "@41" - }, - { - "@type": "@42" - }, - { - "@type": "@43" - }, - { - "@type": "@44" - }, - { - "@type": "@45" - }, - { - "@type": "@46" - }, - { - "@type": "@47" - }, - { - "@type": "@48" - }, - { - "@type": "@49" - }, - { - "@type": "@50" - }, - { - "@type": "@51" - }, - { - "@type": "@52" - }, - { - "@type": "@53" - } - ], - "CLAUSES": [], - "END_OPTIONS": [], - "options": { - "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "with": { + "@type": "PhpMyAdmin\\SqlParser\\Statements\\WithStatement", + "OPTIONS": { + "RECURSIVE": 1 + }, + "CLAUSES": { + "WITH": [ + "WITH", + 2 + ], + "_OPTIONS": [ + "_OPTIONS", + 1 + ], + "AS": [ + "AS", + 2 + ] + }, + "withers": { + "cte": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\WithKeyword", + "name": "cte", + "columns": [], + "statement": { + "@type": "PhpMyAdmin\\SqlParser\\Parser", + "STATEMENT_PARSERS": { + "DESCRIBE": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "DESC": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "EXPLAIN": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "FLUSH": "", + "GRANT": "", + "HELP": "", + "SET PASSWORD": "", + "STATUS": "", + "USE": "", + "ANALYZE": "PhpMyAdmin\\SqlParser\\Statements\\AnalyzeStatement", + "BACKUP": "PhpMyAdmin\\SqlParser\\Statements\\BackupStatement", + "CHECK": "PhpMyAdmin\\SqlParser\\Statements\\CheckStatement", + "CHECKSUM": "PhpMyAdmin\\SqlParser\\Statements\\ChecksumStatement", + "OPTIMIZE": "PhpMyAdmin\\SqlParser\\Statements\\OptimizeStatement", + "REPAIR": "PhpMyAdmin\\SqlParser\\Statements\\RepairStatement", + "RESTORE": "PhpMyAdmin\\SqlParser\\Statements\\RestoreStatement", + "SET": "PhpMyAdmin\\SqlParser\\Statements\\SetStatement", + "SHOW": "PhpMyAdmin\\SqlParser\\Statements\\ShowStatement", + "ALTER": "PhpMyAdmin\\SqlParser\\Statements\\AlterStatement", + "CREATE": "PhpMyAdmin\\SqlParser\\Statements\\CreateStatement", + "DROP": "PhpMyAdmin\\SqlParser\\Statements\\DropStatement", + "RENAME": "PhpMyAdmin\\SqlParser\\Statements\\RenameStatement", + "TRUNCATE": "PhpMyAdmin\\SqlParser\\Statements\\TruncateStatement", + "CALL": "PhpMyAdmin\\SqlParser\\Statements\\CallStatement", + "DELETE": "PhpMyAdmin\\SqlParser\\Statements\\DeleteStatement", + "DO": "", + "HANDLER": "", + "INSERT": "PhpMyAdmin\\SqlParser\\Statements\\InsertStatement", + "LOAD DATA": "PhpMyAdmin\\SqlParser\\Statements\\LoadStatement", + "REPLACE": "PhpMyAdmin\\SqlParser\\Statements\\ReplaceStatement", + "SELECT": "PhpMyAdmin\\SqlParser\\Statements\\SelectStatement", + "UPDATE": "PhpMyAdmin\\SqlParser\\Statements\\UpdateStatement", + "WITH": "PhpMyAdmin\\SqlParser\\Statements\\WithStatement", + "DEALLOCATE": "", + "EXECUTE": "", + "PREPARE": "", + "BEGIN": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "COMMIT": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "ROLLBACK": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "START TRANSACTION": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "PURGE": "PhpMyAdmin\\SqlParser\\Statements\\PurgeStatement", + "LOCK": "PhpMyAdmin\\SqlParser\\Statements\\LockStatement", + "UNLOCK": "PhpMyAdmin\\SqlParser\\Statements\\LockStatement" + }, + "KEYWORD_PARSERS": { + "PARTITION BY": [], + "SUBPARTITION BY": [], + "_OPTIONS": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "field": "options" + }, + "_END_OPTIONS": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "field": "end_options" + }, + "INTERSECT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "EXCEPT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION ALL": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION DISTINCT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "ALTER": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "ANALYZE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "BACKUP": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CALL": { + "class": "PhpMyAdmin\\SqlParser\\Components\\FunctionCall", + "field": "call" + }, + "CHECK": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CHECKSUM": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CROSS JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "DROP": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "fields", + "options": { + "parseField": "table" + } + }, + "FORCE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "FROM": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "from", + "options": { + "field": "table" + } + }, + "GROUP BY": { + "class": "PhpMyAdmin\\SqlParser\\Components\\GroupKeyword", + "field": "group" + }, + "HAVING": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "field": "having" + }, + "IGNORE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "INTO": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IntoKeyword", + "field": "into" + }, + "JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LEFT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LEFT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "ON": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "RIGHT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "RIGHT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "INNER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "FULL JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "FULL OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL LEFT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL RIGHT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL LEFT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL RIGHT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "STRAIGHT_JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LIMIT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Limit", + "field": "limit" + }, + "OPTIMIZE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "ORDER BY": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OrderKeyword", + "field": "order" + }, + "PARTITION": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ArrayObj", + "field": "partition" + }, + "PROCEDURE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\FunctionCall", + "field": "procedure" + }, + "RENAME": { + "class": "PhpMyAdmin\\SqlParser\\Components\\RenameOperation", + "field": "renames" + }, + "REPAIR": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "RESTORE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "SET": { + "class": "PhpMyAdmin\\SqlParser\\Components\\SetOperation", + "field": "set" + }, + "SELECT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "expr" + }, + "TRUNCATE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "UPDATE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "USE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "VALUE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Array2d", + "field": "values" + }, + "VALUES": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Array2d", + "field": "values" + }, + "WHERE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "field": "where" + } + }, + "list": { + "@type": "PhpMyAdmin\\SqlParser\\TokensList", + "tokens": [ + { + "@type": "@19" + }, + { + "@type": "@20" + }, + { + "@type": "@21" + }, + { + "@type": "@22" + }, + { + "@type": "@23" + }, + { + "@type": "@24" + }, + { + "@type": "@25" + }, + { + "@type": "@26" + }, + { + "@type": "@27" + }, + { + "@type": "@28" + }, + { + "@type": "@29" + }, + { + "@type": "@30" + }, + { + "@type": "@31" + }, + { + "@type": "@32" + }, + { + "@type": "@33" + }, + { + "@type": "@34" + }, + { + "@type": "@35" + }, + { + "@type": "@36" + }, + { + "@type": "@37" + }, + { + "@type": "@38" + } + ], + "count": 20, + "idx": 20 + }, + "statements": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Statements\\SelectStatement", + "OPTIONS": { + "ALL": 1, + "DISTINCT": 1, + "DISTINCTROW": 1, + "HIGH_PRIORITY": 2, + "MAX_STATEMENT_TIME": [ + 3, + "var=" + ], + "STRAIGHT_JOIN": 4, + "SQL_SMALL_RESULT": 5, + "SQL_BIG_RESULT": 6, + "SQL_BUFFER_RESULT": 7, + "SQL_CACHE": 8, + "SQL_NO_CACHE": 8, + "SQL_CALC_FOUND_ROWS": 9 + }, + "END_OPTIONS": { + "FOR UPDATE": 1, + "LOCK IN SHARE MODE": 1 + }, + "CLAUSES": { + "SELECT": [ + "SELECT", + 2 + ], + "_OPTIONS": [ + "_OPTIONS", + 1 + ], + "_SELECT": [ + "SELECT", + 1 + ], + "INTO": [ + "INTO", + 3 + ], + "FROM": [ + "FROM", + 3 + ], + "FORCE": [ + "FORCE", + 1 + ], + "USE": [ + "USE", + 1 + ], + "IGNORE": [ + "IGNORE", + 3 + ], + "PARTITION": [ + "PARTITION", + 3 + ], + "JOIN": [ + "JOIN", + 1 + ], + "FULL JOIN": [ + "FULL JOIN", + 1 + ], + "INNER JOIN": [ + "INNER JOIN", + 1 + ], + "LEFT JOIN": [ + "LEFT JOIN", + 1 + ], + "LEFT OUTER JOIN": [ + "LEFT OUTER JOIN", + 1 + ], + "RIGHT JOIN": [ + "RIGHT JOIN", + 1 + ], + "RIGHT OUTER JOIN": [ + "RIGHT OUTER JOIN", + 1 + ], + "NATURAL JOIN": [ + "NATURAL JOIN", + 1 + ], + "NATURAL LEFT JOIN": [ + "NATURAL LEFT JOIN", + 1 + ], + "NATURAL RIGHT JOIN": [ + "NATURAL RIGHT JOIN", + 1 + ], + "NATURAL LEFT OUTER JOIN": [ + "NATURAL LEFT OUTER JOIN", + 1 + ], + "NATURAL RIGHT OUTER JOIN": [ + "NATURAL RIGHT JOIN", + 1 + ], + "WHERE": [ + "WHERE", + 3 + ], + "GROUP BY": [ + "GROUP BY", + 3 + ], + "HAVING": [ + "HAVING", + 3 + ], + "ORDER BY": [ + "ORDER BY", + 3 + ], + "LIMIT": [ + "LIMIT", + 3 + ], + "PROCEDURE": [ + "PROCEDURE", + 3 + ], + "UNION": [ + "UNION", + 1 + ], + "EXCEPT": [ + "EXCEPT", + 1 + ], + "INTERSECT": [ + "INTERSECT", + 1 + ], + "_END_OPTIONS": [ + "_END_OPTIONS", + 1 + ] + }, + "expr": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "ALLOWED_KEYWORDS": { + "AS": 1, + "DUAL": 1, + "NULL": 1, + "REGEXP": 1, + "CASE": 1, + "DIV": 1, + "AND": 1, + "OR": 1, + "XOR": 1, + "NOT": 1, + "MOD": 1, + "OVER": 2 + }, + "database": null, + "table": "p", + "column": "name", + "expr": "p.name", + "alias": null, + "function": null, + "subquery": null + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "ALLOWED_KEYWORDS": { + "AS": 1, + "DUAL": 1, + "NULL": 1, + "REGEXP": 1, + "CASE": 1, + "DIV": 1, + "AND": 1, + "OR": 1, + "XOR": 1, + "NOT": 1, + "MOD": 1, + "OVER": 2 + }, + "database": null, + "table": "p", + "column": "shape", + "expr": "p.shape", + "alias": null, + "function": null, + "subquery": null + } + ], + "from": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "ALLOWED_KEYWORDS": { + "AS": 1, + "DUAL": 1, + "NULL": 1, + "REGEXP": 1, + "CASE": 1, + "DIV": 1, + "AND": 1, + "OR": 1, + "XOR": 1, + "NOT": 1, + "MOD": 1, + "OVER": 2 + }, + "database": null, + "table": "gis_all", + "column": null, + "expr": "gis_all", + "alias": "p", + "function": null, + "subquery": null + } + ], + "index_hints": null, + "partition": null, + "where": null, + "group": null, + "having": null, + "order": null, + "limit": null, + "procedure": null, + "into": null, + "join": null, + "union": [], + "end_options": null, + "options": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "options": [] + }, + "first": 0, + "last": 19 + } + ], + "brackets": 0, + "strict": false, + "errors": [] + } + } + }, + "END_OPTIONS": [], "options": { - "6": "VIEW" - } - }, - "first": 0, - "last": 52 - }, - { - "@type": "PhpMyAdmin\\SqlParser\\Statements\\CreateStatement", - "OPTIONS": { - "TEMPORARY": 1, - "OR REPLACE": 2, - "ALGORITHM": [ - 3, - "var=" - ], - "DEFINER": [ - 4, - "expr=" - ], - "SQL SECURITY": [ - 5, - "var" - ], - "DATABASE": 6, - "EVENT": 6, - "FUNCTION": 6, - "INDEX": 6, - "UNIQUE INDEX": 6, - "FULLTEXT INDEX": 6, - "SPATIAL INDEX": 6, - "PROCEDURE": 6, - "SERVER": 6, - "TABLE": 6, - "TABLESPACE": 6, - "TRIGGER": 6, - "USER": 6, - "VIEW": 6, - "SCHEMA": 6, - "IF NOT EXISTS": 7 - }, - "DB_OPTIONS": { - "CHARACTER SET": [ - 1, - "var=" - ], - "CHARSET": [ - 1, - "var=" - ], - "DEFAULT CHARACTER SET": [ - 1, - "var=" - ], - "DEFAULT CHARSET": [ - 1, - "var=" - ], - "DEFAULT COLLATE": [ - 2, - "var=" - ], - "COLLATE": [ - 2, - "var=" - ] - }, - "TABLE_OPTIONS": { - "ENGINE": [ - 1, - "var=" - ], - "AUTO_INCREMENT": [ - 2, - "var=" - ], - "AVG_ROW_LENGTH": [ - 3, - "var" - ], - "CHARACTER SET": [ - 4, - "var=" - ], - "CHARSET": [ - 4, - "var=" - ], - "DEFAULT CHARACTER SET": [ - 4, - "var=" - ], - "DEFAULT CHARSET": [ - 4, - "var=" - ], - "CHECKSUM": [ - 5, - "var" - ], - "DEFAULT COLLATE": [ - 6, - "var=" - ], - "COLLATE": [ - 6, - "var=" - ], - "COMMENT": [ - 7, - "var=" - ], - "CONNECTION": [ - 8, - "var" - ], - "DATA DIRECTORY": [ - 9, - "var" - ], - "DELAY_KEY_WRITE": [ - 10, - "var" - ], - "INDEX DIRECTORY": [ - 11, - "var" - ], - "INSERT_METHOD": [ - 12, - "var" - ], - "KEY_BLOCK_SIZE": [ - 13, - "var" - ], - "MAX_ROWS": [ - 14, - "var" - ], - "MIN_ROWS": [ - 15, - "var" - ], - "PACK_KEYS": [ - 16, - "var" - ], - "PASSWORD": [ - 17, - "var" - ], - "ROW_FORMAT": [ - 18, - "var" - ], - "TABLESPACE": [ - 19, - "var" - ], - "STORAGE": [ - 20, - "var" - ], - "UNION": [ - 21, - "var" - ] - }, - "FUNC_OPTIONS": { - "NOT": [ - 2, - "var" - ], - "FUNCTION": [ - 3, - "var=" - ], - "PROCEDURE": [ - 3, - "var=" - ], - "CONTAINS": [ - 4, - "expr" - ], - "NO": [ - 4, - "var" - ], - "READS": [ - 4, - "var" - ], - "MODIFIES": [ - 4, - "expr" - ], - "SQL SECURITY": [ - 6, - "var" - ], - "LANGUAGE": [ - 7, - "var" - ], - "COMMENT": [ - 8, - "var" - ], - "CREATE": 1, - "DETERMINISTIC": 2, - "DATA": 5 - }, - "TRIGGER_OPTIONS": { - "BEFORE": 1, - "AFTER": 1, - "INSERT": 2, - "UPDATE": 2, - "DELETE": 2 - }, - "name": { - "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", - "ALLOWED_KEYWORDS": { - "AS": 1, - "DUAL": 1, - "NULL": 1, - "REGEXP": 1, - "CASE": 1, - "DIV": 1, - "AND": 1, - "OR": 1, - "XOR": 1, - "NOT": 1, - "MOD": 1 + "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "options": [] }, - "database": null, - "table": "withclause2", - "column": null, - "expr": "withclause2", - "alias": null, - "function": null, - "subquery": null + "first": null, + "last": null }, - "entityOptions": null, - "fields": null, "select": null, "like": null, "partitionBy": null, @@ -2323,263 +2582,7 @@ "table": null, "return": null, "parameters": null, - "body": [ - { - "@type": "@65" - }, - { - "@type": "@66" - }, - { - "@type": "@67" - }, - { - "@type": "@68" - }, - { - "@type": "@69" - }, - { - "@type": "@70" - }, - { - "@type": "@71" - }, - { - "@type": "@72" - }, - { - "@type": "@73" - }, - { - "@type": "@74" - }, - { - "@type": "@75" - }, - { - "@type": "@76" - }, - { - "@type": "@77" - }, - { - "@type": "@78" - }, - { - "@type": "@79" - }, - { - "@type": "@80" - }, - { - "@type": "@81" - }, - { - "@type": "@82" - }, - { - "@type": "@83" - }, - { - "@type": "@84" - }, - { - "@type": "@85" - }, - { - "@type": "@86" - }, - { - "@type": "@87" - }, - { - "@type": "@88" - }, - { - "@type": "@89" - }, - { - "@type": "@90" - }, - { - "@type": "@91" - }, - { - "@type": "@92" - }, - { - "@type": "@93" - }, - { - "@type": "@94" - }, - { - "@type": "@95" - }, - { - "@type": "@96" - }, - { - "@type": "@97" - }, - { - "@type": "@98" - }, - { - "@type": "@99" - }, - { - "@type": "@100" - }, - { - "@type": "@101" - }, - { - "@type": "@102" - }, - { - "@type": "@103" - }, - { - "@type": "@104" - }, - { - "@type": "@105" - }, - { - "@type": "@106" - }, - { - "@type": "@107" - }, - { - "@type": "@108" - }, - { - "@type": "@109" - }, - { - "@type": "@110" - }, - { - "@type": "@111" - }, - { - "@type": "@112" - }, - { - "@type": "@113" - }, - { - "@type": "@114" - }, - { - "@type": "@115" - }, - { - "@type": "@116" - }, - { - "@type": "@117" - }, - { - "@type": "@118" - }, - { - "@type": "@119" - }, - { - "@type": "@120" - }, - { - "@type": "@121" - }, - { - "@type": "@122" - }, - { - "@type": "@123" - }, - { - "@type": "@124" - }, - { - "@type": "@125" - }, - { - "@type": "@126" - }, - { - "@type": "@127" - }, - { - "@type": "@128" - }, - { - "@type": "@129" - }, - { - "@type": "@130" - }, - { - "@type": "@131" - }, - { - "@type": "@132" - }, - { - "@type": "@133" - }, - { - "@type": "@134" - }, - { - "@type": "@135" - }, - { - "@type": "@136" - }, - { - "@type": "@137" - }, - { - "@type": "@138" - }, - { - "@type": "@139" - }, - { - "@type": "@140" - }, - { - "@type": "@141" - }, - { - "@type": "@142" - }, - { - "@type": "@143" - }, - { - "@type": "@144" - }, - { - "@type": "@145" - }, - { - "@type": "@146" - }, - { - "@type": "@147" - }, - { - "@type": "@148" - }, - { - "@type": "@149" - } - ], + "body": [], "CLAUSES": [], "END_OPTIONS": [], "options": { @@ -2588,7 +2591,7 @@ "6": "VIEW" } }, - "first": 53, + "first": 0, "last": 148 } ], diff --git a/tests/data/parser/parseWithStatement.in b/tests/data/parser/parseWithStatement.in new file mode 100644 index 000000000..9e1537b9f --- /dev/null +++ b/tests/data/parser/parseWithStatement.in @@ -0,0 +1 @@ +INSERT INTO table_name WITH cte (col1) AS ( SELECT 1 UNION ALL SELECT 2 ) SELECT col1 FROM cte \ No newline at end of file diff --git a/tests/data/parser/parseWithStatement.out b/tests/data/parser/parseWithStatement.out new file mode 100644 index 000000000..fa660cde2 --- /dev/null +++ b/tests/data/parser/parseWithStatement.out @@ -0,0 +1,1547 @@ +{ + "query": "INSERT INTO table_name WITH cte (col1) AS ( SELECT 1 UNION ALL SELECT 2 ) SELECT col1 FROM cte", + "lexer": { + "@type": "PhpMyAdmin\\SqlParser\\Lexer", + "PARSER_METHODS": [ + "parseDelimiter", + "parseWhitespace", + "parseNumber", + "parseComment", + "parseOperator", + "parseBool", + "parseString", + "parseSymbol", + "parseKeyword", + "parseLabel", + "parseUnknown" + ], + "str": "INSERT INTO table_name WITH cte (col1) AS ( SELECT 1 UNION ALL SELECT 2 ) SELECT col1 FROM cte", + "len": 94, + "last": 94, + "list": { + "@type": "PhpMyAdmin\\SqlParser\\TokensList", + "tokens": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "INSERT", + "value": "INSERT", + "keyword": "INSERT", + "type": 1, + "flags": 35, + "position": 0 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 6 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "INTO", + "value": "INTO", + "keyword": "INTO", + "type": 1, + "flags": 3, + "position": 7 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 11 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "table_name", + "value": "table_name", + "keyword": "TABLE_NAME", + "type": 1, + "flags": 1, + "position": 12 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 22 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "WITH", + "value": "WITH", + "keyword": "WITH", + "type": 1, + "flags": 3, + "position": 23 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 27 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "cte", + "value": "cte", + "keyword": null, + "type": 0, + "flags": 0, + "position": 28 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 31 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "(", + "value": "(", + "keyword": null, + "type": 2, + "flags": 16, + "position": 32 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "col1", + "value": "col1", + "keyword": null, + "type": 0, + "flags": 0, + "position": 33 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": ")", + "value": ")", + "keyword": null, + "type": 2, + "flags": 16, + "position": 37 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 38 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "AS", + "value": "AS", + "keyword": "AS", + "type": 1, + "flags": 3, + "position": 39 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 41 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "(", + "value": "(", + "keyword": null, + "type": 2, + "flags": 16, + "position": 42 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 43 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "SELECT", + "value": "SELECT", + "keyword": "SELECT", + "type": 1, + "flags": 3, + "position": 44 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 50 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "1", + "value": 1, + "keyword": null, + "type": 6, + "flags": 0, + "position": 51 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 52 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "UNION ALL", + "value": "UNION ALL", + "keyword": "UNION ALL", + "type": 1, + "flags": 7, + "position": 53 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 62 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "SELECT", + "value": "SELECT", + "keyword": "SELECT", + "type": 1, + "flags": 3, + "position": 63 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 69 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "2", + "value": 2, + "keyword": null, + "type": 6, + "flags": 0, + "position": 70 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 71 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": ")", + "value": ")", + "keyword": null, + "type": 2, + "flags": 16, + "position": 72 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 73 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "SELECT", + "value": "SELECT", + "keyword": "SELECT", + "type": 1, + "flags": 3, + "position": 74 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 80 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "col1", + "value": "col1", + "keyword": null, + "type": 0, + "flags": 0, + "position": 81 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 85 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "FROM", + "value": "FROM", + "keyword": "FROM", + "type": 1, + "flags": 3, + "position": 86 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 90 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "cte", + "value": "cte", + "keyword": null, + "type": 0, + "flags": 0, + "position": 91 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": null, + "value": null, + "keyword": null, + "type": 9, + "flags": 0, + "position": null + } + ], + "count": 38, + "idx": 38 + }, + "DEFAULT_DELIMITER": ";", + "delimiter": ";", + "delimiterLen": 1, + "strict": false, + "errors": [] + }, + "parser": { + "@type": "PhpMyAdmin\\SqlParser\\Parser", + "STATEMENT_PARSERS": { + "DESCRIBE": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "DESC": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "EXPLAIN": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "FLUSH": "", + "GRANT": "", + "HELP": "", + "SET PASSWORD": "", + "STATUS": "", + "USE": "", + "ANALYZE": "PhpMyAdmin\\SqlParser\\Statements\\AnalyzeStatement", + "BACKUP": "PhpMyAdmin\\SqlParser\\Statements\\BackupStatement", + "CHECK": "PhpMyAdmin\\SqlParser\\Statements\\CheckStatement", + "CHECKSUM": "PhpMyAdmin\\SqlParser\\Statements\\ChecksumStatement", + "OPTIMIZE": "PhpMyAdmin\\SqlParser\\Statements\\OptimizeStatement", + "REPAIR": "PhpMyAdmin\\SqlParser\\Statements\\RepairStatement", + "RESTORE": "PhpMyAdmin\\SqlParser\\Statements\\RestoreStatement", + "SET": "PhpMyAdmin\\SqlParser\\Statements\\SetStatement", + "SHOW": "PhpMyAdmin\\SqlParser\\Statements\\ShowStatement", + "ALTER": "PhpMyAdmin\\SqlParser\\Statements\\AlterStatement", + "CREATE": "PhpMyAdmin\\SqlParser\\Statements\\CreateStatement", + "DROP": "PhpMyAdmin\\SqlParser\\Statements\\DropStatement", + "RENAME": "PhpMyAdmin\\SqlParser\\Statements\\RenameStatement", + "TRUNCATE": "PhpMyAdmin\\SqlParser\\Statements\\TruncateStatement", + "CALL": "PhpMyAdmin\\SqlParser\\Statements\\CallStatement", + "DELETE": "PhpMyAdmin\\SqlParser\\Statements\\DeleteStatement", + "DO": "", + "HANDLER": "", + "INSERT": "PhpMyAdmin\\SqlParser\\Statements\\InsertStatement", + "LOAD DATA": "PhpMyAdmin\\SqlParser\\Statements\\LoadStatement", + "REPLACE": "PhpMyAdmin\\SqlParser\\Statements\\ReplaceStatement", + "SELECT": "PhpMyAdmin\\SqlParser\\Statements\\SelectStatement", + "UPDATE": "PhpMyAdmin\\SqlParser\\Statements\\UpdateStatement", + "WITH": "PhpMyAdmin\\SqlParser\\Statements\\WithStatement", + "DEALLOCATE": "", + "EXECUTE": "", + "PREPARE": "", + "BEGIN": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "COMMIT": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "ROLLBACK": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "START TRANSACTION": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "PURGE": "PhpMyAdmin\\SqlParser\\Statements\\PurgeStatement", + "LOCK": "PhpMyAdmin\\SqlParser\\Statements\\LockStatement", + "UNLOCK": "PhpMyAdmin\\SqlParser\\Statements\\LockStatement" + }, + "KEYWORD_PARSERS": { + "PARTITION BY": [], + "SUBPARTITION BY": [], + "_OPTIONS": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "field": "options" + }, + "_END_OPTIONS": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "field": "end_options" + }, + "INTERSECT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "EXCEPT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION ALL": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION DISTINCT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "ALTER": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "ANALYZE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "BACKUP": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CALL": { + "class": "PhpMyAdmin\\SqlParser\\Components\\FunctionCall", + "field": "call" + }, + "CHECK": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CHECKSUM": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CROSS JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "DROP": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "fields", + "options": { + "parseField": "table" + } + }, + "FORCE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "FROM": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "from", + "options": { + "field": "table" + } + }, + "GROUP BY": { + "class": "PhpMyAdmin\\SqlParser\\Components\\GroupKeyword", + "field": "group" + }, + "HAVING": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "field": "having" + }, + "IGNORE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "INTO": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IntoKeyword", + "field": "into" + }, + "JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LEFT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LEFT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "ON": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "RIGHT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "RIGHT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "INNER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "FULL JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "FULL OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL LEFT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL RIGHT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL LEFT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL RIGHT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "STRAIGHT_JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LIMIT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Limit", + "field": "limit" + }, + "OPTIMIZE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "ORDER BY": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OrderKeyword", + "field": "order" + }, + "PARTITION": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ArrayObj", + "field": "partition" + }, + "PROCEDURE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\FunctionCall", + "field": "procedure" + }, + "RENAME": { + "class": "PhpMyAdmin\\SqlParser\\Components\\RenameOperation", + "field": "renames" + }, + "REPAIR": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "RESTORE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "SET": { + "class": "PhpMyAdmin\\SqlParser\\Components\\SetOperation", + "field": "set" + }, + "SELECT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "expr" + }, + "TRUNCATE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "UPDATE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "USE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "VALUE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Array2d", + "field": "values" + }, + "VALUES": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Array2d", + "field": "values" + }, + "WHERE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "field": "where" + } + }, + "list": { + "@type": "@1" + }, + "statements": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Statements\\InsertStatement", + "OPTIONS": { + "LOW_PRIORITY": 1, + "DELAYED": 2, + "HIGH_PRIORITY": 3, + "IGNORE": 4 + }, + "into": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\IntoKeyword", + "FIELDS_OPTIONS": { + "TERMINATED BY": [ + 1, + "expr" + ], + "OPTIONALLY": 2, + "ENCLOSED BY": [ + 3, + "expr" + ], + "ESCAPED BY": [ + 4, + "expr" + ] + }, + "LINES_OPTIONS": { + "STARTING BY": [ + 1, + "expr" + ], + "TERMINATED BY": [ + 2, + "expr" + ] + }, + "type": null, + "dest": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "ALLOWED_KEYWORDS": { + "AS": 1, + "DUAL": 1, + "NULL": 1, + "REGEXP": 1, + "CASE": 1, + "DIV": 1, + "AND": 1, + "OR": 1, + "XOR": 1, + "NOT": 1, + "MOD": 1, + "OVER": 2 + }, + "database": null, + "table": "table_name", + "column": null, + "expr": "table_name", + "alias": null, + "function": null, + "subquery": null + }, + "columns": null, + "values": null, + "fields_options": null, + "fields_keyword": null, + "lines_options": null + }, + "values": null, + "set": null, + "select": { + "@type": "PhpMyAdmin\\SqlParser\\Statements\\WithStatement", + "OPTIONS": { + "RECURSIVE": 1 + }, + "CLAUSES": { + "WITH": [ + "WITH", + 2 + ], + "_OPTIONS": [ + "_OPTIONS", + 1 + ], + "AS": [ + "AS", + 2 + ] + }, + "withers": { + "cte": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\WithKeyword", + "name": "cte", + "columns": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\ArrayObj", + "raw": [ + "col1" + ], + "values": [ + "col1" + ] + } + ], + "statement": { + "@type": "PhpMyAdmin\\SqlParser\\Parser", + "STATEMENT_PARSERS": { + "DESCRIBE": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "DESC": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "EXPLAIN": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "FLUSH": "", + "GRANT": "", + "HELP": "", + "SET PASSWORD": "", + "STATUS": "", + "USE": "", + "ANALYZE": "PhpMyAdmin\\SqlParser\\Statements\\AnalyzeStatement", + "BACKUP": "PhpMyAdmin\\SqlParser\\Statements\\BackupStatement", + "CHECK": "PhpMyAdmin\\SqlParser\\Statements\\CheckStatement", + "CHECKSUM": "PhpMyAdmin\\SqlParser\\Statements\\ChecksumStatement", + "OPTIMIZE": "PhpMyAdmin\\SqlParser\\Statements\\OptimizeStatement", + "REPAIR": "PhpMyAdmin\\SqlParser\\Statements\\RepairStatement", + "RESTORE": "PhpMyAdmin\\SqlParser\\Statements\\RestoreStatement", + "SET": "PhpMyAdmin\\SqlParser\\Statements\\SetStatement", + "SHOW": "PhpMyAdmin\\SqlParser\\Statements\\ShowStatement", + "ALTER": "PhpMyAdmin\\SqlParser\\Statements\\AlterStatement", + "CREATE": "PhpMyAdmin\\SqlParser\\Statements\\CreateStatement", + "DROP": "PhpMyAdmin\\SqlParser\\Statements\\DropStatement", + "RENAME": "PhpMyAdmin\\SqlParser\\Statements\\RenameStatement", + "TRUNCATE": "PhpMyAdmin\\SqlParser\\Statements\\TruncateStatement", + "CALL": "PhpMyAdmin\\SqlParser\\Statements\\CallStatement", + "DELETE": "PhpMyAdmin\\SqlParser\\Statements\\DeleteStatement", + "DO": "", + "HANDLER": "", + "INSERT": "PhpMyAdmin\\SqlParser\\Statements\\InsertStatement", + "LOAD DATA": "PhpMyAdmin\\SqlParser\\Statements\\LoadStatement", + "REPLACE": "PhpMyAdmin\\SqlParser\\Statements\\ReplaceStatement", + "SELECT": "PhpMyAdmin\\SqlParser\\Statements\\SelectStatement", + "UPDATE": "PhpMyAdmin\\SqlParser\\Statements\\UpdateStatement", + "WITH": "PhpMyAdmin\\SqlParser\\Statements\\WithStatement", + "DEALLOCATE": "", + "EXECUTE": "", + "PREPARE": "", + "BEGIN": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "COMMIT": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "ROLLBACK": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "START TRANSACTION": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "PURGE": "PhpMyAdmin\\SqlParser\\Statements\\PurgeStatement", + "LOCK": "PhpMyAdmin\\SqlParser\\Statements\\LockStatement", + "UNLOCK": "PhpMyAdmin\\SqlParser\\Statements\\LockStatement" + }, + "KEYWORD_PARSERS": { + "PARTITION BY": [], + "SUBPARTITION BY": [], + "_OPTIONS": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "field": "options" + }, + "_END_OPTIONS": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "field": "end_options" + }, + "INTERSECT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "EXCEPT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION ALL": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION DISTINCT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "ALTER": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "ANALYZE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "BACKUP": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CALL": { + "class": "PhpMyAdmin\\SqlParser\\Components\\FunctionCall", + "field": "call" + }, + "CHECK": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CHECKSUM": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CROSS JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "DROP": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "fields", + "options": { + "parseField": "table" + } + }, + "FORCE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "FROM": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "from", + "options": { + "field": "table" + } + }, + "GROUP BY": { + "class": "PhpMyAdmin\\SqlParser\\Components\\GroupKeyword", + "field": "group" + }, + "HAVING": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "field": "having" + }, + "IGNORE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "INTO": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IntoKeyword", + "field": "into" + }, + "JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LEFT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LEFT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "ON": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "RIGHT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "RIGHT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "INNER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "FULL JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "FULL OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL LEFT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL RIGHT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL LEFT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL RIGHT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "STRAIGHT_JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LIMIT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Limit", + "field": "limit" + }, + "OPTIMIZE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "ORDER BY": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OrderKeyword", + "field": "order" + }, + "PARTITION": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ArrayObj", + "field": "partition" + }, + "PROCEDURE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\FunctionCall", + "field": "procedure" + }, + "RENAME": { + "class": "PhpMyAdmin\\SqlParser\\Components\\RenameOperation", + "field": "renames" + }, + "REPAIR": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "RESTORE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "SET": { + "class": "PhpMyAdmin\\SqlParser\\Components\\SetOperation", + "field": "set" + }, + "SELECT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "expr" + }, + "TRUNCATE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "UPDATE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "USE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "VALUE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Array2d", + "field": "values" + }, + "VALUES": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Array2d", + "field": "values" + }, + "WHERE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "field": "where" + } + }, + "list": { + "@type": "PhpMyAdmin\\SqlParser\\TokensList", + "tokens": [ + { + "@type": "@19" + }, + { + "@type": "@20" + }, + { + "@type": "@21" + }, + { + "@type": "@22" + }, + { + "@type": "@23" + }, + { + "@type": "@24" + }, + { + "@type": "@25" + }, + { + "@type": "@26" + }, + { + "@type": "@27" + }, + { + "@type": "@28" + }, + { + "@type": "@29" + } + ], + "count": 11, + "idx": 11 + }, + "statements": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Statements\\SelectStatement", + "OPTIONS": { + "ALL": 1, + "DISTINCT": 1, + "DISTINCTROW": 1, + "HIGH_PRIORITY": 2, + "MAX_STATEMENT_TIME": [ + 3, + "var=" + ], + "STRAIGHT_JOIN": 4, + "SQL_SMALL_RESULT": 5, + "SQL_BIG_RESULT": 6, + "SQL_BUFFER_RESULT": 7, + "SQL_CACHE": 8, + "SQL_NO_CACHE": 8, + "SQL_CALC_FOUND_ROWS": 9 + }, + "END_OPTIONS": { + "FOR UPDATE": 1, + "LOCK IN SHARE MODE": 1 + }, + "CLAUSES": { + "SELECT": [ + "SELECT", + 2 + ], + "_OPTIONS": [ + "_OPTIONS", + 1 + ], + "_SELECT": [ + "SELECT", + 1 + ], + "INTO": [ + "INTO", + 3 + ], + "FROM": [ + "FROM", + 3 + ], + "FORCE": [ + "FORCE", + 1 + ], + "USE": [ + "USE", + 1 + ], + "IGNORE": [ + "IGNORE", + 3 + ], + "PARTITION": [ + "PARTITION", + 3 + ], + "JOIN": [ + "JOIN", + 1 + ], + "FULL JOIN": [ + "FULL JOIN", + 1 + ], + "INNER JOIN": [ + "INNER JOIN", + 1 + ], + "LEFT JOIN": [ + "LEFT JOIN", + 1 + ], + "LEFT OUTER JOIN": [ + "LEFT OUTER JOIN", + 1 + ], + "RIGHT JOIN": [ + "RIGHT JOIN", + 1 + ], + "RIGHT OUTER JOIN": [ + "RIGHT OUTER JOIN", + 1 + ], + "NATURAL JOIN": [ + "NATURAL JOIN", + 1 + ], + "NATURAL LEFT JOIN": [ + "NATURAL LEFT JOIN", + 1 + ], + "NATURAL RIGHT JOIN": [ + "NATURAL RIGHT JOIN", + 1 + ], + "NATURAL LEFT OUTER JOIN": [ + "NATURAL LEFT OUTER JOIN", + 1 + ], + "NATURAL RIGHT OUTER JOIN": [ + "NATURAL RIGHT JOIN", + 1 + ], + "WHERE": [ + "WHERE", + 3 + ], + "GROUP BY": [ + "GROUP BY", + 3 + ], + "HAVING": [ + "HAVING", + 3 + ], + "ORDER BY": [ + "ORDER BY", + 3 + ], + "LIMIT": [ + "LIMIT", + 3 + ], + "PROCEDURE": [ + "PROCEDURE", + 3 + ], + "UNION": [ + "UNION", + 1 + ], + "EXCEPT": [ + "EXCEPT", + 1 + ], + "INTERSECT": [ + "INTERSECT", + 1 + ], + "_END_OPTIONS": [ + "_END_OPTIONS", + 1 + ] + }, + "expr": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "ALLOWED_KEYWORDS": { + "AS": 1, + "DUAL": 1, + "NULL": 1, + "REGEXP": 1, + "CASE": 1, + "DIV": 1, + "AND": 1, + "OR": 1, + "XOR": 1, + "NOT": 1, + "MOD": 1, + "OVER": 2 + }, + "database": null, + "table": null, + "column": null, + "expr": "1", + "alias": null, + "function": null, + "subquery": null + } + ], + "from": [], + "index_hints": null, + "partition": null, + "where": null, + "group": null, + "having": null, + "order": null, + "limit": null, + "procedure": null, + "into": null, + "join": null, + "union": [ + [ + "UNION ALL", + { + "@type": "PhpMyAdmin\\SqlParser\\Statements\\SelectStatement", + "OPTIONS": { + "ALL": 1, + "DISTINCT": 1, + "DISTINCTROW": 1, + "HIGH_PRIORITY": 2, + "MAX_STATEMENT_TIME": [ + 3, + "var=" + ], + "STRAIGHT_JOIN": 4, + "SQL_SMALL_RESULT": 5, + "SQL_BIG_RESULT": 6, + "SQL_BUFFER_RESULT": 7, + "SQL_CACHE": 8, + "SQL_NO_CACHE": 8, + "SQL_CALC_FOUND_ROWS": 9 + }, + "END_OPTIONS": { + "FOR UPDATE": 1, + "LOCK IN SHARE MODE": 1 + }, + "CLAUSES": { + "SELECT": [ + "SELECT", + 2 + ], + "_OPTIONS": [ + "_OPTIONS", + 1 + ], + "_SELECT": [ + "SELECT", + 1 + ], + "INTO": [ + "INTO", + 3 + ], + "FROM": [ + "FROM", + 3 + ], + "FORCE": [ + "FORCE", + 1 + ], + "USE": [ + "USE", + 1 + ], + "IGNORE": [ + "IGNORE", + 3 + ], + "PARTITION": [ + "PARTITION", + 3 + ], + "JOIN": [ + "JOIN", + 1 + ], + "FULL JOIN": [ + "FULL JOIN", + 1 + ], + "INNER JOIN": [ + "INNER JOIN", + 1 + ], + "LEFT JOIN": [ + "LEFT JOIN", + 1 + ], + "LEFT OUTER JOIN": [ + "LEFT OUTER JOIN", + 1 + ], + "RIGHT JOIN": [ + "RIGHT JOIN", + 1 + ], + "RIGHT OUTER JOIN": [ + "RIGHT OUTER JOIN", + 1 + ], + "NATURAL JOIN": [ + "NATURAL JOIN", + 1 + ], + "NATURAL LEFT JOIN": [ + "NATURAL LEFT JOIN", + 1 + ], + "NATURAL RIGHT JOIN": [ + "NATURAL RIGHT JOIN", + 1 + ], + "NATURAL LEFT OUTER JOIN": [ + "NATURAL LEFT OUTER JOIN", + 1 + ], + "NATURAL RIGHT OUTER JOIN": [ + "NATURAL RIGHT JOIN", + 1 + ], + "WHERE": [ + "WHERE", + 3 + ], + "GROUP BY": [ + "GROUP BY", + 3 + ], + "HAVING": [ + "HAVING", + 3 + ], + "ORDER BY": [ + "ORDER BY", + 3 + ], + "LIMIT": [ + "LIMIT", + 3 + ], + "PROCEDURE": [ + "PROCEDURE", + 3 + ], + "UNION": [ + "UNION", + 1 + ], + "EXCEPT": [ + "EXCEPT", + 1 + ], + "INTERSECT": [ + "INTERSECT", + 1 + ], + "_END_OPTIONS": [ + "_END_OPTIONS", + 1 + ] + }, + "expr": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "ALLOWED_KEYWORDS": { + "AS": 1, + "DUAL": 1, + "NULL": 1, + "REGEXP": 1, + "CASE": 1, + "DIV": 1, + "AND": 1, + "OR": 1, + "XOR": 1, + "NOT": 1, + "MOD": 1, + "OVER": 2 + }, + "database": null, + "table": null, + "column": null, + "expr": "2", + "alias": null, + "function": null, + "subquery": null + } + ], + "from": [], + "index_hints": null, + "partition": null, + "where": null, + "group": null, + "having": null, + "order": [], + "limit": null, + "procedure": null, + "into": null, + "join": null, + "union": [], + "end_options": null, + "options": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "options": [] + }, + "first": 5, + "last": 10 + } + ] + ], + "end_options": null, + "options": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "options": [] + }, + "first": 0, + "last": 10 + } + ], + "brackets": 0, + "strict": false, + "errors": [] + } + } + }, + "END_OPTIONS": [], + "options": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "options": [] + }, + "first": null, + "last": null + }, + "onDuplicateSet": null, + "CLAUSES": [], + "END_OPTIONS": [], + "options": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "options": [] + }, + "first": 0, + "last": 36 + } + ], + "brackets": 0, + "strict": false, + "errors": [] + }, + "errors": { + "lexer": [], + "parser": [] + } +} \ No newline at end of file diff --git a/tests/data/parser/parseWithStatement2.in b/tests/data/parser/parseWithStatement2.in new file mode 100644 index 000000000..126dc6661 --- /dev/null +++ b/tests/data/parser/parseWithStatement2.in @@ -0,0 +1 @@ +CREATE table table_name WITH cte (col1) AS ( SELECT 1 UNION ALL SELECT 2 ) SELECT col1 FROM cte \ No newline at end of file diff --git a/tests/data/parser/parseWithStatement2.out b/tests/data/parser/parseWithStatement2.out new file mode 100644 index 000000000..cf0fff230 --- /dev/null +++ b/tests/data/parser/parseWithStatement2.out @@ -0,0 +1,1731 @@ +{ + "query": "CREATE table table_name WITH cte (col1) AS ( SELECT 1 UNION ALL SELECT 2 ) SELECT col1 FROM cte", + "lexer": { + "@type": "PhpMyAdmin\\SqlParser\\Lexer", + "PARSER_METHODS": [ + "parseDelimiter", + "parseWhitespace", + "parseNumber", + "parseComment", + "parseOperator", + "parseBool", + "parseString", + "parseSymbol", + "parseKeyword", + "parseLabel", + "parseUnknown" + ], + "str": "CREATE table table_name WITH cte (col1) AS ( SELECT 1 UNION ALL SELECT 2 ) SELECT col1 FROM cte", + "len": 95, + "last": 95, + "list": { + "@type": "PhpMyAdmin\\SqlParser\\TokensList", + "tokens": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "CREATE", + "value": "CREATE", + "keyword": "CREATE", + "type": 1, + "flags": 3, + "position": 0 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 6 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "table", + "value": "TABLE", + "keyword": "TABLE", + "type": 1, + "flags": 3, + "position": 7 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 12 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "table_name", + "value": "table_name", + "keyword": "TABLE_NAME", + "type": 1, + "flags": 1, + "position": 13 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 23 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "WITH", + "value": "WITH", + "keyword": "WITH", + "type": 1, + "flags": 3, + "position": 24 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 28 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "cte", + "value": "cte", + "keyword": null, + "type": 0, + "flags": 0, + "position": 29 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 32 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "(", + "value": "(", + "keyword": null, + "type": 2, + "flags": 16, + "position": 33 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "col1", + "value": "col1", + "keyword": null, + "type": 0, + "flags": 0, + "position": 34 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": ")", + "value": ")", + "keyword": null, + "type": 2, + "flags": 16, + "position": 38 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 39 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "AS", + "value": "AS", + "keyword": "AS", + "type": 1, + "flags": 3, + "position": 40 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 42 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "(", + "value": "(", + "keyword": null, + "type": 2, + "flags": 16, + "position": 43 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 44 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "SELECT", + "value": "SELECT", + "keyword": "SELECT", + "type": 1, + "flags": 3, + "position": 45 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 51 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "1", + "value": 1, + "keyword": null, + "type": 6, + "flags": 0, + "position": 52 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 53 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "UNION ALL", + "value": "UNION ALL", + "keyword": "UNION ALL", + "type": 1, + "flags": 7, + "position": 54 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 63 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "SELECT", + "value": "SELECT", + "keyword": "SELECT", + "type": 1, + "flags": 3, + "position": 64 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 70 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "2", + "value": 2, + "keyword": null, + "type": 6, + "flags": 0, + "position": 71 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 72 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": ")", + "value": ")", + "keyword": null, + "type": 2, + "flags": 16, + "position": 73 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 74 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "SELECT", + "value": "SELECT", + "keyword": "SELECT", + "type": 1, + "flags": 3, + "position": 75 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 81 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "col1", + "value": "col1", + "keyword": null, + "type": 0, + "flags": 0, + "position": 82 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 86 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "FROM", + "value": "FROM", + "keyword": "FROM", + "type": 1, + "flags": 3, + "position": 87 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 91 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "cte", + "value": "cte", + "keyword": null, + "type": 0, + "flags": 0, + "position": 92 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": null, + "value": null, + "keyword": null, + "type": 9, + "flags": 0, + "position": null + } + ], + "count": 38, + "idx": 38 + }, + "DEFAULT_DELIMITER": ";", + "delimiter": ";", + "delimiterLen": 1, + "strict": false, + "errors": [] + }, + "parser": { + "@type": "PhpMyAdmin\\SqlParser\\Parser", + "STATEMENT_PARSERS": { + "DESCRIBE": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "DESC": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "EXPLAIN": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "FLUSH": "", + "GRANT": "", + "HELP": "", + "SET PASSWORD": "", + "STATUS": "", + "USE": "", + "ANALYZE": "PhpMyAdmin\\SqlParser\\Statements\\AnalyzeStatement", + "BACKUP": "PhpMyAdmin\\SqlParser\\Statements\\BackupStatement", + "CHECK": "PhpMyAdmin\\SqlParser\\Statements\\CheckStatement", + "CHECKSUM": "PhpMyAdmin\\SqlParser\\Statements\\ChecksumStatement", + "OPTIMIZE": "PhpMyAdmin\\SqlParser\\Statements\\OptimizeStatement", + "REPAIR": "PhpMyAdmin\\SqlParser\\Statements\\RepairStatement", + "RESTORE": "PhpMyAdmin\\SqlParser\\Statements\\RestoreStatement", + "SET": "PhpMyAdmin\\SqlParser\\Statements\\SetStatement", + "SHOW": "PhpMyAdmin\\SqlParser\\Statements\\ShowStatement", + "ALTER": "PhpMyAdmin\\SqlParser\\Statements\\AlterStatement", + "CREATE": "PhpMyAdmin\\SqlParser\\Statements\\CreateStatement", + "DROP": "PhpMyAdmin\\SqlParser\\Statements\\DropStatement", + "RENAME": "PhpMyAdmin\\SqlParser\\Statements\\RenameStatement", + "TRUNCATE": "PhpMyAdmin\\SqlParser\\Statements\\TruncateStatement", + "CALL": "PhpMyAdmin\\SqlParser\\Statements\\CallStatement", + "DELETE": "PhpMyAdmin\\SqlParser\\Statements\\DeleteStatement", + "DO": "", + "HANDLER": "", + "INSERT": "PhpMyAdmin\\SqlParser\\Statements\\InsertStatement", + "LOAD DATA": "PhpMyAdmin\\SqlParser\\Statements\\LoadStatement", + "REPLACE": "PhpMyAdmin\\SqlParser\\Statements\\ReplaceStatement", + "SELECT": "PhpMyAdmin\\SqlParser\\Statements\\SelectStatement", + "UPDATE": "PhpMyAdmin\\SqlParser\\Statements\\UpdateStatement", + "WITH": "PhpMyAdmin\\SqlParser\\Statements\\WithStatement", + "DEALLOCATE": "", + "EXECUTE": "", + "PREPARE": "", + "BEGIN": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "COMMIT": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "ROLLBACK": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "START TRANSACTION": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "PURGE": "PhpMyAdmin\\SqlParser\\Statements\\PurgeStatement", + "LOCK": "PhpMyAdmin\\SqlParser\\Statements\\LockStatement", + "UNLOCK": "PhpMyAdmin\\SqlParser\\Statements\\LockStatement" + }, + "KEYWORD_PARSERS": { + "PARTITION BY": [], + "SUBPARTITION BY": [], + "_OPTIONS": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "field": "options" + }, + "_END_OPTIONS": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "field": "end_options" + }, + "INTERSECT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "EXCEPT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION ALL": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION DISTINCT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "ALTER": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "ANALYZE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "BACKUP": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CALL": { + "class": "PhpMyAdmin\\SqlParser\\Components\\FunctionCall", + "field": "call" + }, + "CHECK": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CHECKSUM": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CROSS JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "DROP": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "fields", + "options": { + "parseField": "table" + } + }, + "FORCE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "FROM": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "from", + "options": { + "field": "table" + } + }, + "GROUP BY": { + "class": "PhpMyAdmin\\SqlParser\\Components\\GroupKeyword", + "field": "group" + }, + "HAVING": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "field": "having" + }, + "IGNORE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "INTO": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IntoKeyword", + "field": "into" + }, + "JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LEFT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LEFT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "ON": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "RIGHT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "RIGHT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "INNER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "FULL JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "FULL OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL LEFT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL RIGHT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL LEFT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL RIGHT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "STRAIGHT_JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LIMIT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Limit", + "field": "limit" + }, + "OPTIMIZE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "ORDER BY": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OrderKeyword", + "field": "order" + }, + "PARTITION": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ArrayObj", + "field": "partition" + }, + "PROCEDURE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\FunctionCall", + "field": "procedure" + }, + "RENAME": { + "class": "PhpMyAdmin\\SqlParser\\Components\\RenameOperation", + "field": "renames" + }, + "REPAIR": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "RESTORE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "SET": { + "class": "PhpMyAdmin\\SqlParser\\Components\\SetOperation", + "field": "set" + }, + "SELECT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "expr" + }, + "TRUNCATE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "UPDATE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "USE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "VALUE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Array2d", + "field": "values" + }, + "VALUES": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Array2d", + "field": "values" + }, + "WHERE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "field": "where" + } + }, + "list": { + "@type": "@1" + }, + "statements": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Statements\\CreateStatement", + "OPTIONS": { + "TEMPORARY": 1, + "OR REPLACE": 2, + "ALGORITHM": [ + 3, + "var=" + ], + "DEFINER": [ + 4, + "expr=" + ], + "SQL SECURITY": [ + 5, + "var" + ], + "DATABASE": 6, + "EVENT": 6, + "FUNCTION": 6, + "INDEX": 6, + "UNIQUE INDEX": 6, + "FULLTEXT INDEX": 6, + "SPATIAL INDEX": 6, + "PROCEDURE": 6, + "SERVER": 6, + "TABLE": 6, + "TABLESPACE": 6, + "TRIGGER": 6, + "USER": 6, + "VIEW": 6, + "SCHEMA": 6, + "IF NOT EXISTS": 7 + }, + "DB_OPTIONS": { + "CHARACTER SET": [ + 1, + "var=" + ], + "CHARSET": [ + 1, + "var=" + ], + "DEFAULT CHARACTER SET": [ + 1, + "var=" + ], + "DEFAULT CHARSET": [ + 1, + "var=" + ], + "DEFAULT COLLATE": [ + 2, + "var=" + ], + "COLLATE": [ + 2, + "var=" + ] + }, + "TABLE_OPTIONS": { + "ENGINE": [ + 1, + "var=" + ], + "AUTO_INCREMENT": [ + 2, + "var=" + ], + "AVG_ROW_LENGTH": [ + 3, + "var" + ], + "CHARACTER SET": [ + 4, + "var=" + ], + "CHARSET": [ + 4, + "var=" + ], + "DEFAULT CHARACTER SET": [ + 4, + "var=" + ], + "DEFAULT CHARSET": [ + 4, + "var=" + ], + "CHECKSUM": [ + 5, + "var" + ], + "DEFAULT COLLATE": [ + 6, + "var=" + ], + "COLLATE": [ + 6, + "var=" + ], + "COMMENT": [ + 7, + "var=" + ], + "CONNECTION": [ + 8, + "var" + ], + "DATA DIRECTORY": [ + 9, + "var" + ], + "DELAY_KEY_WRITE": [ + 10, + "var" + ], + "INDEX DIRECTORY": [ + 11, + "var" + ], + "INSERT_METHOD": [ + 12, + "var" + ], + "KEY_BLOCK_SIZE": [ + 13, + "var" + ], + "MAX_ROWS": [ + 14, + "var" + ], + "MIN_ROWS": [ + 15, + "var" + ], + "PACK_KEYS": [ + 16, + "var" + ], + "PASSWORD": [ + 17, + "var" + ], + "ROW_FORMAT": [ + 18, + "var" + ], + "TABLESPACE": [ + 19, + "var" + ], + "STORAGE": [ + 20, + "var" + ], + "UNION": [ + 21, + "var" + ] + }, + "FUNC_OPTIONS": { + "NOT": [ + 2, + "var" + ], + "FUNCTION": [ + 3, + "var=" + ], + "PROCEDURE": [ + 3, + "var=" + ], + "CONTAINS": [ + 4, + "expr" + ], + "NO": [ + 4, + "var" + ], + "READS": [ + 4, + "var" + ], + "MODIFIES": [ + 4, + "expr" + ], + "SQL SECURITY": [ + 6, + "var" + ], + "LANGUAGE": [ + 7, + "var" + ], + "COMMENT": [ + 8, + "var" + ], + "CREATE": 1, + "DETERMINISTIC": 2, + "DATA": 5 + }, + "TRIGGER_OPTIONS": { + "BEFORE": 1, + "AFTER": 1, + "INSERT": 2, + "UPDATE": 2, + "DELETE": 2 + }, + "name": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "ALLOWED_KEYWORDS": { + "AS": 1, + "DUAL": 1, + "NULL": 1, + "REGEXP": 1, + "CASE": 1, + "DIV": 1, + "AND": 1, + "OR": 1, + "XOR": 1, + "NOT": 1, + "MOD": 1, + "OVER": 2 + }, + "database": null, + "table": "table_name", + "column": null, + "expr": "table_name", + "alias": null, + "function": null, + "subquery": null + }, + "entityOptions": null, + "fields": null, + "with": { + "@type": "PhpMyAdmin\\SqlParser\\Statements\\WithStatement", + "OPTIONS": { + "RECURSIVE": 1 + }, + "CLAUSES": { + "WITH": [ + "WITH", + 2 + ], + "_OPTIONS": [ + "_OPTIONS", + 1 + ], + "AS": [ + "AS", + 2 + ] + }, + "withers": { + "cte": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\WithKeyword", + "name": "cte", + "columns": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\ArrayObj", + "raw": [ + "col1" + ], + "values": [ + "col1" + ] + } + ], + "statement": { + "@type": "PhpMyAdmin\\SqlParser\\Parser", + "STATEMENT_PARSERS": { + "DESCRIBE": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "DESC": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "EXPLAIN": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "FLUSH": "", + "GRANT": "", + "HELP": "", + "SET PASSWORD": "", + "STATUS": "", + "USE": "", + "ANALYZE": "PhpMyAdmin\\SqlParser\\Statements\\AnalyzeStatement", + "BACKUP": "PhpMyAdmin\\SqlParser\\Statements\\BackupStatement", + "CHECK": "PhpMyAdmin\\SqlParser\\Statements\\CheckStatement", + "CHECKSUM": "PhpMyAdmin\\SqlParser\\Statements\\ChecksumStatement", + "OPTIMIZE": "PhpMyAdmin\\SqlParser\\Statements\\OptimizeStatement", + "REPAIR": "PhpMyAdmin\\SqlParser\\Statements\\RepairStatement", + "RESTORE": "PhpMyAdmin\\SqlParser\\Statements\\RestoreStatement", + "SET": "PhpMyAdmin\\SqlParser\\Statements\\SetStatement", + "SHOW": "PhpMyAdmin\\SqlParser\\Statements\\ShowStatement", + "ALTER": "PhpMyAdmin\\SqlParser\\Statements\\AlterStatement", + "CREATE": "PhpMyAdmin\\SqlParser\\Statements\\CreateStatement", + "DROP": "PhpMyAdmin\\SqlParser\\Statements\\DropStatement", + "RENAME": "PhpMyAdmin\\SqlParser\\Statements\\RenameStatement", + "TRUNCATE": "PhpMyAdmin\\SqlParser\\Statements\\TruncateStatement", + "CALL": "PhpMyAdmin\\SqlParser\\Statements\\CallStatement", + "DELETE": "PhpMyAdmin\\SqlParser\\Statements\\DeleteStatement", + "DO": "", + "HANDLER": "", + "INSERT": "PhpMyAdmin\\SqlParser\\Statements\\InsertStatement", + "LOAD DATA": "PhpMyAdmin\\SqlParser\\Statements\\LoadStatement", + "REPLACE": "PhpMyAdmin\\SqlParser\\Statements\\ReplaceStatement", + "SELECT": "PhpMyAdmin\\SqlParser\\Statements\\SelectStatement", + "UPDATE": "PhpMyAdmin\\SqlParser\\Statements\\UpdateStatement", + "WITH": "PhpMyAdmin\\SqlParser\\Statements\\WithStatement", + "DEALLOCATE": "", + "EXECUTE": "", + "PREPARE": "", + "BEGIN": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "COMMIT": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "ROLLBACK": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "START TRANSACTION": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "PURGE": "PhpMyAdmin\\SqlParser\\Statements\\PurgeStatement", + "LOCK": "PhpMyAdmin\\SqlParser\\Statements\\LockStatement", + "UNLOCK": "PhpMyAdmin\\SqlParser\\Statements\\LockStatement" + }, + "KEYWORD_PARSERS": { + "PARTITION BY": [], + "SUBPARTITION BY": [], + "_OPTIONS": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "field": "options" + }, + "_END_OPTIONS": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "field": "end_options" + }, + "INTERSECT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "EXCEPT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION ALL": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION DISTINCT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "ALTER": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "ANALYZE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "BACKUP": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CALL": { + "class": "PhpMyAdmin\\SqlParser\\Components\\FunctionCall", + "field": "call" + }, + "CHECK": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CHECKSUM": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CROSS JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "DROP": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "fields", + "options": { + "parseField": "table" + } + }, + "FORCE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "FROM": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "from", + "options": { + "field": "table" + } + }, + "GROUP BY": { + "class": "PhpMyAdmin\\SqlParser\\Components\\GroupKeyword", + "field": "group" + }, + "HAVING": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "field": "having" + }, + "IGNORE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "INTO": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IntoKeyword", + "field": "into" + }, + "JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LEFT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LEFT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "ON": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "RIGHT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "RIGHT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "INNER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "FULL JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "FULL OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL LEFT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL RIGHT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL LEFT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL RIGHT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "STRAIGHT_JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LIMIT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Limit", + "field": "limit" + }, + "OPTIMIZE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "ORDER BY": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OrderKeyword", + "field": "order" + }, + "PARTITION": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ArrayObj", + "field": "partition" + }, + "PROCEDURE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\FunctionCall", + "field": "procedure" + }, + "RENAME": { + "class": "PhpMyAdmin\\SqlParser\\Components\\RenameOperation", + "field": "renames" + }, + "REPAIR": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "RESTORE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "SET": { + "class": "PhpMyAdmin\\SqlParser\\Components\\SetOperation", + "field": "set" + }, + "SELECT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "expr" + }, + "TRUNCATE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "UPDATE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "USE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "VALUE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Array2d", + "field": "values" + }, + "VALUES": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Array2d", + "field": "values" + }, + "WHERE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "field": "where" + } + }, + "list": { + "@type": "PhpMyAdmin\\SqlParser\\TokensList", + "tokens": [ + { + "@type": "@19" + }, + { + "@type": "@20" + }, + { + "@type": "@21" + }, + { + "@type": "@22" + }, + { + "@type": "@23" + }, + { + "@type": "@24" + }, + { + "@type": "@25" + }, + { + "@type": "@26" + }, + { + "@type": "@27" + }, + { + "@type": "@28" + }, + { + "@type": "@29" + } + ], + "count": 11, + "idx": 11 + }, + "statements": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Statements\\SelectStatement", + "OPTIONS": { + "ALL": 1, + "DISTINCT": 1, + "DISTINCTROW": 1, + "HIGH_PRIORITY": 2, + "MAX_STATEMENT_TIME": [ + 3, + "var=" + ], + "STRAIGHT_JOIN": 4, + "SQL_SMALL_RESULT": 5, + "SQL_BIG_RESULT": 6, + "SQL_BUFFER_RESULT": 7, + "SQL_CACHE": 8, + "SQL_NO_CACHE": 8, + "SQL_CALC_FOUND_ROWS": 9 + }, + "END_OPTIONS": { + "FOR UPDATE": 1, + "LOCK IN SHARE MODE": 1 + }, + "CLAUSES": { + "SELECT": [ + "SELECT", + 2 + ], + "_OPTIONS": [ + "_OPTIONS", + 1 + ], + "_SELECT": [ + "SELECT", + 1 + ], + "INTO": [ + "INTO", + 3 + ], + "FROM": [ + "FROM", + 3 + ], + "FORCE": [ + "FORCE", + 1 + ], + "USE": [ + "USE", + 1 + ], + "IGNORE": [ + "IGNORE", + 3 + ], + "PARTITION": [ + "PARTITION", + 3 + ], + "JOIN": [ + "JOIN", + 1 + ], + "FULL JOIN": [ + "FULL JOIN", + 1 + ], + "INNER JOIN": [ + "INNER JOIN", + 1 + ], + "LEFT JOIN": [ + "LEFT JOIN", + 1 + ], + "LEFT OUTER JOIN": [ + "LEFT OUTER JOIN", + 1 + ], + "RIGHT JOIN": [ + "RIGHT JOIN", + 1 + ], + "RIGHT OUTER JOIN": [ + "RIGHT OUTER JOIN", + 1 + ], + "NATURAL JOIN": [ + "NATURAL JOIN", + 1 + ], + "NATURAL LEFT JOIN": [ + "NATURAL LEFT JOIN", + 1 + ], + "NATURAL RIGHT JOIN": [ + "NATURAL RIGHT JOIN", + 1 + ], + "NATURAL LEFT OUTER JOIN": [ + "NATURAL LEFT OUTER JOIN", + 1 + ], + "NATURAL RIGHT OUTER JOIN": [ + "NATURAL RIGHT JOIN", + 1 + ], + "WHERE": [ + "WHERE", + 3 + ], + "GROUP BY": [ + "GROUP BY", + 3 + ], + "HAVING": [ + "HAVING", + 3 + ], + "ORDER BY": [ + "ORDER BY", + 3 + ], + "LIMIT": [ + "LIMIT", + 3 + ], + "PROCEDURE": [ + "PROCEDURE", + 3 + ], + "UNION": [ + "UNION", + 1 + ], + "EXCEPT": [ + "EXCEPT", + 1 + ], + "INTERSECT": [ + "INTERSECT", + 1 + ], + "_END_OPTIONS": [ + "_END_OPTIONS", + 1 + ] + }, + "expr": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "ALLOWED_KEYWORDS": { + "AS": 1, + "DUAL": 1, + "NULL": 1, + "REGEXP": 1, + "CASE": 1, + "DIV": 1, + "AND": 1, + "OR": 1, + "XOR": 1, + "NOT": 1, + "MOD": 1, + "OVER": 2 + }, + "database": null, + "table": null, + "column": null, + "expr": "1", + "alias": null, + "function": null, + "subquery": null + } + ], + "from": [], + "index_hints": null, + "partition": null, + "where": null, + "group": null, + "having": null, + "order": null, + "limit": null, + "procedure": null, + "into": null, + "join": null, + "union": [ + [ + "UNION ALL", + { + "@type": "PhpMyAdmin\\SqlParser\\Statements\\SelectStatement", + "OPTIONS": { + "ALL": 1, + "DISTINCT": 1, + "DISTINCTROW": 1, + "HIGH_PRIORITY": 2, + "MAX_STATEMENT_TIME": [ + 3, + "var=" + ], + "STRAIGHT_JOIN": 4, + "SQL_SMALL_RESULT": 5, + "SQL_BIG_RESULT": 6, + "SQL_BUFFER_RESULT": 7, + "SQL_CACHE": 8, + "SQL_NO_CACHE": 8, + "SQL_CALC_FOUND_ROWS": 9 + }, + "END_OPTIONS": { + "FOR UPDATE": 1, + "LOCK IN SHARE MODE": 1 + }, + "CLAUSES": { + "SELECT": [ + "SELECT", + 2 + ], + "_OPTIONS": [ + "_OPTIONS", + 1 + ], + "_SELECT": [ + "SELECT", + 1 + ], + "INTO": [ + "INTO", + 3 + ], + "FROM": [ + "FROM", + 3 + ], + "FORCE": [ + "FORCE", + 1 + ], + "USE": [ + "USE", + 1 + ], + "IGNORE": [ + "IGNORE", + 3 + ], + "PARTITION": [ + "PARTITION", + 3 + ], + "JOIN": [ + "JOIN", + 1 + ], + "FULL JOIN": [ + "FULL JOIN", + 1 + ], + "INNER JOIN": [ + "INNER JOIN", + 1 + ], + "LEFT JOIN": [ + "LEFT JOIN", + 1 + ], + "LEFT OUTER JOIN": [ + "LEFT OUTER JOIN", + 1 + ], + "RIGHT JOIN": [ + "RIGHT JOIN", + 1 + ], + "RIGHT OUTER JOIN": [ + "RIGHT OUTER JOIN", + 1 + ], + "NATURAL JOIN": [ + "NATURAL JOIN", + 1 + ], + "NATURAL LEFT JOIN": [ + "NATURAL LEFT JOIN", + 1 + ], + "NATURAL RIGHT JOIN": [ + "NATURAL RIGHT JOIN", + 1 + ], + "NATURAL LEFT OUTER JOIN": [ + "NATURAL LEFT OUTER JOIN", + 1 + ], + "NATURAL RIGHT OUTER JOIN": [ + "NATURAL RIGHT JOIN", + 1 + ], + "WHERE": [ + "WHERE", + 3 + ], + "GROUP BY": [ + "GROUP BY", + 3 + ], + "HAVING": [ + "HAVING", + 3 + ], + "ORDER BY": [ + "ORDER BY", + 3 + ], + "LIMIT": [ + "LIMIT", + 3 + ], + "PROCEDURE": [ + "PROCEDURE", + 3 + ], + "UNION": [ + "UNION", + 1 + ], + "EXCEPT": [ + "EXCEPT", + 1 + ], + "INTERSECT": [ + "INTERSECT", + 1 + ], + "_END_OPTIONS": [ + "_END_OPTIONS", + 1 + ] + }, + "expr": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "ALLOWED_KEYWORDS": { + "AS": 1, + "DUAL": 1, + "NULL": 1, + "REGEXP": 1, + "CASE": 1, + "DIV": 1, + "AND": 1, + "OR": 1, + "XOR": 1, + "NOT": 1, + "MOD": 1, + "OVER": 2 + }, + "database": null, + "table": null, + "column": null, + "expr": "2", + "alias": null, + "function": null, + "subquery": null + } + ], + "from": [], + "index_hints": null, + "partition": null, + "where": null, + "group": null, + "having": null, + "order": [], + "limit": null, + "procedure": null, + "into": null, + "join": null, + "union": [], + "end_options": null, + "options": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "options": [] + }, + "first": 5, + "last": 10 + } + ] + ], + "end_options": null, + "options": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "options": [] + }, + "first": 0, + "last": 10 + } + ], + "brackets": 0, + "strict": false, + "errors": [] + } + } + }, + "END_OPTIONS": [], + "options": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "options": [] + }, + "first": null, + "last": null + }, + "select": null, + "like": null, + "partitionBy": null, + "partitionsNum": null, + "subpartitionBy": null, + "subpartitionsNum": null, + "partitions": null, + "table": null, + "return": null, + "parameters": null, + "body": [], + "CLAUSES": [], + "END_OPTIONS": [], + "options": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "options": { + "6": "TABLE" + } + }, + "first": 0, + "last": 36 + } + ], + "brackets": 0, + "strict": false, + "errors": [] + }, + "errors": { + "lexer": [], + "parser": [] + } +} \ No newline at end of file diff --git a/tests/data/parser/parseWithStatement3.in b/tests/data/parser/parseWithStatement3.in new file mode 100644 index 000000000..66792dece --- /dev/null +++ b/tests/data/parser/parseWithStatement3.in @@ -0,0 +1 @@ +INSERT INTO table_name WITH cte (col1) AS ( SELECT 1 ) SELECT col1 FROM cte ON DUPLICATE KEY UPDATE col_name = 3 \ No newline at end of file diff --git a/tests/data/parser/parseWithStatement3.out b/tests/data/parser/parseWithStatement3.out new file mode 100644 index 000000000..245232fb9 --- /dev/null +++ b/tests/data/parser/parseWithStatement3.out @@ -0,0 +1,1408 @@ +{ + "query": "INSERT INTO table_name WITH cte (col1) AS ( SELECT 1 ) SELECT col1 FROM cte ON DUPLICATE KEY UPDATE col_name = 3", + "lexer": { + "@type": "PhpMyAdmin\\SqlParser\\Lexer", + "PARSER_METHODS": [ + "parseDelimiter", + "parseWhitespace", + "parseNumber", + "parseComment", + "parseOperator", + "parseBool", + "parseString", + "parseSymbol", + "parseKeyword", + "parseLabel", + "parseUnknown" + ], + "str": "INSERT INTO table_name WITH cte (col1) AS ( SELECT 1 ) SELECT col1 FROM cte ON DUPLICATE KEY UPDATE col_name = 3", + "len": 112, + "last": 112, + "list": { + "@type": "PhpMyAdmin\\SqlParser\\TokensList", + "tokens": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "INSERT", + "value": "INSERT", + "keyword": "INSERT", + "type": 1, + "flags": 35, + "position": 0 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 6 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "INTO", + "value": "INTO", + "keyword": "INTO", + "type": 1, + "flags": 3, + "position": 7 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 11 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "table_name", + "value": "table_name", + "keyword": "TABLE_NAME", + "type": 1, + "flags": 1, + "position": 12 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 22 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "WITH", + "value": "WITH", + "keyword": "WITH", + "type": 1, + "flags": 3, + "position": 23 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 27 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "cte", + "value": "cte", + "keyword": null, + "type": 0, + "flags": 0, + "position": 28 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 31 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "(", + "value": "(", + "keyword": null, + "type": 2, + "flags": 16, + "position": 32 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "col1", + "value": "col1", + "keyword": null, + "type": 0, + "flags": 0, + "position": 33 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": ")", + "value": ")", + "keyword": null, + "type": 2, + "flags": 16, + "position": 37 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 38 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "AS", + "value": "AS", + "keyword": "AS", + "type": 1, + "flags": 3, + "position": 39 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 41 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "(", + "value": "(", + "keyword": null, + "type": 2, + "flags": 16, + "position": 42 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 43 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "SELECT", + "value": "SELECT", + "keyword": "SELECT", + "type": 1, + "flags": 3, + "position": 44 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 50 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "1", + "value": 1, + "keyword": null, + "type": 6, + "flags": 0, + "position": 51 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 52 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": ")", + "value": ")", + "keyword": null, + "type": 2, + "flags": 16, + "position": 53 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 54 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "SELECT", + "value": "SELECT", + "keyword": "SELECT", + "type": 1, + "flags": 3, + "position": 55 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 61 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "col1", + "value": "col1", + "keyword": null, + "type": 0, + "flags": 0, + "position": 62 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 66 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "FROM", + "value": "FROM", + "keyword": "FROM", + "type": 1, + "flags": 3, + "position": 67 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 71 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "cte", + "value": "cte", + "keyword": null, + "type": 0, + "flags": 0, + "position": 72 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 75 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "ON", + "value": "ON", + "keyword": "ON", + "type": 1, + "flags": 3, + "position": 76 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 78 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "DUPLICATE", + "value": "DUPLICATE", + "keyword": "DUPLICATE", + "type": 1, + "flags": 1, + "position": 79 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 88 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "KEY", + "value": "KEY", + "keyword": "KEY", + "type": 1, + "flags": 19, + "position": 89 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 92 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "UPDATE", + "value": "UPDATE", + "keyword": "UPDATE", + "type": 1, + "flags": 3, + "position": 93 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 99 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "col_name", + "value": "col_name", + "keyword": null, + "type": 0, + "flags": 0, + "position": 100 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 108 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "=", + "value": "=", + "keyword": null, + "type": 2, + "flags": 2, + "position": 109 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 110 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "3", + "value": 3, + "keyword": null, + "type": 6, + "flags": 0, + "position": 111 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": null, + "value": null, + "keyword": null, + "type": 9, + "flags": 0, + "position": null + } + ], + "count": 46, + "idx": 46 + }, + "DEFAULT_DELIMITER": ";", + "delimiter": ";", + "delimiterLen": 1, + "strict": false, + "errors": [] + }, + "parser": { + "@type": "PhpMyAdmin\\SqlParser\\Parser", + "STATEMENT_PARSERS": { + "DESCRIBE": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "DESC": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "EXPLAIN": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "FLUSH": "", + "GRANT": "", + "HELP": "", + "SET PASSWORD": "", + "STATUS": "", + "USE": "", + "ANALYZE": "PhpMyAdmin\\SqlParser\\Statements\\AnalyzeStatement", + "BACKUP": "PhpMyAdmin\\SqlParser\\Statements\\BackupStatement", + "CHECK": "PhpMyAdmin\\SqlParser\\Statements\\CheckStatement", + "CHECKSUM": "PhpMyAdmin\\SqlParser\\Statements\\ChecksumStatement", + "OPTIMIZE": "PhpMyAdmin\\SqlParser\\Statements\\OptimizeStatement", + "REPAIR": "PhpMyAdmin\\SqlParser\\Statements\\RepairStatement", + "RESTORE": "PhpMyAdmin\\SqlParser\\Statements\\RestoreStatement", + "SET": "PhpMyAdmin\\SqlParser\\Statements\\SetStatement", + "SHOW": "PhpMyAdmin\\SqlParser\\Statements\\ShowStatement", + "ALTER": "PhpMyAdmin\\SqlParser\\Statements\\AlterStatement", + "CREATE": "PhpMyAdmin\\SqlParser\\Statements\\CreateStatement", + "DROP": "PhpMyAdmin\\SqlParser\\Statements\\DropStatement", + "RENAME": "PhpMyAdmin\\SqlParser\\Statements\\RenameStatement", + "TRUNCATE": "PhpMyAdmin\\SqlParser\\Statements\\TruncateStatement", + "CALL": "PhpMyAdmin\\SqlParser\\Statements\\CallStatement", + "DELETE": "PhpMyAdmin\\SqlParser\\Statements\\DeleteStatement", + "DO": "", + "HANDLER": "", + "INSERT": "PhpMyAdmin\\SqlParser\\Statements\\InsertStatement", + "LOAD DATA": "PhpMyAdmin\\SqlParser\\Statements\\LoadStatement", + "REPLACE": "PhpMyAdmin\\SqlParser\\Statements\\ReplaceStatement", + "SELECT": "PhpMyAdmin\\SqlParser\\Statements\\SelectStatement", + "UPDATE": "PhpMyAdmin\\SqlParser\\Statements\\UpdateStatement", + "WITH": "PhpMyAdmin\\SqlParser\\Statements\\WithStatement", + "DEALLOCATE": "", + "EXECUTE": "", + "PREPARE": "", + "BEGIN": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "COMMIT": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "ROLLBACK": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "START TRANSACTION": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "PURGE": "PhpMyAdmin\\SqlParser\\Statements\\PurgeStatement", + "LOCK": "PhpMyAdmin\\SqlParser\\Statements\\LockStatement", + "UNLOCK": "PhpMyAdmin\\SqlParser\\Statements\\LockStatement" + }, + "KEYWORD_PARSERS": { + "PARTITION BY": [], + "SUBPARTITION BY": [], + "_OPTIONS": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "field": "options" + }, + "_END_OPTIONS": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "field": "end_options" + }, + "INTERSECT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "EXCEPT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION ALL": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION DISTINCT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "ALTER": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "ANALYZE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "BACKUP": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CALL": { + "class": "PhpMyAdmin\\SqlParser\\Components\\FunctionCall", + "field": "call" + }, + "CHECK": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CHECKSUM": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CROSS JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "DROP": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "fields", + "options": { + "parseField": "table" + } + }, + "FORCE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "FROM": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "from", + "options": { + "field": "table" + } + }, + "GROUP BY": { + "class": "PhpMyAdmin\\SqlParser\\Components\\GroupKeyword", + "field": "group" + }, + "HAVING": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "field": "having" + }, + "IGNORE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "INTO": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IntoKeyword", + "field": "into" + }, + "JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LEFT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LEFT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "ON": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "RIGHT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "RIGHT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "INNER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "FULL JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "FULL OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL LEFT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL RIGHT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL LEFT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL RIGHT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "STRAIGHT_JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LIMIT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Limit", + "field": "limit" + }, + "OPTIMIZE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "ORDER BY": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OrderKeyword", + "field": "order" + }, + "PARTITION": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ArrayObj", + "field": "partition" + }, + "PROCEDURE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\FunctionCall", + "field": "procedure" + }, + "RENAME": { + "class": "PhpMyAdmin\\SqlParser\\Components\\RenameOperation", + "field": "renames" + }, + "REPAIR": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "RESTORE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "SET": { + "class": "PhpMyAdmin\\SqlParser\\Components\\SetOperation", + "field": "set" + }, + "SELECT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "expr" + }, + "TRUNCATE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "UPDATE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "USE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "VALUE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Array2d", + "field": "values" + }, + "VALUES": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Array2d", + "field": "values" + }, + "WHERE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "field": "where" + } + }, + "list": { + "@type": "@1" + }, + "statements": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Statements\\InsertStatement", + "OPTIONS": { + "LOW_PRIORITY": 1, + "DELAYED": 2, + "HIGH_PRIORITY": 3, + "IGNORE": 4 + }, + "into": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\IntoKeyword", + "FIELDS_OPTIONS": { + "TERMINATED BY": [ + 1, + "expr" + ], + "OPTIONALLY": 2, + "ENCLOSED BY": [ + 3, + "expr" + ], + "ESCAPED BY": [ + 4, + "expr" + ] + }, + "LINES_OPTIONS": { + "STARTING BY": [ + 1, + "expr" + ], + "TERMINATED BY": [ + 2, + "expr" + ] + }, + "type": null, + "dest": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "ALLOWED_KEYWORDS": { + "AS": 1, + "DUAL": 1, + "NULL": 1, + "REGEXP": 1, + "CASE": 1, + "DIV": 1, + "AND": 1, + "OR": 1, + "XOR": 1, + "NOT": 1, + "MOD": 1, + "OVER": 2 + }, + "database": null, + "table": "table_name", + "column": null, + "expr": "table_name", + "alias": null, + "function": null, + "subquery": null + }, + "columns": null, + "values": null, + "fields_options": null, + "fields_keyword": null, + "lines_options": null + }, + "values": null, + "set": null, + "select": { + "@type": "PhpMyAdmin\\SqlParser\\Statements\\WithStatement", + "OPTIONS": { + "RECURSIVE": 1 + }, + "CLAUSES": { + "WITH": [ + "WITH", + 2 + ], + "_OPTIONS": [ + "_OPTIONS", + 1 + ], + "AS": [ + "AS", + 2 + ] + }, + "withers": { + "cte": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\WithKeyword", + "name": "cte", + "columns": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\ArrayObj", + "raw": [ + "col1" + ], + "values": [ + "col1" + ] + } + ], + "statement": { + "@type": "PhpMyAdmin\\SqlParser\\Parser", + "STATEMENT_PARSERS": { + "DESCRIBE": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "DESC": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "EXPLAIN": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "FLUSH": "", + "GRANT": "", + "HELP": "", + "SET PASSWORD": "", + "STATUS": "", + "USE": "", + "ANALYZE": "PhpMyAdmin\\SqlParser\\Statements\\AnalyzeStatement", + "BACKUP": "PhpMyAdmin\\SqlParser\\Statements\\BackupStatement", + "CHECK": "PhpMyAdmin\\SqlParser\\Statements\\CheckStatement", + "CHECKSUM": "PhpMyAdmin\\SqlParser\\Statements\\ChecksumStatement", + "OPTIMIZE": "PhpMyAdmin\\SqlParser\\Statements\\OptimizeStatement", + "REPAIR": "PhpMyAdmin\\SqlParser\\Statements\\RepairStatement", + "RESTORE": "PhpMyAdmin\\SqlParser\\Statements\\RestoreStatement", + "SET": "PhpMyAdmin\\SqlParser\\Statements\\SetStatement", + "SHOW": "PhpMyAdmin\\SqlParser\\Statements\\ShowStatement", + "ALTER": "PhpMyAdmin\\SqlParser\\Statements\\AlterStatement", + "CREATE": "PhpMyAdmin\\SqlParser\\Statements\\CreateStatement", + "DROP": "PhpMyAdmin\\SqlParser\\Statements\\DropStatement", + "RENAME": "PhpMyAdmin\\SqlParser\\Statements\\RenameStatement", + "TRUNCATE": "PhpMyAdmin\\SqlParser\\Statements\\TruncateStatement", + "CALL": "PhpMyAdmin\\SqlParser\\Statements\\CallStatement", + "DELETE": "PhpMyAdmin\\SqlParser\\Statements\\DeleteStatement", + "DO": "", + "HANDLER": "", + "INSERT": "PhpMyAdmin\\SqlParser\\Statements\\InsertStatement", + "LOAD DATA": "PhpMyAdmin\\SqlParser\\Statements\\LoadStatement", + "REPLACE": "PhpMyAdmin\\SqlParser\\Statements\\ReplaceStatement", + "SELECT": "PhpMyAdmin\\SqlParser\\Statements\\SelectStatement", + "UPDATE": "PhpMyAdmin\\SqlParser\\Statements\\UpdateStatement", + "WITH": "PhpMyAdmin\\SqlParser\\Statements\\WithStatement", + "DEALLOCATE": "", + "EXECUTE": "", + "PREPARE": "", + "BEGIN": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "COMMIT": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "ROLLBACK": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "START TRANSACTION": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "PURGE": "PhpMyAdmin\\SqlParser\\Statements\\PurgeStatement", + "LOCK": "PhpMyAdmin\\SqlParser\\Statements\\LockStatement", + "UNLOCK": "PhpMyAdmin\\SqlParser\\Statements\\LockStatement" + }, + "KEYWORD_PARSERS": { + "PARTITION BY": [], + "SUBPARTITION BY": [], + "_OPTIONS": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "field": "options" + }, + "_END_OPTIONS": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "field": "end_options" + }, + "INTERSECT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "EXCEPT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION ALL": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION DISTINCT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "ALTER": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "ANALYZE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "BACKUP": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CALL": { + "class": "PhpMyAdmin\\SqlParser\\Components\\FunctionCall", + "field": "call" + }, + "CHECK": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CHECKSUM": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CROSS JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "DROP": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "fields", + "options": { + "parseField": "table" + } + }, + "FORCE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "FROM": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "from", + "options": { + "field": "table" + } + }, + "GROUP BY": { + "class": "PhpMyAdmin\\SqlParser\\Components\\GroupKeyword", + "field": "group" + }, + "HAVING": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "field": "having" + }, + "IGNORE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "INTO": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IntoKeyword", + "field": "into" + }, + "JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LEFT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LEFT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "ON": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "RIGHT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "RIGHT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "INNER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "FULL JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "FULL OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL LEFT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL RIGHT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL LEFT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL RIGHT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "STRAIGHT_JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LIMIT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Limit", + "field": "limit" + }, + "OPTIMIZE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "ORDER BY": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OrderKeyword", + "field": "order" + }, + "PARTITION": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ArrayObj", + "field": "partition" + }, + "PROCEDURE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\FunctionCall", + "field": "procedure" + }, + "RENAME": { + "class": "PhpMyAdmin\\SqlParser\\Components\\RenameOperation", + "field": "renames" + }, + "REPAIR": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "RESTORE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "SET": { + "class": "PhpMyAdmin\\SqlParser\\Components\\SetOperation", + "field": "set" + }, + "SELECT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "expr" + }, + "TRUNCATE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "UPDATE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "USE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "VALUE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Array2d", + "field": "values" + }, + "VALUES": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Array2d", + "field": "values" + }, + "WHERE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "field": "where" + } + }, + "list": { + "@type": "PhpMyAdmin\\SqlParser\\TokensList", + "tokens": [ + { + "@type": "@19" + }, + { + "@type": "@20" + }, + { + "@type": "@21" + }, + { + "@type": "@22" + }, + { + "@type": "@23" + } + ], + "count": 5, + "idx": 5 + }, + "statements": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Statements\\SelectStatement", + "OPTIONS": { + "ALL": 1, + "DISTINCT": 1, + "DISTINCTROW": 1, + "HIGH_PRIORITY": 2, + "MAX_STATEMENT_TIME": [ + 3, + "var=" + ], + "STRAIGHT_JOIN": 4, + "SQL_SMALL_RESULT": 5, + "SQL_BIG_RESULT": 6, + "SQL_BUFFER_RESULT": 7, + "SQL_CACHE": 8, + "SQL_NO_CACHE": 8, + "SQL_CALC_FOUND_ROWS": 9 + }, + "END_OPTIONS": { + "FOR UPDATE": 1, + "LOCK IN SHARE MODE": 1 + }, + "CLAUSES": { + "SELECT": [ + "SELECT", + 2 + ], + "_OPTIONS": [ + "_OPTIONS", + 1 + ], + "_SELECT": [ + "SELECT", + 1 + ], + "INTO": [ + "INTO", + 3 + ], + "FROM": [ + "FROM", + 3 + ], + "FORCE": [ + "FORCE", + 1 + ], + "USE": [ + "USE", + 1 + ], + "IGNORE": [ + "IGNORE", + 3 + ], + "PARTITION": [ + "PARTITION", + 3 + ], + "JOIN": [ + "JOIN", + 1 + ], + "FULL JOIN": [ + "FULL JOIN", + 1 + ], + "INNER JOIN": [ + "INNER JOIN", + 1 + ], + "LEFT JOIN": [ + "LEFT JOIN", + 1 + ], + "LEFT OUTER JOIN": [ + "LEFT OUTER JOIN", + 1 + ], + "RIGHT JOIN": [ + "RIGHT JOIN", + 1 + ], + "RIGHT OUTER JOIN": [ + "RIGHT OUTER JOIN", + 1 + ], + "NATURAL JOIN": [ + "NATURAL JOIN", + 1 + ], + "NATURAL LEFT JOIN": [ + "NATURAL LEFT JOIN", + 1 + ], + "NATURAL RIGHT JOIN": [ + "NATURAL RIGHT JOIN", + 1 + ], + "NATURAL LEFT OUTER JOIN": [ + "NATURAL LEFT OUTER JOIN", + 1 + ], + "NATURAL RIGHT OUTER JOIN": [ + "NATURAL RIGHT JOIN", + 1 + ], + "WHERE": [ + "WHERE", + 3 + ], + "GROUP BY": [ + "GROUP BY", + 3 + ], + "HAVING": [ + "HAVING", + 3 + ], + "ORDER BY": [ + "ORDER BY", + 3 + ], + "LIMIT": [ + "LIMIT", + 3 + ], + "PROCEDURE": [ + "PROCEDURE", + 3 + ], + "UNION": [ + "UNION", + 1 + ], + "EXCEPT": [ + "EXCEPT", + 1 + ], + "INTERSECT": [ + "INTERSECT", + 1 + ], + "_END_OPTIONS": [ + "_END_OPTIONS", + 1 + ] + }, + "expr": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "ALLOWED_KEYWORDS": { + "AS": 1, + "DUAL": 1, + "NULL": 1, + "REGEXP": 1, + "CASE": 1, + "DIV": 1, + "AND": 1, + "OR": 1, + "XOR": 1, + "NOT": 1, + "MOD": 1, + "OVER": 2 + }, + "database": null, + "table": null, + "column": null, + "expr": "1", + "alias": null, + "function": null, + "subquery": null + } + ], + "from": [], + "index_hints": null, + "partition": null, + "where": null, + "group": null, + "having": null, + "order": null, + "limit": null, + "procedure": null, + "into": null, + "join": null, + "union": [], + "end_options": null, + "options": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "options": [] + }, + "first": 0, + "last": 4 + } + ], + "brackets": 0, + "strict": false, + "errors": [] + } + } + }, + "END_OPTIONS": [], + "options": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "options": [] + }, + "first": null, + "last": null + }, + "onDuplicateSet": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\SetOperation", + "column": "col_name", + "value": "3" + } + ], + "CLAUSES": [], + "END_OPTIONS": [], + "options": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "options": [] + }, + "first": 0, + "last": 44 + } + ], + "brackets": 0, + "strict": false, + "errors": [] + }, + "errors": { + "lexer": [], + "parser": [] + } +} \ No newline at end of file From 835a537d485a24bfd9b377728b500890caa3f51f Mon Sep 17 00:00:00 2001 From: "Fawzi E. Abdulfattah" Date: Mon, 6 Dec 2021 00:53:55 +0200 Subject: [PATCH 02/12] Adding more test cases for withStatements Signed-off-by: Fawzi E. Abdulfattah --- src/Statements/CreateStatement.php | 2 +- src/Statements/WithStatement.php | 5 + tests/Parser/WithStatementTest.php | 26 + tests/data/parser/parseWithStatement1.in | 1 + tests/data/parser/parseWithStatement1.out | 1731 ++++++++++ tests/data/parser/parseWithStatement2.in | 2 +- tests/data/parser/parseWithStatement2.out | 761 ++--- tests/data/parser/parseWithStatement3.in | 2 +- tests/data/parser/parseWithStatement3.out | 3225 ++++++++++++++---- tests/data/parser/parseWithStatementErr.in | 1 + tests/data/parser/parseWithStatementErr.out | 827 +++++ tests/data/parser/parseWithStatementErr1.in | 1 + tests/data/parser/parseWithStatementErr1.out | 1612 +++++++++ tests/data/parser/parseWithStatementErr2.in | 1 + tests/data/parser/parseWithStatementErr2.out | 1358 ++++++++ tests/data/parser/parseWithStatementErr3.in | 1 + tests/data/parser/parseWithStatementErr3.out | 1683 +++++++++ tests/data/parser/parseWithStatementErr4.in | 1 + tests/data/parser/parseWithStatementErr4.out | 1699 +++++++++ tests/data/parser/parseWithStatementErr5.in | 1 + tests/data/parser/parseWithStatementErr5.out | 941 +++++ tests/data/parser/parseWithStatementErr6.in | 1 + tests/data/parser/parseWithStatementErr6.out | 1451 ++++++++ 23 files changed, 14052 insertions(+), 1281 deletions(-) create mode 100644 tests/data/parser/parseWithStatement1.in create mode 100644 tests/data/parser/parseWithStatement1.out create mode 100644 tests/data/parser/parseWithStatementErr.in create mode 100644 tests/data/parser/parseWithStatementErr.out create mode 100644 tests/data/parser/parseWithStatementErr1.in create mode 100644 tests/data/parser/parseWithStatementErr1.out create mode 100644 tests/data/parser/parseWithStatementErr2.in create mode 100644 tests/data/parser/parseWithStatementErr2.out create mode 100644 tests/data/parser/parseWithStatementErr3.in create mode 100644 tests/data/parser/parseWithStatementErr3.out create mode 100644 tests/data/parser/parseWithStatementErr4.in create mode 100644 tests/data/parser/parseWithStatementErr4.out create mode 100644 tests/data/parser/parseWithStatementErr5.in create mode 100644 tests/data/parser/parseWithStatementErr5.out create mode 100644 tests/data/parser/parseWithStatementErr6.in create mode 100644 tests/data/parser/parseWithStatementErr6.out diff --git a/src/Statements/CreateStatement.php b/src/Statements/CreateStatement.php index 694a5e79f..db28dc501 100644 --- a/src/Statements/CreateStatement.php +++ b/src/Statements/CreateStatement.php @@ -313,7 +313,7 @@ class CreateStatement extends Statement /** * If `CREATE TABLE WITH`. * If `CREATE TABLE AS WITH`. - * If `CREATE VIEW AS ` WITH`. + * If `CREATE VIEW AS WITH`. * * Used by `CREATE TABLE`, `CREATE VIEW` * diff --git a/src/Statements/WithStatement.php b/src/Statements/WithStatement.php index 186da3287..786389140 100644 --- a/src/Statements/WithStatement.php +++ b/src/Statements/WithStatement.php @@ -138,6 +138,11 @@ public function parse(Parser $parser, TokensList $list) break; } + if ($token->value !== 'SELECT') { + $parser->error('Unexpected keyword', $token); + break; + } + ++$list->idx; $subList = $this->getSubTokenList($list); if ($subList instanceof ParserException) { diff --git a/tests/Parser/WithStatementTest.php b/tests/Parser/WithStatementTest.php index 8e1a7110e..f3f671fd9 100644 --- a/tests/Parser/WithStatementTest.php +++ b/tests/Parser/WithStatementTest.php @@ -12,6 +12,32 @@ class WithStatementTest extends TestCase { + /** + * @param mixed $test + * + * @dataProvider parseWith + */ + public function testParse($test): void + { + $this->runParserTest($test); + } + + public function parseWith(): array + { + return [ + ['parser/parseWithStatement'], + ['parser/parseWithStatement1'], + ['parser/parseWithStatement2'], + ['parser/parseWithStatement3'], + ['parser/parseWithStatementErr'], + ['parser/parseWithStatementErr1'], + ['parser/parseWithStatementErr2'], + ['parser/parseWithStatementErr3'], + ['parser/parseWithStatementErr4'], + ['parser/parseWithStatementErr5'], + ]; + } + public function testWith(): void { $sql = << Date: Mon, 6 Dec 2021 02:53:21 +0200 Subject: [PATCH 03/12] Fixing phpstan issues, and adding more test cases Signed-off-by: Fawzi E. Abdulfattah --- src/Statements/CreateStatement.php | 17 +++++++--- src/Statements/InsertStatement.php | 10 +++++- src/Statements/WithStatement.php | 35 +++++++++++++------- tests/Builder/CreateStatementTest.php | 14 ++++++++ tests/Parser/WithStatementTest.php | 10 +++--- tests/data/parser/parseWithStatement.out | 3 +- tests/data/parser/parseWithStatement2.out | 3 +- tests/data/parser/parseWithStatementErr.out | 3 +- tests/data/parser/parseWithStatementErr3.out | 2 +- tests/data/parser/parseWithStatementErr5.out | 21 ++++-------- tests/data/parser/parseWithStatementErr6.out | 6 ++-- 11 files changed, 82 insertions(+), 42 deletions(-) diff --git a/src/Statements/CreateStatement.php b/src/Statements/CreateStatement.php index db28dc501..0fde49f04 100644 --- a/src/Statements/CreateStatement.php +++ b/src/Statements/CreateStatement.php @@ -447,6 +447,13 @@ public function build() . Expression::build($this->like); } + if ($this->with !== null) { + return 'CREATE ' + . OptionsArray::build($this->options) . ' ' + . Expression::build($this->name) . ' ' + . $this->with->build(); + } + $partition = ''; if (! empty($this->partitionBy)) { @@ -477,9 +484,9 @@ public function build() . $partition; } elseif ($this->options->has('VIEW')) { $builtStatement = ''; - if ($this->select) { + if ($this->select !== null) { $builtStatement = $this->select->build(); - } elseif ($this->with) { + } elseif ($this->with !== null) { $builtStatement = $this->with->build(); } @@ -564,7 +571,7 @@ public function parse(Parser $parser, TokensList $list) if (($token->type === Token::TYPE_KEYWORD) && ($token->keyword === 'SELECT')) { /* CREATE TABLE ... SELECT */ $this->select = new SelectStatement($parser, $list); - } elseif (($token->type === Token::TYPE_KEYWORD) && ($token->keyword === 'WITH')) { + } elseif ($token->type === Token::TYPE_KEYWORD && ($token->keyword === 'WITH')) { /* CREATE TABLE WITH */ $this->with = new WithStatement($parser, $list); } elseif ( @@ -575,10 +582,10 @@ public function parse(Parser $parser, TokensList $list) /* CREATE TABLE ... AS SELECT */ $list->idx = $nextidx; $this->select = new SelectStatement($parser, $list); - } elseif ($list->tokens[$nextidx]->value === 'SELECT') { + } elseif ($list->tokens[$nextidx]->value === 'WITH') { /* CREATE TABLE WITH */ $list->idx = $nextidx; - $this->select = new WithStatement($parser, $list); + $this->with = new WithStatement($parser, $list); } } elseif ($token->type === Token::TYPE_KEYWORD && $token->keyword === 'LIKE') { /* CREATE TABLE `new_tbl` LIKE 'orig_tbl' */ diff --git a/src/Statements/InsertStatement.php b/src/Statements/InsertStatement.php index 6ecc982f8..d21662a83 100644 --- a/src/Statements/InsertStatement.php +++ b/src/Statements/InsertStatement.php @@ -98,6 +98,14 @@ class InsertStatement extends Statement */ public $select; + /** + * If WITH CTE is present + * holds the WithStatement. + * + * @var WithStatement|null + */ + public $with; + /** * If ON DUPLICATE KEY UPDATE clause is present * holds the SetOperation. @@ -211,7 +219,7 @@ public function parse(Parser $parser, TokensList $list) } elseif ($token->keyword === 'SELECT') { $this->select = new SelectStatement($parser, $list); } elseif ($token->keyword === 'WITH') { - $this->select = new WithStatement($parser, $list); + $this->with = new WithStatement($parser, $list); } else { $parser->error('Unexpected keyword.', $token); break; diff --git a/src/Statements/WithStatement.php b/src/Statements/WithStatement.php index 786389140..414abd687 100644 --- a/src/Statements/WithStatement.php +++ b/src/Statements/WithStatement.php @@ -108,13 +108,14 @@ public function parse(Parser $parser, TokensList $list) } if ($state === 0) { - if ($token->type === Token::TYPE_NONE) { - $wither = $token->value; - $this->withers[$wither] = new WithKeyword($wither); - $state = 1; - } else { + if ($token->type !== Token::TYPE_NONE) { $parser->error('The name of the CTE was expected.', $token); + break; } + + $wither = $token->value; + $this->withers[$wither] = new WithKeyword($wither); + $state = 1; } elseif ($state === 1) { if ($token->type === Token::TYPE_OPERATOR && $token->value === '(') { $this->withers[$wither]->columns = Array2d::parse($parser, $list); @@ -133,21 +134,29 @@ public function parse(Parser $parser, TokensList $list) $state = 3; } elseif ($state === 3) { - if ($token->value !== '(') { + $idxBeforeGetNext = $list->idx; + + // We want to get the next non-comment and non-space token after $token + // therefore, the first getNext call will start with the current $idx which's $token, + // will return it and increase $idx by 1, which's not guaranteed to be non-comment + // and non-space, that's why we're calling getNext again. + $list->getNext(); + $nextKeyword = $list->getNext(); + + if (! ($token->value === '(' && ($nextKeyword && $nextKeyword->value === 'SELECT'))) { $parser->error('Subquery of the CTE was expected.', $token); + $list->idx = $idxBeforeGetNext; break; } - if ($token->value !== 'SELECT') { - $parser->error('Unexpected keyword', $token); - break; - } + // Restore the index + $list->idx = $idxBeforeGetNext; ++$list->idx; $subList = $this->getSubTokenList($list); if ($subList instanceof ParserException) { $parser->errors[] = $subList; - continue; + break; } $subParser = new Parser($subList); @@ -156,6 +165,8 @@ public function parse(Parser $parser, TokensList $list) foreach ($subParser->errors as $error) { $parser->errors[] = $error; } + + break; } $this->withers[$wither]->statement = $subParser; @@ -229,7 +240,7 @@ public function parse(Parser $parser, TokensList $list) // 5 is the only valid end state if ($state !== 5) { - $parser->error('Unexpected end of WITH CTE.', $token); + $parser->error('Unexpected end of WITH CTE.', $list->tokens[$list->idx]); } --$list->idx; diff --git a/tests/Builder/CreateStatementTest.php b/tests/Builder/CreateStatementTest.php index 0e8ac655c..d235bfb31 100644 --- a/tests/Builder/CreateStatementTest.php +++ b/tests/Builder/CreateStatementTest.php @@ -164,6 +164,20 @@ public function testBuilderTable(): void ') ENGINE=InnoDB DEFAULT CHARSET=latin1'; $parser = new Parser($query); $this->assertEquals($query, $parser->statements[0]->build()); + + /* Assertion 5 */ + $parser = new Parser( + 'CREATE table table_name WITH' . + ' cte (col1) AS ( SELECT 1 UNION ALL SELECT 2 )' . + ' SELECT col1 FROM cte' + ); + $stmt = $parser->statements[0]; + + $this->assertEquals( + 'CREATE TABLE table_name WITH' . + ' cte(col1) AS (SELECT 1 UNION ALL SELECT 2)', + $stmt->build() + ); } public function testBuilderPartitions(): void diff --git a/tests/Parser/WithStatementTest.php b/tests/Parser/WithStatementTest.php index f3f671fd9..95f88d299 100644 --- a/tests/Parser/WithStatementTest.php +++ b/tests/Parser/WithStatementTest.php @@ -13,15 +13,16 @@ class WithStatementTest extends TestCase { /** - * @param mixed $test - * * @dataProvider parseWith */ - public function testParse($test): void + public function testParse(string $test): void { $this->runParserTest($test); } + /** + * @return array> + */ public function parseWith(): array { return [ @@ -35,6 +36,7 @@ public function parseWith(): array ['parser/parseWithStatementErr3'], ['parser/parseWithStatementErr4'], ['parser/parseWithStatementErr5'], + ['parser/parseWithStatementErr6'], ]; } @@ -81,7 +83,7 @@ public function testWithHasErrors(): void $this->assertCount(0, $lexerErrors); $parser = new Parser($lexer->list); $parserErrors = $this->getErrorsAsArray($parser); - $this->assertCount(2, $parserErrors); + $this->assertCount(4, $parserErrors); } public function testWithEmbedParenthesis(): void diff --git a/tests/data/parser/parseWithStatement.out b/tests/data/parser/parseWithStatement.out index fa660cde2..9fa3073b6 100644 --- a/tests/data/parser/parseWithStatement.out +++ b/tests/data/parser/parseWithStatement.out @@ -743,7 +743,8 @@ }, "values": null, "set": null, - "select": { + "select": null, + "with": { "@type": "PhpMyAdmin\\SqlParser\\Statements\\WithStatement", "OPTIONS": { "RECURSIVE": 1 diff --git a/tests/data/parser/parseWithStatement2.out b/tests/data/parser/parseWithStatement2.out index 245232fb9..677aa58c5 100644 --- a/tests/data/parser/parseWithStatement2.out +++ b/tests/data/parser/parseWithStatement2.out @@ -815,7 +815,8 @@ }, "values": null, "set": null, - "select": { + "select": null, + "with": { "@type": "PhpMyAdmin\\SqlParser\\Statements\\WithStatement", "OPTIONS": { "RECURSIVE": 1 diff --git a/tests/data/parser/parseWithStatementErr.out b/tests/data/parser/parseWithStatementErr.out index 3990aa10c..13834b775 100644 --- a/tests/data/parser/parseWithStatementErr.out +++ b/tests/data/parser/parseWithStatementErr.out @@ -734,7 +734,8 @@ }, "values": null, "set": null, - "select": { + "select": null, + "with": { "@type": "PhpMyAdmin\\SqlParser\\Statements\\WithStatement", "OPTIONS": { "RECURSIVE": 1 diff --git a/tests/data/parser/parseWithStatementErr3.out b/tests/data/parser/parseWithStatementErr3.out index 4aebe7041..3c43475ca 100644 --- a/tests/data/parser/parseWithStatementErr3.out +++ b/tests/data/parser/parseWithStatementErr3.out @@ -1654,7 +1654,7 @@ } }, "first": 0, - "last": 30 + "last": 29 } ], "brackets": 0, diff --git a/tests/data/parser/parseWithStatementErr5.out b/tests/data/parser/parseWithStatementErr5.out index 5c35128b9..b00c29766 100644 --- a/tests/data/parser/parseWithStatementErr5.out +++ b/tests/data/parser/parseWithStatementErr5.out @@ -862,14 +862,7 @@ 2 ] }, - "withers": { - "col1": { - "@type": "PhpMyAdmin\\SqlParser\\Components\\WithKeyword", - "name": "col1", - "columns": [], - "statement": null - } - }, + "withers": [], "END_OPTIONS": [], "options": { "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", @@ -898,10 +891,10 @@ } }, "first": 0, - "last": 9 + "last": 7 } ], - "brackets": 0, + "brackets": 1, "strict": false, "errors": [] }, @@ -916,16 +909,16 @@ 0 ], [ - "Unexpected token.", + "Unexpected end of WITH CTE.", { - "@type": "@12" + "@type": "@10" }, 0 ], [ - "Unexpected end of WITH CTE.", + "Unexpected beginning of statement.", { - "@type": "@12" + "@type": "@11" }, 0 ], diff --git a/tests/data/parser/parseWithStatementErr6.out b/tests/data/parser/parseWithStatementErr6.out index 1a58b2358..652168b42 100644 --- a/tests/data/parser/parseWithStatementErr6.out +++ b/tests/data/parser/parseWithStatementErr6.out @@ -1031,7 +1031,8 @@ }, "values": null, "set": null, - "select": { + "select": null, + "with": { "@type": "PhpMyAdmin\\SqlParser\\Statements\\WithStatement", "OPTIONS": { "RECURSIVE": 1 @@ -1173,6 +1174,7 @@ ], "set": null, "select": null, + "with": null, "onDuplicateSet": null, "CLAUSES": [], "END_OPTIONS": [], @@ -1412,7 +1414,7 @@ "lexer": [], "parser": [ [ - "Unexpected keyword", + "Subquery of the CTE was expected.", { "@type": "@18" }, From 29611305a4cced9415720216817b3fcc65de5b1a Mon Sep 17 00:00:00 2001 From: "Fawzi E. Abdulfattah" Date: Mon, 6 Dec 2021 03:35:53 +0200 Subject: [PATCH 04/12] Adding more tests for withStatements Signed-off-by: Fawzi E. Abdulfattah --- tests/Builder/CreateStatementTest.php | 89 +- tests/Parser/WithStatementTest.php | 3 + tests/data/parser/parseWithStatement4.in | 1 + tests/data/parser/parseWithStatement4.out | 1717 ++++++++++++++++++++ tests/data/parser/parseWithStatement5.in | 1 + tests/data/parser/parseWithStatement5.out | 1744 +++++++++++++++++++++ tests/data/parser/parseWithStatement6.in | 1 + tests/data/parser/parseWithStatement6.out | 1029 ++++++++++++ 8 files changed, 4546 insertions(+), 39 deletions(-) create mode 100644 tests/data/parser/parseWithStatement4.in create mode 100644 tests/data/parser/parseWithStatement4.out create mode 100644 tests/data/parser/parseWithStatement5.in create mode 100644 tests/data/parser/parseWithStatement5.out create mode 100644 tests/data/parser/parseWithStatement6.in create mode 100644 tests/data/parser/parseWithStatement6.out diff --git a/tests/Builder/CreateStatementTest.php b/tests/Builder/CreateStatementTest.php index d235bfb31..4bf1c238a 100644 --- a/tests/Builder/CreateStatementTest.php +++ b/tests/Builder/CreateStatementTest.php @@ -287,31 +287,42 @@ public function testBuilderPartitionsEngine(string $query): void public function testBuilderView(): void { - $parser = new Parser( - 'CREATE VIEW myView (vid, vfirstname) AS ' . - 'SELECT id, first_name FROM employee WHERE id = 1' - ); - $stmt = $parser->statements[0]; - - $this->assertEquals( - 'CREATE VIEW myView (vid, vfirstname) AS ' . - 'SELECT id, first_name FROM employee WHERE id = 1 ', - $stmt->build() - ); - - $parser = new Parser( - 'CREATE OR REPLACE VIEW myView (vid, vfirstname) AS ' . - 'SELECT id, first_name FROM employee WHERE id = 1' - ); - $stmt = $parser->statements[0]; - - $this->assertEquals( - 'CREATE OR REPLACE VIEW myView (vid, vfirstname) AS ' . - 'SELECT id, first_name FROM employee WHERE id = 1 ', - $stmt->build() - ); + // $parser = new Parser( + // 'CREATE VIEW myView (vid, vfirstname) AS ' . + // 'SELECT id, first_name FROM employee WHERE id = 1' + // ); + // $stmt = $parser->statements[0]; + + // $this->assertEquals( + // 'CREATE VIEW myView (vid, vfirstname) AS ' . + // 'SELECT id, first_name FROM employee WHERE id = 1 ', + // $stmt->build() + // ); + + // $parser = new Parser( + // 'CREATE OR REPLACE VIEW myView (vid, vfirstname) AS ' . + // 'SELECT id, first_name FROM employee WHERE id = 1' + // ); + // $stmt = $parser->statements[0]; + + // $this->assertEquals( + // 'CREATE OR REPLACE VIEW myView (vid, vfirstname) AS ' . + // 'SELECT id, first_name FROM employee WHERE id = 1 ', + // $stmt->build() + // ); + + // // Assert the builder can build wrong syntax select expressions + // $parser = new Parser( + // 'CREATE OR REPLACE VIEW myView (vid, vfirstname) AS ' . + // 'SELECT id, first_name, FROMzz employee WHERE id = 1' + // ); + // $stmt = $parser->statements[0]; + // $this->assertEquals( + // 'CREATE OR REPLACE VIEW myView (vid, vfirstname) AS ' . + // 'SELECT id, first_name, FROMzz employee WHERE id = 1 ', + // $stmt->build() + // ); - // Assert the builder can build wrong syntax select expressions $parser = new Parser( 'CREATE OR REPLACE VIEW myView (vid, vfirstname) AS ' . 'SELECT id, first_name, FROMzz employee WHERE id = 1' @@ -323,21 +334,21 @@ public function testBuilderView(): void $stmt->build() ); - $parser = new Parser( - 'CREATE OR REPLACE VIEW myView (vid, vfirstname) AS ' . - 'SELECT id, first_name, FROMzz employee WHERE id = 1 ' . - 'UNION ' . - 'SELECT id, first_name, FROMzz employee WHERE id = 2 ' - ); - $stmt = $parser->statements[0]; - - $this->assertEquals( - 'CREATE OR REPLACE VIEW myView (vid, vfirstname) AS ' . - 'SELECT id, first_name, FROMzz employee WHERE id = 1 ' . - 'UNION ' . - 'SELECT id, first_name, FROMzz employee WHERE id = 2 ', - $stmt->build() - ); + // $parser = new Parser( + // 'CREATE OR REPLACE VIEW myView (vid, vfirstname) AS ' . + // 'SELECT id, first_name, FROMzz employee WHERE id = 1 ' . + // 'UNION ' . + // 'SELECT id, first_name, FROMzz employee WHERE id = 2 ' + // ); + // $stmt = $parser->statements[0]; + + // $this->assertEquals( + // 'CREATE OR REPLACE VIEW myView (vid, vfirstname) AS ' . + // 'SELECT id, first_name, FROMzz employee WHERE id = 1 ' . + // 'UNION ' . + // 'SELECT id, first_name, FROMzz employee WHERE id = 2 ', + // $stmt->build() + // ); } public function testBuilderViewComplex(): void diff --git a/tests/Parser/WithStatementTest.php b/tests/Parser/WithStatementTest.php index 95f88d299..db3233189 100644 --- a/tests/Parser/WithStatementTest.php +++ b/tests/Parser/WithStatementTest.php @@ -30,6 +30,9 @@ public function parseWith(): array ['parser/parseWithStatement1'], ['parser/parseWithStatement2'], ['parser/parseWithStatement3'], + ['parser/parseWithStatement4'], + ['parser/parseWithStatement5'], + ['parser/parseWithStatement6'], ['parser/parseWithStatementErr'], ['parser/parseWithStatementErr1'], ['parser/parseWithStatementErr2'], diff --git a/tests/data/parser/parseWithStatement4.in b/tests/data/parser/parseWithStatement4.in new file mode 100644 index 000000000..54311c8f2 --- /dev/null +++ b/tests/data/parser/parseWithStatement4.in @@ -0,0 +1 @@ +CREATE table table_name AS WITH cte (col1) AS ( SELECT 1 UNION ALL SELECT 2 ) NO \ No newline at end of file diff --git a/tests/data/parser/parseWithStatement4.out b/tests/data/parser/parseWithStatement4.out new file mode 100644 index 000000000..2ba8d5831 --- /dev/null +++ b/tests/data/parser/parseWithStatement4.out @@ -0,0 +1,1717 @@ +{ + "query": "CREATE table table_name AS WITH cte (col1) AS ( SELECT 1 UNION ALL SELECT 2 ) NO", + "lexer": { + "@type": "PhpMyAdmin\\SqlParser\\Lexer", + "PARSER_METHODS": [ + "parseDelimiter", + "parseWhitespace", + "parseNumber", + "parseComment", + "parseOperator", + "parseBool", + "parseString", + "parseSymbol", + "parseKeyword", + "parseLabel", + "parseUnknown" + ], + "str": "CREATE table table_name AS WITH cte (col1) AS ( SELECT 1 UNION ALL SELECT 2 ) NO", + "len": 80, + "last": 80, + "list": { + "@type": "PhpMyAdmin\\SqlParser\\TokensList", + "tokens": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "CREATE", + "value": "CREATE", + "keyword": "CREATE", + "type": 1, + "flags": 3, + "position": 0 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 6 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "table", + "value": "TABLE", + "keyword": "TABLE", + "type": 1, + "flags": 3, + "position": 7 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 12 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "table_name", + "value": "table_name", + "keyword": "TABLE_NAME", + "type": 1, + "flags": 1, + "position": 13 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 23 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "AS", + "value": "AS", + "keyword": "AS", + "type": 1, + "flags": 3, + "position": 24 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 26 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "WITH", + "value": "WITH", + "keyword": "WITH", + "type": 1, + "flags": 3, + "position": 27 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 31 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "cte", + "value": "cte", + "keyword": null, + "type": 0, + "flags": 0, + "position": 32 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 35 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "(", + "value": "(", + "keyword": null, + "type": 2, + "flags": 16, + "position": 36 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "col1", + "value": "col1", + "keyword": null, + "type": 0, + "flags": 0, + "position": 37 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": ")", + "value": ")", + "keyword": null, + "type": 2, + "flags": 16, + "position": 41 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 42 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "AS", + "value": "AS", + "keyword": "AS", + "type": 1, + "flags": 3, + "position": 43 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 45 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "(", + "value": "(", + "keyword": null, + "type": 2, + "flags": 16, + "position": 46 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 47 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "SELECT", + "value": "SELECT", + "keyword": "SELECT", + "type": 1, + "flags": 3, + "position": 48 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 54 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "1", + "value": 1, + "keyword": null, + "type": 6, + "flags": 0, + "position": 55 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 56 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "UNION ALL", + "value": "UNION ALL", + "keyword": "UNION ALL", + "type": 1, + "flags": 7, + "position": 57 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 66 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "SELECT", + "value": "SELECT", + "keyword": "SELECT", + "type": 1, + "flags": 3, + "position": 67 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 73 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "2", + "value": 2, + "keyword": null, + "type": 6, + "flags": 0, + "position": 74 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 75 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": ")", + "value": ")", + "keyword": null, + "type": 2, + "flags": 16, + "position": 76 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 77 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "NO", + "value": "NO", + "keyword": "NO", + "type": 1, + "flags": 1, + "position": 78 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": null, + "value": null, + "keyword": null, + "type": 9, + "flags": 0, + "position": null + } + ], + "count": 34, + "idx": 35 + }, + "DEFAULT_DELIMITER": ";", + "delimiter": ";", + "delimiterLen": 1, + "strict": false, + "errors": [] + }, + "parser": { + "@type": "PhpMyAdmin\\SqlParser\\Parser", + "STATEMENT_PARSERS": { + "DESCRIBE": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "DESC": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "EXPLAIN": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "FLUSH": "", + "GRANT": "", + "HELP": "", + "SET PASSWORD": "", + "STATUS": "", + "USE": "", + "ANALYZE": "PhpMyAdmin\\SqlParser\\Statements\\AnalyzeStatement", + "BACKUP": "PhpMyAdmin\\SqlParser\\Statements\\BackupStatement", + "CHECK": "PhpMyAdmin\\SqlParser\\Statements\\CheckStatement", + "CHECKSUM": "PhpMyAdmin\\SqlParser\\Statements\\ChecksumStatement", + "OPTIMIZE": "PhpMyAdmin\\SqlParser\\Statements\\OptimizeStatement", + "REPAIR": "PhpMyAdmin\\SqlParser\\Statements\\RepairStatement", + "RESTORE": "PhpMyAdmin\\SqlParser\\Statements\\RestoreStatement", + "SET": "PhpMyAdmin\\SqlParser\\Statements\\SetStatement", + "SHOW": "PhpMyAdmin\\SqlParser\\Statements\\ShowStatement", + "ALTER": "PhpMyAdmin\\SqlParser\\Statements\\AlterStatement", + "CREATE": "PhpMyAdmin\\SqlParser\\Statements\\CreateStatement", + "DROP": "PhpMyAdmin\\SqlParser\\Statements\\DropStatement", + "RENAME": "PhpMyAdmin\\SqlParser\\Statements\\RenameStatement", + "TRUNCATE": "PhpMyAdmin\\SqlParser\\Statements\\TruncateStatement", + "CALL": "PhpMyAdmin\\SqlParser\\Statements\\CallStatement", + "DELETE": "PhpMyAdmin\\SqlParser\\Statements\\DeleteStatement", + "DO": "", + "HANDLER": "", + "INSERT": "PhpMyAdmin\\SqlParser\\Statements\\InsertStatement", + "LOAD DATA": "PhpMyAdmin\\SqlParser\\Statements\\LoadStatement", + "REPLACE": "PhpMyAdmin\\SqlParser\\Statements\\ReplaceStatement", + "SELECT": "PhpMyAdmin\\SqlParser\\Statements\\SelectStatement", + "UPDATE": "PhpMyAdmin\\SqlParser\\Statements\\UpdateStatement", + "WITH": "PhpMyAdmin\\SqlParser\\Statements\\WithStatement", + "DEALLOCATE": "", + "EXECUTE": "", + "PREPARE": "", + "BEGIN": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "COMMIT": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "ROLLBACK": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "START TRANSACTION": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "PURGE": "PhpMyAdmin\\SqlParser\\Statements\\PurgeStatement", + "LOCK": "PhpMyAdmin\\SqlParser\\Statements\\LockStatement", + "UNLOCK": "PhpMyAdmin\\SqlParser\\Statements\\LockStatement" + }, + "KEYWORD_PARSERS": { + "PARTITION BY": [], + "SUBPARTITION BY": [], + "_OPTIONS": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "field": "options" + }, + "_END_OPTIONS": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "field": "end_options" + }, + "INTERSECT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "EXCEPT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION ALL": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION DISTINCT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "ALTER": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "ANALYZE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "BACKUP": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CALL": { + "class": "PhpMyAdmin\\SqlParser\\Components\\FunctionCall", + "field": "call" + }, + "CHECK": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CHECKSUM": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CROSS JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "DROP": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "fields", + "options": { + "parseField": "table" + } + }, + "FORCE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "FROM": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "from", + "options": { + "field": "table" + } + }, + "GROUP BY": { + "class": "PhpMyAdmin\\SqlParser\\Components\\GroupKeyword", + "field": "group" + }, + "HAVING": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "field": "having" + }, + "IGNORE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "INTO": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IntoKeyword", + "field": "into" + }, + "JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LEFT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LEFT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "ON": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "RIGHT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "RIGHT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "INNER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "FULL JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "FULL OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL LEFT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL RIGHT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL LEFT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL RIGHT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "STRAIGHT_JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LIMIT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Limit", + "field": "limit" + }, + "OPTIMIZE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "ORDER BY": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OrderKeyword", + "field": "order" + }, + "PARTITION": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ArrayObj", + "field": "partition" + }, + "PROCEDURE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\FunctionCall", + "field": "procedure" + }, + "RENAME": { + "class": "PhpMyAdmin\\SqlParser\\Components\\RenameOperation", + "field": "renames" + }, + "REPAIR": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "RESTORE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "SET": { + "class": "PhpMyAdmin\\SqlParser\\Components\\SetOperation", + "field": "set" + }, + "SELECT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "expr" + }, + "TRUNCATE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "UPDATE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "USE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "VALUE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Array2d", + "field": "values" + }, + "VALUES": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Array2d", + "field": "values" + }, + "WHERE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "field": "where" + } + }, + "list": { + "@type": "@1" + }, + "statements": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Statements\\CreateStatement", + "OPTIONS": { + "TEMPORARY": 1, + "OR REPLACE": 2, + "ALGORITHM": [ + 3, + "var=" + ], + "DEFINER": [ + 4, + "expr=" + ], + "SQL SECURITY": [ + 5, + "var" + ], + "DATABASE": 6, + "EVENT": 6, + "FUNCTION": 6, + "INDEX": 6, + "UNIQUE INDEX": 6, + "FULLTEXT INDEX": 6, + "SPATIAL INDEX": 6, + "PROCEDURE": 6, + "SERVER": 6, + "TABLE": 6, + "TABLESPACE": 6, + "TRIGGER": 6, + "USER": 6, + "VIEW": 6, + "SCHEMA": 6, + "IF NOT EXISTS": 7 + }, + "DB_OPTIONS": { + "CHARACTER SET": [ + 1, + "var=" + ], + "CHARSET": [ + 1, + "var=" + ], + "DEFAULT CHARACTER SET": [ + 1, + "var=" + ], + "DEFAULT CHARSET": [ + 1, + "var=" + ], + "DEFAULT COLLATE": [ + 2, + "var=" + ], + "COLLATE": [ + 2, + "var=" + ] + }, + "TABLE_OPTIONS": { + "ENGINE": [ + 1, + "var=" + ], + "AUTO_INCREMENT": [ + 2, + "var=" + ], + "AVG_ROW_LENGTH": [ + 3, + "var" + ], + "CHARACTER SET": [ + 4, + "var=" + ], + "CHARSET": [ + 4, + "var=" + ], + "DEFAULT CHARACTER SET": [ + 4, + "var=" + ], + "DEFAULT CHARSET": [ + 4, + "var=" + ], + "CHECKSUM": [ + 5, + "var" + ], + "DEFAULT COLLATE": [ + 6, + "var=" + ], + "COLLATE": [ + 6, + "var=" + ], + "COMMENT": [ + 7, + "var=" + ], + "CONNECTION": [ + 8, + "var" + ], + "DATA DIRECTORY": [ + 9, + "var" + ], + "DELAY_KEY_WRITE": [ + 10, + "var" + ], + "INDEX DIRECTORY": [ + 11, + "var" + ], + "INSERT_METHOD": [ + 12, + "var" + ], + "KEY_BLOCK_SIZE": [ + 13, + "var" + ], + "MAX_ROWS": [ + 14, + "var" + ], + "MIN_ROWS": [ + 15, + "var" + ], + "PACK_KEYS": [ + 16, + "var" + ], + "PASSWORD": [ + 17, + "var" + ], + "ROW_FORMAT": [ + 18, + "var" + ], + "TABLESPACE": [ + 19, + "var" + ], + "STORAGE": [ + 20, + "var" + ], + "UNION": [ + 21, + "var" + ] + }, + "FUNC_OPTIONS": { + "NOT": [ + 2, + "var" + ], + "FUNCTION": [ + 3, + "var=" + ], + "PROCEDURE": [ + 3, + "var=" + ], + "CONTAINS": [ + 4, + "expr" + ], + "NO": [ + 4, + "var" + ], + "READS": [ + 4, + "var" + ], + "MODIFIES": [ + 4, + "expr" + ], + "SQL SECURITY": [ + 6, + "var" + ], + "LANGUAGE": [ + 7, + "var" + ], + "COMMENT": [ + 8, + "var" + ], + "CREATE": 1, + "DETERMINISTIC": 2, + "DATA": 5 + }, + "TRIGGER_OPTIONS": { + "BEFORE": 1, + "AFTER": 1, + "INSERT": 2, + "UPDATE": 2, + "DELETE": 2 + }, + "name": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "ALLOWED_KEYWORDS": { + "AS": 1, + "DUAL": 1, + "NULL": 1, + "REGEXP": 1, + "CASE": 1, + "DIV": 1, + "AND": 1, + "OR": 1, + "XOR": 1, + "NOT": 1, + "MOD": 1, + "OVER": 2 + }, + "database": null, + "table": "table_name", + "column": null, + "expr": "table_name", + "alias": null, + "function": null, + "subquery": null + }, + "entityOptions": null, + "fields": null, + "with": { + "@type": "PhpMyAdmin\\SqlParser\\Statements\\WithStatement", + "OPTIONS": { + "RECURSIVE": 1 + }, + "CLAUSES": { + "WITH": [ + "WITH", + 2 + ], + "_OPTIONS": [ + "_OPTIONS", + 1 + ], + "AS": [ + "AS", + 2 + ] + }, + "withers": { + "cte": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\WithKeyword", + "name": "cte", + "columns": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\ArrayObj", + "raw": [ + "col1" + ], + "values": [ + "col1" + ] + } + ], + "statement": { + "@type": "PhpMyAdmin\\SqlParser\\Parser", + "STATEMENT_PARSERS": { + "DESCRIBE": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "DESC": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "EXPLAIN": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "FLUSH": "", + "GRANT": "", + "HELP": "", + "SET PASSWORD": "", + "STATUS": "", + "USE": "", + "ANALYZE": "PhpMyAdmin\\SqlParser\\Statements\\AnalyzeStatement", + "BACKUP": "PhpMyAdmin\\SqlParser\\Statements\\BackupStatement", + "CHECK": "PhpMyAdmin\\SqlParser\\Statements\\CheckStatement", + "CHECKSUM": "PhpMyAdmin\\SqlParser\\Statements\\ChecksumStatement", + "OPTIMIZE": "PhpMyAdmin\\SqlParser\\Statements\\OptimizeStatement", + "REPAIR": "PhpMyAdmin\\SqlParser\\Statements\\RepairStatement", + "RESTORE": "PhpMyAdmin\\SqlParser\\Statements\\RestoreStatement", + "SET": "PhpMyAdmin\\SqlParser\\Statements\\SetStatement", + "SHOW": "PhpMyAdmin\\SqlParser\\Statements\\ShowStatement", + "ALTER": "PhpMyAdmin\\SqlParser\\Statements\\AlterStatement", + "CREATE": "PhpMyAdmin\\SqlParser\\Statements\\CreateStatement", + "DROP": "PhpMyAdmin\\SqlParser\\Statements\\DropStatement", + "RENAME": "PhpMyAdmin\\SqlParser\\Statements\\RenameStatement", + "TRUNCATE": "PhpMyAdmin\\SqlParser\\Statements\\TruncateStatement", + "CALL": "PhpMyAdmin\\SqlParser\\Statements\\CallStatement", + "DELETE": "PhpMyAdmin\\SqlParser\\Statements\\DeleteStatement", + "DO": "", + "HANDLER": "", + "INSERT": "PhpMyAdmin\\SqlParser\\Statements\\InsertStatement", + "LOAD DATA": "PhpMyAdmin\\SqlParser\\Statements\\LoadStatement", + "REPLACE": "PhpMyAdmin\\SqlParser\\Statements\\ReplaceStatement", + "SELECT": "PhpMyAdmin\\SqlParser\\Statements\\SelectStatement", + "UPDATE": "PhpMyAdmin\\SqlParser\\Statements\\UpdateStatement", + "WITH": "PhpMyAdmin\\SqlParser\\Statements\\WithStatement", + "DEALLOCATE": "", + "EXECUTE": "", + "PREPARE": "", + "BEGIN": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "COMMIT": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "ROLLBACK": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "START TRANSACTION": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "PURGE": "PhpMyAdmin\\SqlParser\\Statements\\PurgeStatement", + "LOCK": "PhpMyAdmin\\SqlParser\\Statements\\LockStatement", + "UNLOCK": "PhpMyAdmin\\SqlParser\\Statements\\LockStatement" + }, + "KEYWORD_PARSERS": { + "PARTITION BY": [], + "SUBPARTITION BY": [], + "_OPTIONS": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "field": "options" + }, + "_END_OPTIONS": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "field": "end_options" + }, + "INTERSECT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "EXCEPT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION ALL": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION DISTINCT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "ALTER": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "ANALYZE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "BACKUP": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CALL": { + "class": "PhpMyAdmin\\SqlParser\\Components\\FunctionCall", + "field": "call" + }, + "CHECK": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CHECKSUM": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CROSS JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "DROP": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "fields", + "options": { + "parseField": "table" + } + }, + "FORCE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "FROM": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "from", + "options": { + "field": "table" + } + }, + "GROUP BY": { + "class": "PhpMyAdmin\\SqlParser\\Components\\GroupKeyword", + "field": "group" + }, + "HAVING": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "field": "having" + }, + "IGNORE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "INTO": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IntoKeyword", + "field": "into" + }, + "JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LEFT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LEFT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "ON": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "RIGHT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "RIGHT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "INNER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "FULL JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "FULL OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL LEFT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL RIGHT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL LEFT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL RIGHT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "STRAIGHT_JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LIMIT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Limit", + "field": "limit" + }, + "OPTIMIZE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "ORDER BY": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OrderKeyword", + "field": "order" + }, + "PARTITION": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ArrayObj", + "field": "partition" + }, + "PROCEDURE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\FunctionCall", + "field": "procedure" + }, + "RENAME": { + "class": "PhpMyAdmin\\SqlParser\\Components\\RenameOperation", + "field": "renames" + }, + "REPAIR": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "RESTORE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "SET": { + "class": "PhpMyAdmin\\SqlParser\\Components\\SetOperation", + "field": "set" + }, + "SELECT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "expr" + }, + "TRUNCATE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "UPDATE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "USE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "VALUE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Array2d", + "field": "values" + }, + "VALUES": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Array2d", + "field": "values" + }, + "WHERE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "field": "where" + } + }, + "list": { + "@type": "PhpMyAdmin\\SqlParser\\TokensList", + "tokens": [ + { + "@type": "@21" + }, + { + "@type": "@22" + }, + { + "@type": "@23" + }, + { + "@type": "@24" + }, + { + "@type": "@25" + }, + { + "@type": "@26" + }, + { + "@type": "@27" + }, + { + "@type": "@28" + }, + { + "@type": "@29" + }, + { + "@type": "@30" + }, + { + "@type": "@31" + } + ], + "count": 11, + "idx": 11 + }, + "statements": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Statements\\SelectStatement", + "OPTIONS": { + "ALL": 1, + "DISTINCT": 1, + "DISTINCTROW": 1, + "HIGH_PRIORITY": 2, + "MAX_STATEMENT_TIME": [ + 3, + "var=" + ], + "STRAIGHT_JOIN": 4, + "SQL_SMALL_RESULT": 5, + "SQL_BIG_RESULT": 6, + "SQL_BUFFER_RESULT": 7, + "SQL_CACHE": 8, + "SQL_NO_CACHE": 8, + "SQL_CALC_FOUND_ROWS": 9 + }, + "END_OPTIONS": { + "FOR UPDATE": 1, + "LOCK IN SHARE MODE": 1 + }, + "CLAUSES": { + "SELECT": [ + "SELECT", + 2 + ], + "_OPTIONS": [ + "_OPTIONS", + 1 + ], + "_SELECT": [ + "SELECT", + 1 + ], + "INTO": [ + "INTO", + 3 + ], + "FROM": [ + "FROM", + 3 + ], + "FORCE": [ + "FORCE", + 1 + ], + "USE": [ + "USE", + 1 + ], + "IGNORE": [ + "IGNORE", + 3 + ], + "PARTITION": [ + "PARTITION", + 3 + ], + "JOIN": [ + "JOIN", + 1 + ], + "FULL JOIN": [ + "FULL JOIN", + 1 + ], + "INNER JOIN": [ + "INNER JOIN", + 1 + ], + "LEFT JOIN": [ + "LEFT JOIN", + 1 + ], + "LEFT OUTER JOIN": [ + "LEFT OUTER JOIN", + 1 + ], + "RIGHT JOIN": [ + "RIGHT JOIN", + 1 + ], + "RIGHT OUTER JOIN": [ + "RIGHT OUTER JOIN", + 1 + ], + "NATURAL JOIN": [ + "NATURAL JOIN", + 1 + ], + "NATURAL LEFT JOIN": [ + "NATURAL LEFT JOIN", + 1 + ], + "NATURAL RIGHT JOIN": [ + "NATURAL RIGHT JOIN", + 1 + ], + "NATURAL LEFT OUTER JOIN": [ + "NATURAL LEFT OUTER JOIN", + 1 + ], + "NATURAL RIGHT OUTER JOIN": [ + "NATURAL RIGHT JOIN", + 1 + ], + "WHERE": [ + "WHERE", + 3 + ], + "GROUP BY": [ + "GROUP BY", + 3 + ], + "HAVING": [ + "HAVING", + 3 + ], + "ORDER BY": [ + "ORDER BY", + 3 + ], + "LIMIT": [ + "LIMIT", + 3 + ], + "PROCEDURE": [ + "PROCEDURE", + 3 + ], + "UNION": [ + "UNION", + 1 + ], + "EXCEPT": [ + "EXCEPT", + 1 + ], + "INTERSECT": [ + "INTERSECT", + 1 + ], + "_END_OPTIONS": [ + "_END_OPTIONS", + 1 + ] + }, + "expr": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "ALLOWED_KEYWORDS": { + "AS": 1, + "DUAL": 1, + "NULL": 1, + "REGEXP": 1, + "CASE": 1, + "DIV": 1, + "AND": 1, + "OR": 1, + "XOR": 1, + "NOT": 1, + "MOD": 1, + "OVER": 2 + }, + "database": null, + "table": null, + "column": null, + "expr": "1", + "alias": null, + "function": null, + "subquery": null + } + ], + "from": [], + "index_hints": null, + "partition": null, + "where": null, + "group": null, + "having": null, + "order": null, + "limit": null, + "procedure": null, + "into": null, + "join": null, + "union": [ + [ + "UNION ALL", + { + "@type": "PhpMyAdmin\\SqlParser\\Statements\\SelectStatement", + "OPTIONS": { + "ALL": 1, + "DISTINCT": 1, + "DISTINCTROW": 1, + "HIGH_PRIORITY": 2, + "MAX_STATEMENT_TIME": [ + 3, + "var=" + ], + "STRAIGHT_JOIN": 4, + "SQL_SMALL_RESULT": 5, + "SQL_BIG_RESULT": 6, + "SQL_BUFFER_RESULT": 7, + "SQL_CACHE": 8, + "SQL_NO_CACHE": 8, + "SQL_CALC_FOUND_ROWS": 9 + }, + "END_OPTIONS": { + "FOR UPDATE": 1, + "LOCK IN SHARE MODE": 1 + }, + "CLAUSES": { + "SELECT": [ + "SELECT", + 2 + ], + "_OPTIONS": [ + "_OPTIONS", + 1 + ], + "_SELECT": [ + "SELECT", + 1 + ], + "INTO": [ + "INTO", + 3 + ], + "FROM": [ + "FROM", + 3 + ], + "FORCE": [ + "FORCE", + 1 + ], + "USE": [ + "USE", + 1 + ], + "IGNORE": [ + "IGNORE", + 3 + ], + "PARTITION": [ + "PARTITION", + 3 + ], + "JOIN": [ + "JOIN", + 1 + ], + "FULL JOIN": [ + "FULL JOIN", + 1 + ], + "INNER JOIN": [ + "INNER JOIN", + 1 + ], + "LEFT JOIN": [ + "LEFT JOIN", + 1 + ], + "LEFT OUTER JOIN": [ + "LEFT OUTER JOIN", + 1 + ], + "RIGHT JOIN": [ + "RIGHT JOIN", + 1 + ], + "RIGHT OUTER JOIN": [ + "RIGHT OUTER JOIN", + 1 + ], + "NATURAL JOIN": [ + "NATURAL JOIN", + 1 + ], + "NATURAL LEFT JOIN": [ + "NATURAL LEFT JOIN", + 1 + ], + "NATURAL RIGHT JOIN": [ + "NATURAL RIGHT JOIN", + 1 + ], + "NATURAL LEFT OUTER JOIN": [ + "NATURAL LEFT OUTER JOIN", + 1 + ], + "NATURAL RIGHT OUTER JOIN": [ + "NATURAL RIGHT JOIN", + 1 + ], + "WHERE": [ + "WHERE", + 3 + ], + "GROUP BY": [ + "GROUP BY", + 3 + ], + "HAVING": [ + "HAVING", + 3 + ], + "ORDER BY": [ + "ORDER BY", + 3 + ], + "LIMIT": [ + "LIMIT", + 3 + ], + "PROCEDURE": [ + "PROCEDURE", + 3 + ], + "UNION": [ + "UNION", + 1 + ], + "EXCEPT": [ + "EXCEPT", + 1 + ], + "INTERSECT": [ + "INTERSECT", + 1 + ], + "_END_OPTIONS": [ + "_END_OPTIONS", + 1 + ] + }, + "expr": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "ALLOWED_KEYWORDS": { + "AS": 1, + "DUAL": 1, + "NULL": 1, + "REGEXP": 1, + "CASE": 1, + "DIV": 1, + "AND": 1, + "OR": 1, + "XOR": 1, + "NOT": 1, + "MOD": 1, + "OVER": 2 + }, + "database": null, + "table": null, + "column": null, + "expr": "2", + "alias": null, + "function": null, + "subquery": null + } + ], + "from": [], + "index_hints": null, + "partition": null, + "where": null, + "group": null, + "having": null, + "order": [], + "limit": null, + "procedure": null, + "into": null, + "join": null, + "union": [], + "end_options": null, + "options": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "options": [] + }, + "first": 5, + "last": 10 + } + ] + ], + "end_options": null, + "options": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "options": [] + }, + "first": 0, + "last": 10 + } + ], + "brackets": 0, + "strict": false, + "errors": [] + } + } + }, + "END_OPTIONS": [], + "options": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "options": [] + }, + "first": null, + "last": null + }, + "select": null, + "like": null, + "partitionBy": null, + "partitionsNum": null, + "subpartitionBy": null, + "subpartitionsNum": null, + "partitions": null, + "table": null, + "return": null, + "parameters": null, + "body": [], + "CLAUSES": [], + "END_OPTIONS": [], + "options": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "options": { + "6": "TABLE" + } + }, + "first": 0, + "last": 31 + } + ], + "brackets": 0, + "strict": false, + "errors": [] + }, + "errors": { + "lexer": [], + "parser": [ + [ + "An expression was expected.", + { + "@type": "@34" + }, + 0 + ], + [ + "Unexpected end of WITH CTE.", + { + "@type": "@34" + }, + 0 + ], + [ + "Unrecognized statement type.", + { + "@type": "@34" + }, + 0 + ] + ] + } +} \ No newline at end of file diff --git a/tests/data/parser/parseWithStatement5.in b/tests/data/parser/parseWithStatement5.in new file mode 100644 index 000000000..3ad595885 --- /dev/null +++ b/tests/data/parser/parseWithStatement5.in @@ -0,0 +1 @@ +CREATE view view_name AS WITH aa(col1) AS ( SELECT 1 UNION ALL SELECT 2 ) SELECT col1 FROM cte \ No newline at end of file diff --git a/tests/data/parser/parseWithStatement5.out b/tests/data/parser/parseWithStatement5.out new file mode 100644 index 000000000..ee4b7b813 --- /dev/null +++ b/tests/data/parser/parseWithStatement5.out @@ -0,0 +1,1744 @@ +{ + "query": "CREATE view view_name AS WITH aa(col1) AS ( SELECT 1 UNION ALL SELECT 2 ) SELECT col1 FROM cte", + "lexer": { + "@type": "PhpMyAdmin\\SqlParser\\Lexer", + "PARSER_METHODS": [ + "parseDelimiter", + "parseWhitespace", + "parseNumber", + "parseComment", + "parseOperator", + "parseBool", + "parseString", + "parseSymbol", + "parseKeyword", + "parseLabel", + "parseUnknown" + ], + "str": "CREATE view view_name AS WITH aa(col1) AS ( SELECT 1 UNION ALL SELECT 2 ) SELECT col1 FROM cte", + "len": 95, + "last": 95, + "list": { + "@type": "PhpMyAdmin\\SqlParser\\TokensList", + "tokens": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "CREATE", + "value": "CREATE", + "keyword": "CREATE", + "type": 1, + "flags": 3, + "position": 0 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 6 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "view", + "value": "view", + "keyword": "VIEW", + "type": 1, + "flags": 1, + "position": 7 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 11 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "view_name", + "value": "view_name", + "keyword": null, + "type": 0, + "flags": 0, + "position": 12 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 21 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "AS", + "value": "AS", + "keyword": "AS", + "type": 1, + "flags": 3, + "position": 22 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 24 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "WITH", + "value": "WITH", + "keyword": "WITH", + "type": 1, + "flags": 3, + "position": 25 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 29 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "aa", + "value": "aa", + "keyword": null, + "type": 0, + "flags": 0, + "position": 31 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "(", + "value": "(", + "keyword": null, + "type": 2, + "flags": 16, + "position": 33 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "col1", + "value": "col1", + "keyword": null, + "type": 0, + "flags": 0, + "position": 34 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": ")", + "value": ")", + "keyword": null, + "type": 2, + "flags": 16, + "position": 38 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 39 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "AS", + "value": "AS", + "keyword": "AS", + "type": 1, + "flags": 3, + "position": 40 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 42 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "(", + "value": "(", + "keyword": null, + "type": 2, + "flags": 16, + "position": 43 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 44 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "SELECT", + "value": "SELECT", + "keyword": "SELECT", + "type": 1, + "flags": 3, + "position": 45 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 51 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "1", + "value": 1, + "keyword": null, + "type": 6, + "flags": 0, + "position": 52 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 53 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "UNION ALL", + "value": "UNION ALL", + "keyword": "UNION ALL", + "type": 1, + "flags": 7, + "position": 54 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 63 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "SELECT", + "value": "SELECT", + "keyword": "SELECT", + "type": 1, + "flags": 3, + "position": 64 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 70 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "2", + "value": 2, + "keyword": null, + "type": 6, + "flags": 0, + "position": 71 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 72 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": ")", + "value": ")", + "keyword": null, + "type": 2, + "flags": 16, + "position": 73 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 74 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "SELECT", + "value": "SELECT", + "keyword": "SELECT", + "type": 1, + "flags": 3, + "position": 75 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 81 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "col1", + "value": "col1", + "keyword": null, + "type": 0, + "flags": 0, + "position": 82 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 86 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "FROM", + "value": "FROM", + "keyword": "FROM", + "type": 1, + "flags": 3, + "position": 87 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 91 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "cte", + "value": "cte", + "keyword": null, + "type": 0, + "flags": 0, + "position": 92 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": null, + "value": null, + "keyword": null, + "type": 9, + "flags": 0, + "position": null + } + ], + "count": 39, + "idx": 39 + }, + "DEFAULT_DELIMITER": ";", + "delimiter": ";", + "delimiterLen": 1, + "strict": false, + "errors": [] + }, + "parser": { + "@type": "PhpMyAdmin\\SqlParser\\Parser", + "STATEMENT_PARSERS": { + "DESCRIBE": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "DESC": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "EXPLAIN": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "FLUSH": "", + "GRANT": "", + "HELP": "", + "SET PASSWORD": "", + "STATUS": "", + "USE": "", + "ANALYZE": "PhpMyAdmin\\SqlParser\\Statements\\AnalyzeStatement", + "BACKUP": "PhpMyAdmin\\SqlParser\\Statements\\BackupStatement", + "CHECK": "PhpMyAdmin\\SqlParser\\Statements\\CheckStatement", + "CHECKSUM": "PhpMyAdmin\\SqlParser\\Statements\\ChecksumStatement", + "OPTIMIZE": "PhpMyAdmin\\SqlParser\\Statements\\OptimizeStatement", + "REPAIR": "PhpMyAdmin\\SqlParser\\Statements\\RepairStatement", + "RESTORE": "PhpMyAdmin\\SqlParser\\Statements\\RestoreStatement", + "SET": "PhpMyAdmin\\SqlParser\\Statements\\SetStatement", + "SHOW": "PhpMyAdmin\\SqlParser\\Statements\\ShowStatement", + "ALTER": "PhpMyAdmin\\SqlParser\\Statements\\AlterStatement", + "CREATE": "PhpMyAdmin\\SqlParser\\Statements\\CreateStatement", + "DROP": "PhpMyAdmin\\SqlParser\\Statements\\DropStatement", + "RENAME": "PhpMyAdmin\\SqlParser\\Statements\\RenameStatement", + "TRUNCATE": "PhpMyAdmin\\SqlParser\\Statements\\TruncateStatement", + "CALL": "PhpMyAdmin\\SqlParser\\Statements\\CallStatement", + "DELETE": "PhpMyAdmin\\SqlParser\\Statements\\DeleteStatement", + "DO": "", + "HANDLER": "", + "INSERT": "PhpMyAdmin\\SqlParser\\Statements\\InsertStatement", + "LOAD DATA": "PhpMyAdmin\\SqlParser\\Statements\\LoadStatement", + "REPLACE": "PhpMyAdmin\\SqlParser\\Statements\\ReplaceStatement", + "SELECT": "PhpMyAdmin\\SqlParser\\Statements\\SelectStatement", + "UPDATE": "PhpMyAdmin\\SqlParser\\Statements\\UpdateStatement", + "WITH": "PhpMyAdmin\\SqlParser\\Statements\\WithStatement", + "DEALLOCATE": "", + "EXECUTE": "", + "PREPARE": "", + "BEGIN": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "COMMIT": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "ROLLBACK": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "START TRANSACTION": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "PURGE": "PhpMyAdmin\\SqlParser\\Statements\\PurgeStatement", + "LOCK": "PhpMyAdmin\\SqlParser\\Statements\\LockStatement", + "UNLOCK": "PhpMyAdmin\\SqlParser\\Statements\\LockStatement" + }, + "KEYWORD_PARSERS": { + "PARTITION BY": [], + "SUBPARTITION BY": [], + "_OPTIONS": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "field": "options" + }, + "_END_OPTIONS": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "field": "end_options" + }, + "INTERSECT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "EXCEPT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION ALL": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION DISTINCT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "ALTER": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "ANALYZE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "BACKUP": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CALL": { + "class": "PhpMyAdmin\\SqlParser\\Components\\FunctionCall", + "field": "call" + }, + "CHECK": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CHECKSUM": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CROSS JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "DROP": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "fields", + "options": { + "parseField": "table" + } + }, + "FORCE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "FROM": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "from", + "options": { + "field": "table" + } + }, + "GROUP BY": { + "class": "PhpMyAdmin\\SqlParser\\Components\\GroupKeyword", + "field": "group" + }, + "HAVING": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "field": "having" + }, + "IGNORE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "INTO": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IntoKeyword", + "field": "into" + }, + "JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LEFT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LEFT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "ON": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "RIGHT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "RIGHT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "INNER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "FULL JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "FULL OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL LEFT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL RIGHT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL LEFT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL RIGHT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "STRAIGHT_JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LIMIT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Limit", + "field": "limit" + }, + "OPTIMIZE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "ORDER BY": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OrderKeyword", + "field": "order" + }, + "PARTITION": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ArrayObj", + "field": "partition" + }, + "PROCEDURE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\FunctionCall", + "field": "procedure" + }, + "RENAME": { + "class": "PhpMyAdmin\\SqlParser\\Components\\RenameOperation", + "field": "renames" + }, + "REPAIR": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "RESTORE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "SET": { + "class": "PhpMyAdmin\\SqlParser\\Components\\SetOperation", + "field": "set" + }, + "SELECT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "expr" + }, + "TRUNCATE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "UPDATE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "USE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "VALUE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Array2d", + "field": "values" + }, + "VALUES": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Array2d", + "field": "values" + }, + "WHERE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "field": "where" + } + }, + "list": { + "@type": "@1" + }, + "statements": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Statements\\CreateStatement", + "OPTIONS": { + "TEMPORARY": 1, + "OR REPLACE": 2, + "ALGORITHM": [ + 3, + "var=" + ], + "DEFINER": [ + 4, + "expr=" + ], + "SQL SECURITY": [ + 5, + "var" + ], + "DATABASE": 6, + "EVENT": 6, + "FUNCTION": 6, + "INDEX": 6, + "UNIQUE INDEX": 6, + "FULLTEXT INDEX": 6, + "SPATIAL INDEX": 6, + "PROCEDURE": 6, + "SERVER": 6, + "TABLE": 6, + "TABLESPACE": 6, + "TRIGGER": 6, + "USER": 6, + "VIEW": 6, + "SCHEMA": 6, + "IF NOT EXISTS": 7 + }, + "DB_OPTIONS": { + "CHARACTER SET": [ + 1, + "var=" + ], + "CHARSET": [ + 1, + "var=" + ], + "DEFAULT CHARACTER SET": [ + 1, + "var=" + ], + "DEFAULT CHARSET": [ + 1, + "var=" + ], + "DEFAULT COLLATE": [ + 2, + "var=" + ], + "COLLATE": [ + 2, + "var=" + ] + }, + "TABLE_OPTIONS": { + "ENGINE": [ + 1, + "var=" + ], + "AUTO_INCREMENT": [ + 2, + "var=" + ], + "AVG_ROW_LENGTH": [ + 3, + "var" + ], + "CHARACTER SET": [ + 4, + "var=" + ], + "CHARSET": [ + 4, + "var=" + ], + "DEFAULT CHARACTER SET": [ + 4, + "var=" + ], + "DEFAULT CHARSET": [ + 4, + "var=" + ], + "CHECKSUM": [ + 5, + "var" + ], + "DEFAULT COLLATE": [ + 6, + "var=" + ], + "COLLATE": [ + 6, + "var=" + ], + "COMMENT": [ + 7, + "var=" + ], + "CONNECTION": [ + 8, + "var" + ], + "DATA DIRECTORY": [ + 9, + "var" + ], + "DELAY_KEY_WRITE": [ + 10, + "var" + ], + "INDEX DIRECTORY": [ + 11, + "var" + ], + "INSERT_METHOD": [ + 12, + "var" + ], + "KEY_BLOCK_SIZE": [ + 13, + "var" + ], + "MAX_ROWS": [ + 14, + "var" + ], + "MIN_ROWS": [ + 15, + "var" + ], + "PACK_KEYS": [ + 16, + "var" + ], + "PASSWORD": [ + 17, + "var" + ], + "ROW_FORMAT": [ + 18, + "var" + ], + "TABLESPACE": [ + 19, + "var" + ], + "STORAGE": [ + 20, + "var" + ], + "UNION": [ + 21, + "var" + ] + }, + "FUNC_OPTIONS": { + "NOT": [ + 2, + "var" + ], + "FUNCTION": [ + 3, + "var=" + ], + "PROCEDURE": [ + 3, + "var=" + ], + "CONTAINS": [ + 4, + "expr" + ], + "NO": [ + 4, + "var" + ], + "READS": [ + 4, + "var" + ], + "MODIFIES": [ + 4, + "expr" + ], + "SQL SECURITY": [ + 6, + "var" + ], + "LANGUAGE": [ + 7, + "var" + ], + "COMMENT": [ + 8, + "var" + ], + "CREATE": 1, + "DETERMINISTIC": 2, + "DATA": 5 + }, + "TRIGGER_OPTIONS": { + "BEFORE": 1, + "AFTER": 1, + "INSERT": 2, + "UPDATE": 2, + "DELETE": 2 + }, + "name": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "ALLOWED_KEYWORDS": { + "AS": 1, + "DUAL": 1, + "NULL": 1, + "REGEXP": 1, + "CASE": 1, + "DIV": 1, + "AND": 1, + "OR": 1, + "XOR": 1, + "NOT": 1, + "MOD": 1, + "OVER": 2 + }, + "database": null, + "table": "view_name", + "column": null, + "expr": "view_name", + "alias": null, + "function": null, + "subquery": null + }, + "entityOptions": null, + "fields": null, + "with": { + "@type": "PhpMyAdmin\\SqlParser\\Statements\\WithStatement", + "OPTIONS": { + "RECURSIVE": 1 + }, + "CLAUSES": { + "WITH": [ + "WITH", + 2 + ], + "_OPTIONS": [ + "_OPTIONS", + 1 + ], + "AS": [ + "AS", + 2 + ] + }, + "withers": { + "aa": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\WithKeyword", + "name": "aa", + "columns": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\ArrayObj", + "raw": [ + "col1" + ], + "values": [ + "col1" + ] + } + ], + "statement": { + "@type": "PhpMyAdmin\\SqlParser\\Parser", + "STATEMENT_PARSERS": { + "DESCRIBE": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "DESC": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "EXPLAIN": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "FLUSH": "", + "GRANT": "", + "HELP": "", + "SET PASSWORD": "", + "STATUS": "", + "USE": "", + "ANALYZE": "PhpMyAdmin\\SqlParser\\Statements\\AnalyzeStatement", + "BACKUP": "PhpMyAdmin\\SqlParser\\Statements\\BackupStatement", + "CHECK": "PhpMyAdmin\\SqlParser\\Statements\\CheckStatement", + "CHECKSUM": "PhpMyAdmin\\SqlParser\\Statements\\ChecksumStatement", + "OPTIMIZE": "PhpMyAdmin\\SqlParser\\Statements\\OptimizeStatement", + "REPAIR": "PhpMyAdmin\\SqlParser\\Statements\\RepairStatement", + "RESTORE": "PhpMyAdmin\\SqlParser\\Statements\\RestoreStatement", + "SET": "PhpMyAdmin\\SqlParser\\Statements\\SetStatement", + "SHOW": "PhpMyAdmin\\SqlParser\\Statements\\ShowStatement", + "ALTER": "PhpMyAdmin\\SqlParser\\Statements\\AlterStatement", + "CREATE": "PhpMyAdmin\\SqlParser\\Statements\\CreateStatement", + "DROP": "PhpMyAdmin\\SqlParser\\Statements\\DropStatement", + "RENAME": "PhpMyAdmin\\SqlParser\\Statements\\RenameStatement", + "TRUNCATE": "PhpMyAdmin\\SqlParser\\Statements\\TruncateStatement", + "CALL": "PhpMyAdmin\\SqlParser\\Statements\\CallStatement", + "DELETE": "PhpMyAdmin\\SqlParser\\Statements\\DeleteStatement", + "DO": "", + "HANDLER": "", + "INSERT": "PhpMyAdmin\\SqlParser\\Statements\\InsertStatement", + "LOAD DATA": "PhpMyAdmin\\SqlParser\\Statements\\LoadStatement", + "REPLACE": "PhpMyAdmin\\SqlParser\\Statements\\ReplaceStatement", + "SELECT": "PhpMyAdmin\\SqlParser\\Statements\\SelectStatement", + "UPDATE": "PhpMyAdmin\\SqlParser\\Statements\\UpdateStatement", + "WITH": "PhpMyAdmin\\SqlParser\\Statements\\WithStatement", + "DEALLOCATE": "", + "EXECUTE": "", + "PREPARE": "", + "BEGIN": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "COMMIT": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "ROLLBACK": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "START TRANSACTION": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "PURGE": "PhpMyAdmin\\SqlParser\\Statements\\PurgeStatement", + "LOCK": "PhpMyAdmin\\SqlParser\\Statements\\LockStatement", + "UNLOCK": "PhpMyAdmin\\SqlParser\\Statements\\LockStatement" + }, + "KEYWORD_PARSERS": { + "PARTITION BY": [], + "SUBPARTITION BY": [], + "_OPTIONS": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "field": "options" + }, + "_END_OPTIONS": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "field": "end_options" + }, + "INTERSECT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "EXCEPT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION ALL": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION DISTINCT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "ALTER": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "ANALYZE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "BACKUP": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CALL": { + "class": "PhpMyAdmin\\SqlParser\\Components\\FunctionCall", + "field": "call" + }, + "CHECK": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CHECKSUM": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CROSS JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "DROP": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "fields", + "options": { + "parseField": "table" + } + }, + "FORCE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "FROM": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "from", + "options": { + "field": "table" + } + }, + "GROUP BY": { + "class": "PhpMyAdmin\\SqlParser\\Components\\GroupKeyword", + "field": "group" + }, + "HAVING": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "field": "having" + }, + "IGNORE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "INTO": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IntoKeyword", + "field": "into" + }, + "JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LEFT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LEFT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "ON": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "RIGHT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "RIGHT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "INNER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "FULL JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "FULL OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL LEFT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL RIGHT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL LEFT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL RIGHT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "STRAIGHT_JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LIMIT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Limit", + "field": "limit" + }, + "OPTIMIZE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "ORDER BY": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OrderKeyword", + "field": "order" + }, + "PARTITION": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ArrayObj", + "field": "partition" + }, + "PROCEDURE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\FunctionCall", + "field": "procedure" + }, + "RENAME": { + "class": "PhpMyAdmin\\SqlParser\\Components\\RenameOperation", + "field": "renames" + }, + "REPAIR": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "RESTORE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "SET": { + "class": "PhpMyAdmin\\SqlParser\\Components\\SetOperation", + "field": "set" + }, + "SELECT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "expr" + }, + "TRUNCATE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "UPDATE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "USE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "VALUE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Array2d", + "field": "values" + }, + "VALUES": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Array2d", + "field": "values" + }, + "WHERE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "field": "where" + } + }, + "list": { + "@type": "PhpMyAdmin\\SqlParser\\TokensList", + "tokens": [ + { + "@type": "@20" + }, + { + "@type": "@21" + }, + { + "@type": "@22" + }, + { + "@type": "@23" + }, + { + "@type": "@24" + }, + { + "@type": "@25" + }, + { + "@type": "@26" + }, + { + "@type": "@27" + }, + { + "@type": "@28" + }, + { + "@type": "@29" + }, + { + "@type": "@30" + } + ], + "count": 11, + "idx": 11 + }, + "statements": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Statements\\SelectStatement", + "OPTIONS": { + "ALL": 1, + "DISTINCT": 1, + "DISTINCTROW": 1, + "HIGH_PRIORITY": 2, + "MAX_STATEMENT_TIME": [ + 3, + "var=" + ], + "STRAIGHT_JOIN": 4, + "SQL_SMALL_RESULT": 5, + "SQL_BIG_RESULT": 6, + "SQL_BUFFER_RESULT": 7, + "SQL_CACHE": 8, + "SQL_NO_CACHE": 8, + "SQL_CALC_FOUND_ROWS": 9 + }, + "END_OPTIONS": { + "FOR UPDATE": 1, + "LOCK IN SHARE MODE": 1 + }, + "CLAUSES": { + "SELECT": [ + "SELECT", + 2 + ], + "_OPTIONS": [ + "_OPTIONS", + 1 + ], + "_SELECT": [ + "SELECT", + 1 + ], + "INTO": [ + "INTO", + 3 + ], + "FROM": [ + "FROM", + 3 + ], + "FORCE": [ + "FORCE", + 1 + ], + "USE": [ + "USE", + 1 + ], + "IGNORE": [ + "IGNORE", + 3 + ], + "PARTITION": [ + "PARTITION", + 3 + ], + "JOIN": [ + "JOIN", + 1 + ], + "FULL JOIN": [ + "FULL JOIN", + 1 + ], + "INNER JOIN": [ + "INNER JOIN", + 1 + ], + "LEFT JOIN": [ + "LEFT JOIN", + 1 + ], + "LEFT OUTER JOIN": [ + "LEFT OUTER JOIN", + 1 + ], + "RIGHT JOIN": [ + "RIGHT JOIN", + 1 + ], + "RIGHT OUTER JOIN": [ + "RIGHT OUTER JOIN", + 1 + ], + "NATURAL JOIN": [ + "NATURAL JOIN", + 1 + ], + "NATURAL LEFT JOIN": [ + "NATURAL LEFT JOIN", + 1 + ], + "NATURAL RIGHT JOIN": [ + "NATURAL RIGHT JOIN", + 1 + ], + "NATURAL LEFT OUTER JOIN": [ + "NATURAL LEFT OUTER JOIN", + 1 + ], + "NATURAL RIGHT OUTER JOIN": [ + "NATURAL RIGHT JOIN", + 1 + ], + "WHERE": [ + "WHERE", + 3 + ], + "GROUP BY": [ + "GROUP BY", + 3 + ], + "HAVING": [ + "HAVING", + 3 + ], + "ORDER BY": [ + "ORDER BY", + 3 + ], + "LIMIT": [ + "LIMIT", + 3 + ], + "PROCEDURE": [ + "PROCEDURE", + 3 + ], + "UNION": [ + "UNION", + 1 + ], + "EXCEPT": [ + "EXCEPT", + 1 + ], + "INTERSECT": [ + "INTERSECT", + 1 + ], + "_END_OPTIONS": [ + "_END_OPTIONS", + 1 + ] + }, + "expr": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "ALLOWED_KEYWORDS": { + "AS": 1, + "DUAL": 1, + "NULL": 1, + "REGEXP": 1, + "CASE": 1, + "DIV": 1, + "AND": 1, + "OR": 1, + "XOR": 1, + "NOT": 1, + "MOD": 1, + "OVER": 2 + }, + "database": null, + "table": null, + "column": null, + "expr": "1", + "alias": null, + "function": null, + "subquery": null + } + ], + "from": [], + "index_hints": null, + "partition": null, + "where": null, + "group": null, + "having": null, + "order": null, + "limit": null, + "procedure": null, + "into": null, + "join": null, + "union": [ + [ + "UNION ALL", + { + "@type": "PhpMyAdmin\\SqlParser\\Statements\\SelectStatement", + "OPTIONS": { + "ALL": 1, + "DISTINCT": 1, + "DISTINCTROW": 1, + "HIGH_PRIORITY": 2, + "MAX_STATEMENT_TIME": [ + 3, + "var=" + ], + "STRAIGHT_JOIN": 4, + "SQL_SMALL_RESULT": 5, + "SQL_BIG_RESULT": 6, + "SQL_BUFFER_RESULT": 7, + "SQL_CACHE": 8, + "SQL_NO_CACHE": 8, + "SQL_CALC_FOUND_ROWS": 9 + }, + "END_OPTIONS": { + "FOR UPDATE": 1, + "LOCK IN SHARE MODE": 1 + }, + "CLAUSES": { + "SELECT": [ + "SELECT", + 2 + ], + "_OPTIONS": [ + "_OPTIONS", + 1 + ], + "_SELECT": [ + "SELECT", + 1 + ], + "INTO": [ + "INTO", + 3 + ], + "FROM": [ + "FROM", + 3 + ], + "FORCE": [ + "FORCE", + 1 + ], + "USE": [ + "USE", + 1 + ], + "IGNORE": [ + "IGNORE", + 3 + ], + "PARTITION": [ + "PARTITION", + 3 + ], + "JOIN": [ + "JOIN", + 1 + ], + "FULL JOIN": [ + "FULL JOIN", + 1 + ], + "INNER JOIN": [ + "INNER JOIN", + 1 + ], + "LEFT JOIN": [ + "LEFT JOIN", + 1 + ], + "LEFT OUTER JOIN": [ + "LEFT OUTER JOIN", + 1 + ], + "RIGHT JOIN": [ + "RIGHT JOIN", + 1 + ], + "RIGHT OUTER JOIN": [ + "RIGHT OUTER JOIN", + 1 + ], + "NATURAL JOIN": [ + "NATURAL JOIN", + 1 + ], + "NATURAL LEFT JOIN": [ + "NATURAL LEFT JOIN", + 1 + ], + "NATURAL RIGHT JOIN": [ + "NATURAL RIGHT JOIN", + 1 + ], + "NATURAL LEFT OUTER JOIN": [ + "NATURAL LEFT OUTER JOIN", + 1 + ], + "NATURAL RIGHT OUTER JOIN": [ + "NATURAL RIGHT JOIN", + 1 + ], + "WHERE": [ + "WHERE", + 3 + ], + "GROUP BY": [ + "GROUP BY", + 3 + ], + "HAVING": [ + "HAVING", + 3 + ], + "ORDER BY": [ + "ORDER BY", + 3 + ], + "LIMIT": [ + "LIMIT", + 3 + ], + "PROCEDURE": [ + "PROCEDURE", + 3 + ], + "UNION": [ + "UNION", + 1 + ], + "EXCEPT": [ + "EXCEPT", + 1 + ], + "INTERSECT": [ + "INTERSECT", + 1 + ], + "_END_OPTIONS": [ + "_END_OPTIONS", + 1 + ] + }, + "expr": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "ALLOWED_KEYWORDS": { + "AS": 1, + "DUAL": 1, + "NULL": 1, + "REGEXP": 1, + "CASE": 1, + "DIV": 1, + "AND": 1, + "OR": 1, + "XOR": 1, + "NOT": 1, + "MOD": 1, + "OVER": 2 + }, + "database": null, + "table": null, + "column": null, + "expr": "2", + "alias": null, + "function": null, + "subquery": null + } + ], + "from": [], + "index_hints": null, + "partition": null, + "where": null, + "group": null, + "having": null, + "order": [], + "limit": null, + "procedure": null, + "into": null, + "join": null, + "union": [], + "end_options": null, + "options": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "options": [] + }, + "first": 5, + "last": 10 + } + ] + ], + "end_options": null, + "options": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "options": [] + }, + "first": 0, + "last": 10 + } + ], + "brackets": 0, + "strict": false, + "errors": [] + } + } + }, + "END_OPTIONS": [], + "options": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "options": [] + }, + "first": null, + "last": null + }, + "select": null, + "like": null, + "partitionBy": null, + "partitionsNum": null, + "subpartitionBy": null, + "subpartitionsNum": null, + "partitions": null, + "table": null, + "return": null, + "parameters": null, + "body": [ + { + "@type": "@39" + } + ], + "CLAUSES": [], + "END_OPTIONS": [], + "options": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "options": { + "6": "view" + } + }, + "first": 0, + "last": 38 + } + ], + "brackets": 0, + "strict": false, + "errors": [] + }, + "errors": { + "lexer": [], + "parser": [] + } +} \ No newline at end of file diff --git a/tests/data/parser/parseWithStatement6.in b/tests/data/parser/parseWithStatement6.in new file mode 100644 index 000000000..9bbc2d940 --- /dev/null +++ b/tests/data/parser/parseWithStatement6.in @@ -0,0 +1 @@ +CREATE view view_name WITH aa(col1) AS ( SELECT 1 UNION ALL SELECT 2 ) SELECT col1 FROM cte \ No newline at end of file diff --git a/tests/data/parser/parseWithStatement6.out b/tests/data/parser/parseWithStatement6.out new file mode 100644 index 000000000..18effdcd0 --- /dev/null +++ b/tests/data/parser/parseWithStatement6.out @@ -0,0 +1,1029 @@ +{ + "query": "CREATE view view_name WITH aa(col1) AS ( SELECT 1 UNION ALL SELECT 2 ) SELECT col1 FROM cte", + "lexer": { + "@type": "PhpMyAdmin\\SqlParser\\Lexer", + "PARSER_METHODS": [ + "parseDelimiter", + "parseWhitespace", + "parseNumber", + "parseComment", + "parseOperator", + "parseBool", + "parseString", + "parseSymbol", + "parseKeyword", + "parseLabel", + "parseUnknown" + ], + "str": "CREATE view view_name WITH aa(col1) AS ( SELECT 1 UNION ALL SELECT 2 ) SELECT col1 FROM cte", + "len": 92, + "last": 92, + "list": { + "@type": "PhpMyAdmin\\SqlParser\\TokensList", + "tokens": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "CREATE", + "value": "CREATE", + "keyword": "CREATE", + "type": 1, + "flags": 3, + "position": 0 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 6 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "view", + "value": "view", + "keyword": "VIEW", + "type": 1, + "flags": 1, + "position": 7 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 11 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "view_name", + "value": "view_name", + "keyword": null, + "type": 0, + "flags": 0, + "position": 12 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 21 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "WITH", + "value": "WITH", + "keyword": "WITH", + "type": 1, + "flags": 3, + "position": 22 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 26 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "aa", + "value": "aa", + "keyword": null, + "type": 0, + "flags": 0, + "position": 28 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "(", + "value": "(", + "keyword": null, + "type": 2, + "flags": 16, + "position": 30 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "col1", + "value": "col1", + "keyword": null, + "type": 0, + "flags": 0, + "position": 31 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": ")", + "value": ")", + "keyword": null, + "type": 2, + "flags": 16, + "position": 35 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 36 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "AS", + "value": "AS", + "keyword": "AS", + "type": 1, + "flags": 3, + "position": 37 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 39 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "(", + "value": "(", + "keyword": null, + "type": 2, + "flags": 16, + "position": 40 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 41 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "SELECT", + "value": "SELECT", + "keyword": "SELECT", + "type": 1, + "flags": 3, + "position": 42 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 48 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "1", + "value": 1, + "keyword": null, + "type": 6, + "flags": 0, + "position": 49 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 50 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "UNION ALL", + "value": "UNION ALL", + "keyword": "UNION ALL", + "type": 1, + "flags": 7, + "position": 51 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 60 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "SELECT", + "value": "SELECT", + "keyword": "SELECT", + "type": 1, + "flags": 3, + "position": 61 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 67 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "2", + "value": 2, + "keyword": null, + "type": 6, + "flags": 0, + "position": 68 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 69 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": ")", + "value": ")", + "keyword": null, + "type": 2, + "flags": 16, + "position": 70 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 71 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "SELECT", + "value": "SELECT", + "keyword": "SELECT", + "type": 1, + "flags": 3, + "position": 72 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 78 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "col1", + "value": "col1", + "keyword": null, + "type": 0, + "flags": 0, + "position": 79 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 83 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "FROM", + "value": "FROM", + "keyword": "FROM", + "type": 1, + "flags": 3, + "position": 84 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 88 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "cte", + "value": "cte", + "keyword": null, + "type": 0, + "flags": 0, + "position": 89 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": null, + "value": null, + "keyword": null, + "type": 9, + "flags": 0, + "position": null + } + ], + "count": 37, + "idx": 37 + }, + "DEFAULT_DELIMITER": ";", + "delimiter": ";", + "delimiterLen": 1, + "strict": false, + "errors": [] + }, + "parser": { + "@type": "PhpMyAdmin\\SqlParser\\Parser", + "STATEMENT_PARSERS": { + "DESCRIBE": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "DESC": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "EXPLAIN": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "FLUSH": "", + "GRANT": "", + "HELP": "", + "SET PASSWORD": "", + "STATUS": "", + "USE": "", + "ANALYZE": "PhpMyAdmin\\SqlParser\\Statements\\AnalyzeStatement", + "BACKUP": "PhpMyAdmin\\SqlParser\\Statements\\BackupStatement", + "CHECK": "PhpMyAdmin\\SqlParser\\Statements\\CheckStatement", + "CHECKSUM": "PhpMyAdmin\\SqlParser\\Statements\\ChecksumStatement", + "OPTIMIZE": "PhpMyAdmin\\SqlParser\\Statements\\OptimizeStatement", + "REPAIR": "PhpMyAdmin\\SqlParser\\Statements\\RepairStatement", + "RESTORE": "PhpMyAdmin\\SqlParser\\Statements\\RestoreStatement", + "SET": "PhpMyAdmin\\SqlParser\\Statements\\SetStatement", + "SHOW": "PhpMyAdmin\\SqlParser\\Statements\\ShowStatement", + "ALTER": "PhpMyAdmin\\SqlParser\\Statements\\AlterStatement", + "CREATE": "PhpMyAdmin\\SqlParser\\Statements\\CreateStatement", + "DROP": "PhpMyAdmin\\SqlParser\\Statements\\DropStatement", + "RENAME": "PhpMyAdmin\\SqlParser\\Statements\\RenameStatement", + "TRUNCATE": "PhpMyAdmin\\SqlParser\\Statements\\TruncateStatement", + "CALL": "PhpMyAdmin\\SqlParser\\Statements\\CallStatement", + "DELETE": "PhpMyAdmin\\SqlParser\\Statements\\DeleteStatement", + "DO": "", + "HANDLER": "", + "INSERT": "PhpMyAdmin\\SqlParser\\Statements\\InsertStatement", + "LOAD DATA": "PhpMyAdmin\\SqlParser\\Statements\\LoadStatement", + "REPLACE": "PhpMyAdmin\\SqlParser\\Statements\\ReplaceStatement", + "SELECT": "PhpMyAdmin\\SqlParser\\Statements\\SelectStatement", + "UPDATE": "PhpMyAdmin\\SqlParser\\Statements\\UpdateStatement", + "WITH": "PhpMyAdmin\\SqlParser\\Statements\\WithStatement", + "DEALLOCATE": "", + "EXECUTE": "", + "PREPARE": "", + "BEGIN": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "COMMIT": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "ROLLBACK": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "START TRANSACTION": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "PURGE": "PhpMyAdmin\\SqlParser\\Statements\\PurgeStatement", + "LOCK": "PhpMyAdmin\\SqlParser\\Statements\\LockStatement", + "UNLOCK": "PhpMyAdmin\\SqlParser\\Statements\\LockStatement" + }, + "KEYWORD_PARSERS": { + "PARTITION BY": [], + "SUBPARTITION BY": [], + "_OPTIONS": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "field": "options" + }, + "_END_OPTIONS": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "field": "end_options" + }, + "INTERSECT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "EXCEPT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION ALL": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION DISTINCT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "ALTER": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "ANALYZE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "BACKUP": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CALL": { + "class": "PhpMyAdmin\\SqlParser\\Components\\FunctionCall", + "field": "call" + }, + "CHECK": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CHECKSUM": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CROSS JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "DROP": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "fields", + "options": { + "parseField": "table" + } + }, + "FORCE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "FROM": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "from", + "options": { + "field": "table" + } + }, + "GROUP BY": { + "class": "PhpMyAdmin\\SqlParser\\Components\\GroupKeyword", + "field": "group" + }, + "HAVING": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "field": "having" + }, + "IGNORE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "INTO": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IntoKeyword", + "field": "into" + }, + "JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LEFT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LEFT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "ON": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "RIGHT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "RIGHT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "INNER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "FULL JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "FULL OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL LEFT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL RIGHT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL LEFT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL RIGHT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "STRAIGHT_JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LIMIT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Limit", + "field": "limit" + }, + "OPTIMIZE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "ORDER BY": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OrderKeyword", + "field": "order" + }, + "PARTITION": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ArrayObj", + "field": "partition" + }, + "PROCEDURE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\FunctionCall", + "field": "procedure" + }, + "RENAME": { + "class": "PhpMyAdmin\\SqlParser\\Components\\RenameOperation", + "field": "renames" + }, + "REPAIR": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "RESTORE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "SET": { + "class": "PhpMyAdmin\\SqlParser\\Components\\SetOperation", + "field": "set" + }, + "SELECT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "expr" + }, + "TRUNCATE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "UPDATE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "USE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "VALUE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Array2d", + "field": "values" + }, + "VALUES": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Array2d", + "field": "values" + }, + "WHERE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "field": "where" + } + }, + "list": { + "@type": "@1" + }, + "statements": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Statements\\CreateStatement", + "OPTIONS": { + "TEMPORARY": 1, + "OR REPLACE": 2, + "ALGORITHM": [ + 3, + "var=" + ], + "DEFINER": [ + 4, + "expr=" + ], + "SQL SECURITY": [ + 5, + "var" + ], + "DATABASE": 6, + "EVENT": 6, + "FUNCTION": 6, + "INDEX": 6, + "UNIQUE INDEX": 6, + "FULLTEXT INDEX": 6, + "SPATIAL INDEX": 6, + "PROCEDURE": 6, + "SERVER": 6, + "TABLE": 6, + "TABLESPACE": 6, + "TRIGGER": 6, + "USER": 6, + "VIEW": 6, + "SCHEMA": 6, + "IF NOT EXISTS": 7 + }, + "DB_OPTIONS": { + "CHARACTER SET": [ + 1, + "var=" + ], + "CHARSET": [ + 1, + "var=" + ], + "DEFAULT CHARACTER SET": [ + 1, + "var=" + ], + "DEFAULT CHARSET": [ + 1, + "var=" + ], + "DEFAULT COLLATE": [ + 2, + "var=" + ], + "COLLATE": [ + 2, + "var=" + ] + }, + "TABLE_OPTIONS": { + "ENGINE": [ + 1, + "var=" + ], + "AUTO_INCREMENT": [ + 2, + "var=" + ], + "AVG_ROW_LENGTH": [ + 3, + "var" + ], + "CHARACTER SET": [ + 4, + "var=" + ], + "CHARSET": [ + 4, + "var=" + ], + "DEFAULT CHARACTER SET": [ + 4, + "var=" + ], + "DEFAULT CHARSET": [ + 4, + "var=" + ], + "CHECKSUM": [ + 5, + "var" + ], + "DEFAULT COLLATE": [ + 6, + "var=" + ], + "COLLATE": [ + 6, + "var=" + ], + "COMMENT": [ + 7, + "var=" + ], + "CONNECTION": [ + 8, + "var" + ], + "DATA DIRECTORY": [ + 9, + "var" + ], + "DELAY_KEY_WRITE": [ + 10, + "var" + ], + "INDEX DIRECTORY": [ + 11, + "var" + ], + "INSERT_METHOD": [ + 12, + "var" + ], + "KEY_BLOCK_SIZE": [ + 13, + "var" + ], + "MAX_ROWS": [ + 14, + "var" + ], + "MIN_ROWS": [ + 15, + "var" + ], + "PACK_KEYS": [ + 16, + "var" + ], + "PASSWORD": [ + 17, + "var" + ], + "ROW_FORMAT": [ + 18, + "var" + ], + "TABLESPACE": [ + 19, + "var" + ], + "STORAGE": [ + 20, + "var" + ], + "UNION": [ + 21, + "var" + ] + }, + "FUNC_OPTIONS": { + "NOT": [ + 2, + "var" + ], + "FUNCTION": [ + 3, + "var=" + ], + "PROCEDURE": [ + 3, + "var=" + ], + "CONTAINS": [ + 4, + "expr" + ], + "NO": [ + 4, + "var" + ], + "READS": [ + 4, + "var" + ], + "MODIFIES": [ + 4, + "expr" + ], + "SQL SECURITY": [ + 6, + "var" + ], + "LANGUAGE": [ + 7, + "var" + ], + "COMMENT": [ + 8, + "var" + ], + "CREATE": 1, + "DETERMINISTIC": 2, + "DATA": 5 + }, + "TRIGGER_OPTIONS": { + "BEFORE": 1, + "AFTER": 1, + "INSERT": 2, + "UPDATE": 2, + "DELETE": 2 + }, + "name": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "ALLOWED_KEYWORDS": { + "AS": 1, + "DUAL": 1, + "NULL": 1, + "REGEXP": 1, + "CASE": 1, + "DIV": 1, + "AND": 1, + "OR": 1, + "XOR": 1, + "NOT": 1, + "MOD": 1, + "OVER": 2 + }, + "database": null, + "table": "view_name", + "column": null, + "expr": "view_name", + "alias": null, + "function": null, + "subquery": null + }, + "entityOptions": null, + "fields": null, + "with": null, + "select": null, + "like": null, + "partitionBy": null, + "partitionsNum": null, + "subpartitionBy": null, + "subpartitionsNum": null, + "partitions": null, + "table": null, + "return": null, + "parameters": null, + "body": [ + { + "@type": "@9" + }, + { + "@type": "@10" + }, + { + "@type": "@11" + }, + { + "@type": "@12" + }, + { + "@type": "@13" + }, + { + "@type": "@14" + }, + { + "@type": "@15" + }, + { + "@type": "@16" + }, + { + "@type": "@17" + }, + { + "@type": "@18" + }, + { + "@type": "@19" + }, + { + "@type": "@20" + }, + { + "@type": "@21" + }, + { + "@type": "@22" + }, + { + "@type": "@23" + }, + { + "@type": "@24" + }, + { + "@type": "@25" + }, + { + "@type": "@26" + }, + { + "@type": "@27" + }, + { + "@type": "@28" + }, + { + "@type": "@29" + }, + { + "@type": "@30" + }, + { + "@type": "@31" + }, + { + "@type": "@32" + }, + { + "@type": "@33" + }, + { + "@type": "@34" + }, + { + "@type": "@35" + }, + { + "@type": "@36" + }, + { + "@type": "@37" + } + ], + "CLAUSES": [], + "END_OPTIONS": [], + "options": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "options": { + "6": "view" + } + }, + "first": 0, + "last": 36 + } + ], + "brackets": 0, + "strict": false, + "errors": [] + }, + "errors": { + "lexer": [], + "parser": [] + } +} \ No newline at end of file From 85a6461ed722acfcb8e2f70eb7e2c992282b24f6 Mon Sep 17 00:00:00 2001 From: "Fawzi E. Abdulfattah" Date: Mon, 6 Dec 2021 03:44:13 +0200 Subject: [PATCH 05/12] Improve types for Psalm and error's message improvement Signed-off-by: Fawzi E. Abdulfattah --- src/Statements/WithStatement.php | 9 ++++++++- tests/data/parser/parseWithStatement4.out | 2 +- tests/data/parser/parseWithStatementErr.out | 2 +- tests/data/parser/parseWithStatementErr1.out | 2 +- tests/data/parser/parseWithStatementErr2.out | 2 +- tests/data/parser/parseWithStatementErr3.out | 2 +- tests/data/parser/parseWithStatementErr4.out | 2 +- tests/data/parser/parseWithStatementErr5.out | 2 +- tests/data/parser/parseWithStatementErr6.out | 2 +- 9 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/Statements/WithStatement.php b/src/Statements/WithStatement.php index 414abd687..d322e53e6 100644 --- a/src/Statements/WithStatement.php +++ b/src/Statements/WithStatement.php @@ -240,7 +240,14 @@ public function parse(Parser $parser, TokensList $list) // 5 is the only valid end state if ($state !== 5) { - $parser->error('Unexpected end of WITH CTE.', $list->tokens[$list->idx]); + /** + * Token parsed at this moment. + * + * @var Token + */ + $token = $list->tokens[$list->idx]; + + $parser->error('Unexpected end of the WITH CTE.', $token); } --$list->idx; diff --git a/tests/data/parser/parseWithStatement4.out b/tests/data/parser/parseWithStatement4.out index 2ba8d5831..571cb3f60 100644 --- a/tests/data/parser/parseWithStatement4.out +++ b/tests/data/parser/parseWithStatement4.out @@ -1699,7 +1699,7 @@ 0 ], [ - "Unexpected end of WITH CTE.", + "Unexpected end of the WITH CTE.", { "@type": "@34" }, diff --git a/tests/data/parser/parseWithStatementErr.out b/tests/data/parser/parseWithStatementErr.out index 13834b775..5c8c48979 100644 --- a/tests/data/parser/parseWithStatementErr.out +++ b/tests/data/parser/parseWithStatementErr.out @@ -796,7 +796,7 @@ 0 ], [ - "Unexpected end of WITH CTE.", + "Unexpected end of the WITH CTE.", { "@type": "@12" }, diff --git a/tests/data/parser/parseWithStatementErr1.out b/tests/data/parser/parseWithStatementErr1.out index 032a3f99b..f50cdc921 100644 --- a/tests/data/parser/parseWithStatementErr1.out +++ b/tests/data/parser/parseWithStatementErr1.out @@ -1594,7 +1594,7 @@ 0 ], [ - "Unexpected end of WITH CTE.", + "Unexpected end of the WITH CTE.", { "@type": "@16" }, diff --git a/tests/data/parser/parseWithStatementErr2.out b/tests/data/parser/parseWithStatementErr2.out index 3a4d89b9b..d6a737148 100644 --- a/tests/data/parser/parseWithStatementErr2.out +++ b/tests/data/parser/parseWithStatementErr2.out @@ -1347,7 +1347,7 @@ 0 ], [ - "Unexpected end of WITH CTE.", + "Unexpected end of the WITH CTE.", { "@type": "@25" }, diff --git a/tests/data/parser/parseWithStatementErr3.out b/tests/data/parser/parseWithStatementErr3.out index 3c43475ca..2749b9518 100644 --- a/tests/data/parser/parseWithStatementErr3.out +++ b/tests/data/parser/parseWithStatementErr3.out @@ -1672,7 +1672,7 @@ 0 ], [ - "Unexpected end of WITH CTE.", + "Unexpected end of the WITH CTE.", { "@type": "@32" }, diff --git a/tests/data/parser/parseWithStatementErr4.out b/tests/data/parser/parseWithStatementErr4.out index 762f8d9de..3231428ee 100644 --- a/tests/data/parser/parseWithStatementErr4.out +++ b/tests/data/parser/parseWithStatementErr4.out @@ -1681,7 +1681,7 @@ 0 ], [ - "Unexpected end of WITH CTE.", + "Unexpected end of the WITH CTE.", { "@type": "@32" }, diff --git a/tests/data/parser/parseWithStatementErr5.out b/tests/data/parser/parseWithStatementErr5.out index b00c29766..5b3fe7418 100644 --- a/tests/data/parser/parseWithStatementErr5.out +++ b/tests/data/parser/parseWithStatementErr5.out @@ -909,7 +909,7 @@ 0 ], [ - "Unexpected end of WITH CTE.", + "Unexpected end of the WITH CTE.", { "@type": "@10" }, diff --git a/tests/data/parser/parseWithStatementErr6.out b/tests/data/parser/parseWithStatementErr6.out index 652168b42..d538640e1 100644 --- a/tests/data/parser/parseWithStatementErr6.out +++ b/tests/data/parser/parseWithStatementErr6.out @@ -1421,7 +1421,7 @@ 0 ], [ - "Unexpected end of WITH CTE.", + "Unexpected end of the WITH CTE.", { "@type": "@18" }, From f5269d7ff85e5ba689f60ef85983fef2aed616d6 Mon Sep 17 00:00:00 2001 From: "Fawzi E. Abdulfattah" Date: Mon, 6 Dec 2021 03:54:24 +0200 Subject: [PATCH 06/12] Adding more test cases Signed-off-by: Fawzi E. Abdulfattah --- tests/Parser/WithStatementTest.php | 2 + tests/data/parser/parseWithStatementErr7.in | 1 + tests/data/parser/parseWithStatementErr7.out | 938 ++++++++++++ tests/data/parser/parseWithStatementErr8.in | 1 + tests/data/parser/parseWithStatementErr8.out | 1430 ++++++++++++++++++ 5 files changed, 2372 insertions(+) create mode 100644 tests/data/parser/parseWithStatementErr7.in create mode 100644 tests/data/parser/parseWithStatementErr7.out create mode 100644 tests/data/parser/parseWithStatementErr8.in create mode 100644 tests/data/parser/parseWithStatementErr8.out diff --git a/tests/Parser/WithStatementTest.php b/tests/Parser/WithStatementTest.php index db3233189..66c565511 100644 --- a/tests/Parser/WithStatementTest.php +++ b/tests/Parser/WithStatementTest.php @@ -40,6 +40,8 @@ public function parseWith(): array ['parser/parseWithStatementErr4'], ['parser/parseWithStatementErr5'], ['parser/parseWithStatementErr6'], + ['parser/parseWithStatementErr7'], + ['parser/parseWithStatementErr8'], ]; } diff --git a/tests/data/parser/parseWithStatementErr7.in b/tests/data/parser/parseWithStatementErr7.in new file mode 100644 index 000000000..00ee71c2a --- /dev/null +++ b/tests/data/parser/parseWithStatementErr7.in @@ -0,0 +1 @@ +WITH cte (col1) AS ( SELECT 1 UNN ALL SELECT 2 ) SELECT col1 FROM cte \ No newline at end of file diff --git a/tests/data/parser/parseWithStatementErr7.out b/tests/data/parser/parseWithStatementErr7.out new file mode 100644 index 000000000..163edc50b --- /dev/null +++ b/tests/data/parser/parseWithStatementErr7.out @@ -0,0 +1,938 @@ +{ + "query": "WITH cte (col1) AS ( SELECT 1 UNN ALL SELECT 2 ) SELECT col1 FROM cte", + "lexer": { + "@type": "PhpMyAdmin\\SqlParser\\Lexer", + "PARSER_METHODS": [ + "parseDelimiter", + "parseWhitespace", + "parseNumber", + "parseComment", + "parseOperator", + "parseBool", + "parseString", + "parseSymbol", + "parseKeyword", + "parseLabel", + "parseUnknown" + ], + "str": "WITH cte (col1) AS ( SELECT 1 UNN ALL SELECT 2 ) SELECT col1 FROM cte", + "len": 69, + "last": 69, + "list": { + "@type": "PhpMyAdmin\\SqlParser\\TokensList", + "tokens": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "WITH", + "value": "WITH", + "keyword": "WITH", + "type": 1, + "flags": 3, + "position": 0 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 4 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "cte", + "value": "cte", + "keyword": null, + "type": 0, + "flags": 0, + "position": 5 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 8 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "(", + "value": "(", + "keyword": null, + "type": 2, + "flags": 16, + "position": 9 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "col1", + "value": "col1", + "keyword": null, + "type": 0, + "flags": 0, + "position": 10 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": ")", + "value": ")", + "keyword": null, + "type": 2, + "flags": 16, + "position": 14 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 15 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "AS", + "value": "AS", + "keyword": "AS", + "type": 1, + "flags": 3, + "position": 16 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 18 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "(", + "value": "(", + "keyword": null, + "type": 2, + "flags": 16, + "position": 19 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 20 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "SELECT", + "value": "SELECT", + "keyword": "SELECT", + "type": 1, + "flags": 3, + "position": 21 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 27 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "1", + "value": 1, + "keyword": null, + "type": 6, + "flags": 0, + "position": 28 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 29 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "UNN", + "value": "UNN", + "keyword": null, + "type": 0, + "flags": 0, + "position": 30 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 33 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "ALL", + "value": "ALL", + "keyword": "ALL", + "type": 1, + "flags": 3, + "position": 34 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 37 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "SELECT", + "value": "SELECT", + "keyword": "SELECT", + "type": 1, + "flags": 3, + "position": 38 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 44 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "2", + "value": 2, + "keyword": null, + "type": 6, + "flags": 0, + "position": 45 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 46 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": ")", + "value": ")", + "keyword": null, + "type": 2, + "flags": 16, + "position": 47 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 48 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "SELECT", + "value": "SELECT", + "keyword": "SELECT", + "type": 1, + "flags": 3, + "position": 49 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 55 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "col1", + "value": "col1", + "keyword": null, + "type": 0, + "flags": 0, + "position": 56 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 60 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "FROM", + "value": "FROM", + "keyword": "FROM", + "type": 1, + "flags": 3, + "position": 61 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 65 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "cte", + "value": "cte", + "keyword": null, + "type": 0, + "flags": 0, + "position": 66 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": null, + "value": null, + "keyword": null, + "type": 9, + "flags": 0, + "position": null + } + ], + "count": 34, + "idx": 34 + }, + "DEFAULT_DELIMITER": ";", + "delimiter": ";", + "delimiterLen": 1, + "strict": false, + "errors": [] + }, + "parser": { + "@type": "PhpMyAdmin\\SqlParser\\Parser", + "STATEMENT_PARSERS": { + "DESCRIBE": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "DESC": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "EXPLAIN": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "FLUSH": "", + "GRANT": "", + "HELP": "", + "SET PASSWORD": "", + "STATUS": "", + "USE": "", + "ANALYZE": "PhpMyAdmin\\SqlParser\\Statements\\AnalyzeStatement", + "BACKUP": "PhpMyAdmin\\SqlParser\\Statements\\BackupStatement", + "CHECK": "PhpMyAdmin\\SqlParser\\Statements\\CheckStatement", + "CHECKSUM": "PhpMyAdmin\\SqlParser\\Statements\\ChecksumStatement", + "OPTIMIZE": "PhpMyAdmin\\SqlParser\\Statements\\OptimizeStatement", + "REPAIR": "PhpMyAdmin\\SqlParser\\Statements\\RepairStatement", + "RESTORE": "PhpMyAdmin\\SqlParser\\Statements\\RestoreStatement", + "SET": "PhpMyAdmin\\SqlParser\\Statements\\SetStatement", + "SHOW": "PhpMyAdmin\\SqlParser\\Statements\\ShowStatement", + "ALTER": "PhpMyAdmin\\SqlParser\\Statements\\AlterStatement", + "CREATE": "PhpMyAdmin\\SqlParser\\Statements\\CreateStatement", + "DROP": "PhpMyAdmin\\SqlParser\\Statements\\DropStatement", + "RENAME": "PhpMyAdmin\\SqlParser\\Statements\\RenameStatement", + "TRUNCATE": "PhpMyAdmin\\SqlParser\\Statements\\TruncateStatement", + "CALL": "PhpMyAdmin\\SqlParser\\Statements\\CallStatement", + "DELETE": "PhpMyAdmin\\SqlParser\\Statements\\DeleteStatement", + "DO": "", + "HANDLER": "", + "INSERT": "PhpMyAdmin\\SqlParser\\Statements\\InsertStatement", + "LOAD DATA": "PhpMyAdmin\\SqlParser\\Statements\\LoadStatement", + "REPLACE": "PhpMyAdmin\\SqlParser\\Statements\\ReplaceStatement", + "SELECT": "PhpMyAdmin\\SqlParser\\Statements\\SelectStatement", + "UPDATE": "PhpMyAdmin\\SqlParser\\Statements\\UpdateStatement", + "WITH": "PhpMyAdmin\\SqlParser\\Statements\\WithStatement", + "DEALLOCATE": "", + "EXECUTE": "", + "PREPARE": "", + "BEGIN": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "COMMIT": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "ROLLBACK": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "START TRANSACTION": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "PURGE": "PhpMyAdmin\\SqlParser\\Statements\\PurgeStatement", + "LOCK": "PhpMyAdmin\\SqlParser\\Statements\\LockStatement", + "UNLOCK": "PhpMyAdmin\\SqlParser\\Statements\\LockStatement" + }, + "KEYWORD_PARSERS": { + "PARTITION BY": [], + "SUBPARTITION BY": [], + "_OPTIONS": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "field": "options" + }, + "_END_OPTIONS": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "field": "end_options" + }, + "INTERSECT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "EXCEPT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION ALL": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION DISTINCT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "ALTER": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "ANALYZE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "BACKUP": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CALL": { + "class": "PhpMyAdmin\\SqlParser\\Components\\FunctionCall", + "field": "call" + }, + "CHECK": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CHECKSUM": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CROSS JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "DROP": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "fields", + "options": { + "parseField": "table" + } + }, + "FORCE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "FROM": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "from", + "options": { + "field": "table" + } + }, + "GROUP BY": { + "class": "PhpMyAdmin\\SqlParser\\Components\\GroupKeyword", + "field": "group" + }, + "HAVING": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "field": "having" + }, + "IGNORE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "INTO": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IntoKeyword", + "field": "into" + }, + "JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LEFT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LEFT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "ON": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "RIGHT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "RIGHT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "INNER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "FULL JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "FULL OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL LEFT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL RIGHT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL LEFT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL RIGHT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "STRAIGHT_JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LIMIT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Limit", + "field": "limit" + }, + "OPTIMIZE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "ORDER BY": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OrderKeyword", + "field": "order" + }, + "PARTITION": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ArrayObj", + "field": "partition" + }, + "PROCEDURE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\FunctionCall", + "field": "procedure" + }, + "RENAME": { + "class": "PhpMyAdmin\\SqlParser\\Components\\RenameOperation", + "field": "renames" + }, + "REPAIR": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "RESTORE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "SET": { + "class": "PhpMyAdmin\\SqlParser\\Components\\SetOperation", + "field": "set" + }, + "SELECT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "expr" + }, + "TRUNCATE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "UPDATE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "USE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "VALUE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Array2d", + "field": "values" + }, + "VALUES": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Array2d", + "field": "values" + }, + "WHERE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "field": "where" + } + }, + "list": { + "@type": "@1" + }, + "statements": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Statements\\WithStatement", + "OPTIONS": { + "RECURSIVE": 1 + }, + "CLAUSES": { + "WITH": [ + "WITH", + 2 + ], + "_OPTIONS": [ + "_OPTIONS", + 1 + ], + "AS": [ + "AS", + 2 + ] + }, + "withers": { + "cte": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\WithKeyword", + "name": "cte", + "columns": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\ArrayObj", + "raw": [ + "col1" + ], + "values": [ + "col1" + ] + } + ], + "statement": null + } + }, + "END_OPTIONS": [], + "options": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "options": [] + }, + "first": 0, + "last": 23 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Statements\\SelectStatement", + "OPTIONS": { + "ALL": 1, + "DISTINCT": 1, + "DISTINCTROW": 1, + "HIGH_PRIORITY": 2, + "MAX_STATEMENT_TIME": [ + 3, + "var=" + ], + "STRAIGHT_JOIN": 4, + "SQL_SMALL_RESULT": 5, + "SQL_BIG_RESULT": 6, + "SQL_BUFFER_RESULT": 7, + "SQL_CACHE": 8, + "SQL_NO_CACHE": 8, + "SQL_CALC_FOUND_ROWS": 9 + }, + "END_OPTIONS": { + "FOR UPDATE": 1, + "LOCK IN SHARE MODE": 1 + }, + "CLAUSES": { + "SELECT": [ + "SELECT", + 2 + ], + "_OPTIONS": [ + "_OPTIONS", + 1 + ], + "_SELECT": [ + "SELECT", + 1 + ], + "INTO": [ + "INTO", + 3 + ], + "FROM": [ + "FROM", + 3 + ], + "FORCE": [ + "FORCE", + 1 + ], + "USE": [ + "USE", + 1 + ], + "IGNORE": [ + "IGNORE", + 3 + ], + "PARTITION": [ + "PARTITION", + 3 + ], + "JOIN": [ + "JOIN", + 1 + ], + "FULL JOIN": [ + "FULL JOIN", + 1 + ], + "INNER JOIN": [ + "INNER JOIN", + 1 + ], + "LEFT JOIN": [ + "LEFT JOIN", + 1 + ], + "LEFT OUTER JOIN": [ + "LEFT OUTER JOIN", + 1 + ], + "RIGHT JOIN": [ + "RIGHT JOIN", + 1 + ], + "RIGHT OUTER JOIN": [ + "RIGHT OUTER JOIN", + 1 + ], + "NATURAL JOIN": [ + "NATURAL JOIN", + 1 + ], + "NATURAL LEFT JOIN": [ + "NATURAL LEFT JOIN", + 1 + ], + "NATURAL RIGHT JOIN": [ + "NATURAL RIGHT JOIN", + 1 + ], + "NATURAL LEFT OUTER JOIN": [ + "NATURAL LEFT OUTER JOIN", + 1 + ], + "NATURAL RIGHT OUTER JOIN": [ + "NATURAL RIGHT JOIN", + 1 + ], + "WHERE": [ + "WHERE", + 3 + ], + "GROUP BY": [ + "GROUP BY", + 3 + ], + "HAVING": [ + "HAVING", + 3 + ], + "ORDER BY": [ + "ORDER BY", + 3 + ], + "LIMIT": [ + "LIMIT", + 3 + ], + "PROCEDURE": [ + "PROCEDURE", + 3 + ], + "UNION": [ + "UNION", + 1 + ], + "EXCEPT": [ + "EXCEPT", + 1 + ], + "INTERSECT": [ + "INTERSECT", + 1 + ], + "_END_OPTIONS": [ + "_END_OPTIONS", + 1 + ] + }, + "expr": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "ALLOWED_KEYWORDS": { + "AS": 1, + "DUAL": 1, + "NULL": 1, + "REGEXP": 1, + "CASE": 1, + "DIV": 1, + "AND": 1, + "OR": 1, + "XOR": 1, + "NOT": 1, + "MOD": 1, + "OVER": 2 + }, + "database": null, + "table": null, + "column": "col1", + "expr": "col1", + "alias": null, + "function": null, + "subquery": null + } + ], + "from": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "ALLOWED_KEYWORDS": { + "AS": 1, + "DUAL": 1, + "NULL": 1, + "REGEXP": 1, + "CASE": 1, + "DIV": 1, + "AND": 1, + "OR": 1, + "XOR": 1, + "NOT": 1, + "MOD": 1, + "OVER": 2 + }, + "database": null, + "table": "cte", + "column": null, + "expr": "cte", + "alias": null, + "function": null, + "subquery": null + } + ], + "index_hints": null, + "partition": null, + "where": null, + "group": null, + "having": null, + "order": null, + "limit": null, + "procedure": null, + "into": null, + "join": null, + "union": [], + "end_options": null, + "options": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "options": [] + }, + "first": 24, + "last": 32 + } + ], + "brackets": 0, + "strict": false, + "errors": [] + }, + "errors": { + "lexer": [], + "parser": [ + [ + "Unrecognized keyword.", + { + "@type": "@20" + }, + 0 + ], + [ + "This type of clause was previously parsed.", + { + "@type": "@22" + }, + 0 + ], + [ + "Unexpected end of the WITH CTE.", + { + "@type": "@26" + }, + 0 + ] + ] + } +} \ No newline at end of file diff --git a/tests/data/parser/parseWithStatementErr8.in b/tests/data/parser/parseWithStatementErr8.in new file mode 100644 index 000000000..fbc5b99af --- /dev/null +++ b/tests/data/parser/parseWithStatementErr8.in @@ -0,0 +1 @@ +WITH cte (col1) AS ( SELECT 1 UNION ALL SELECT 2 ) SELECT col1 FR cte \ No newline at end of file diff --git a/tests/data/parser/parseWithStatementErr8.out b/tests/data/parser/parseWithStatementErr8.out new file mode 100644 index 000000000..a31251f51 --- /dev/null +++ b/tests/data/parser/parseWithStatementErr8.out @@ -0,0 +1,1430 @@ +{ + "query": "WITH cte (col1) AS ( SELECT 1 UNION ALL SELECT 2 ) SELECT col1 FR cte", + "lexer": { + "@type": "PhpMyAdmin\\SqlParser\\Lexer", + "PARSER_METHODS": [ + "parseDelimiter", + "parseWhitespace", + "parseNumber", + "parseComment", + "parseOperator", + "parseBool", + "parseString", + "parseSymbol", + "parseKeyword", + "parseLabel", + "parseUnknown" + ], + "str": "WITH cte (col1) AS ( SELECT 1 UNION ALL SELECT 2 ) SELECT col1 FR cte", + "len": 69, + "last": 69, + "list": { + "@type": "PhpMyAdmin\\SqlParser\\TokensList", + "tokens": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "WITH", + "value": "WITH", + "keyword": "WITH", + "type": 1, + "flags": 3, + "position": 0 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 4 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "cte", + "value": "cte", + "keyword": null, + "type": 0, + "flags": 0, + "position": 5 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 8 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "(", + "value": "(", + "keyword": null, + "type": 2, + "flags": 16, + "position": 9 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "col1", + "value": "col1", + "keyword": null, + "type": 0, + "flags": 0, + "position": 10 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": ")", + "value": ")", + "keyword": null, + "type": 2, + "flags": 16, + "position": 14 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 15 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "AS", + "value": "AS", + "keyword": "AS", + "type": 1, + "flags": 3, + "position": 16 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 18 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "(", + "value": "(", + "keyword": null, + "type": 2, + "flags": 16, + "position": 19 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 20 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "SELECT", + "value": "SELECT", + "keyword": "SELECT", + "type": 1, + "flags": 3, + "position": 21 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 27 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "1", + "value": 1, + "keyword": null, + "type": 6, + "flags": 0, + "position": 28 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 29 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "UNION ALL", + "value": "UNION ALL", + "keyword": "UNION ALL", + "type": 1, + "flags": 7, + "position": 30 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 39 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "SELECT", + "value": "SELECT", + "keyword": "SELECT", + "type": 1, + "flags": 3, + "position": 40 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 46 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "2", + "value": 2, + "keyword": null, + "type": 6, + "flags": 0, + "position": 47 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 48 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": ")", + "value": ")", + "keyword": null, + "type": 2, + "flags": 16, + "position": 49 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 50 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "SELECT", + "value": "SELECT", + "keyword": "SELECT", + "type": 1, + "flags": 3, + "position": 51 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 57 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "col1", + "value": "col1", + "keyword": null, + "type": 0, + "flags": 0, + "position": 58 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 62 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "FR", + "value": "FR", + "keyword": null, + "type": 0, + "flags": 0, + "position": 63 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 65 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "cte", + "value": "cte", + "keyword": null, + "type": 0, + "flags": 0, + "position": 66 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": null, + "value": null, + "keyword": null, + "type": 9, + "flags": 0, + "position": null + } + ], + "count": 32, + "idx": 32 + }, + "DEFAULT_DELIMITER": ";", + "delimiter": ";", + "delimiterLen": 1, + "strict": false, + "errors": [] + }, + "parser": { + "@type": "PhpMyAdmin\\SqlParser\\Parser", + "STATEMENT_PARSERS": { + "DESCRIBE": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "DESC": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "EXPLAIN": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "FLUSH": "", + "GRANT": "", + "HELP": "", + "SET PASSWORD": "", + "STATUS": "", + "USE": "", + "ANALYZE": "PhpMyAdmin\\SqlParser\\Statements\\AnalyzeStatement", + "BACKUP": "PhpMyAdmin\\SqlParser\\Statements\\BackupStatement", + "CHECK": "PhpMyAdmin\\SqlParser\\Statements\\CheckStatement", + "CHECKSUM": "PhpMyAdmin\\SqlParser\\Statements\\ChecksumStatement", + "OPTIMIZE": "PhpMyAdmin\\SqlParser\\Statements\\OptimizeStatement", + "REPAIR": "PhpMyAdmin\\SqlParser\\Statements\\RepairStatement", + "RESTORE": "PhpMyAdmin\\SqlParser\\Statements\\RestoreStatement", + "SET": "PhpMyAdmin\\SqlParser\\Statements\\SetStatement", + "SHOW": "PhpMyAdmin\\SqlParser\\Statements\\ShowStatement", + "ALTER": "PhpMyAdmin\\SqlParser\\Statements\\AlterStatement", + "CREATE": "PhpMyAdmin\\SqlParser\\Statements\\CreateStatement", + "DROP": "PhpMyAdmin\\SqlParser\\Statements\\DropStatement", + "RENAME": "PhpMyAdmin\\SqlParser\\Statements\\RenameStatement", + "TRUNCATE": "PhpMyAdmin\\SqlParser\\Statements\\TruncateStatement", + "CALL": "PhpMyAdmin\\SqlParser\\Statements\\CallStatement", + "DELETE": "PhpMyAdmin\\SqlParser\\Statements\\DeleteStatement", + "DO": "", + "HANDLER": "", + "INSERT": "PhpMyAdmin\\SqlParser\\Statements\\InsertStatement", + "LOAD DATA": "PhpMyAdmin\\SqlParser\\Statements\\LoadStatement", + "REPLACE": "PhpMyAdmin\\SqlParser\\Statements\\ReplaceStatement", + "SELECT": "PhpMyAdmin\\SqlParser\\Statements\\SelectStatement", + "UPDATE": "PhpMyAdmin\\SqlParser\\Statements\\UpdateStatement", + "WITH": "PhpMyAdmin\\SqlParser\\Statements\\WithStatement", + "DEALLOCATE": "", + "EXECUTE": "", + "PREPARE": "", + "BEGIN": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "COMMIT": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "ROLLBACK": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "START TRANSACTION": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "PURGE": "PhpMyAdmin\\SqlParser\\Statements\\PurgeStatement", + "LOCK": "PhpMyAdmin\\SqlParser\\Statements\\LockStatement", + "UNLOCK": "PhpMyAdmin\\SqlParser\\Statements\\LockStatement" + }, + "KEYWORD_PARSERS": { + "PARTITION BY": [], + "SUBPARTITION BY": [], + "_OPTIONS": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "field": "options" + }, + "_END_OPTIONS": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "field": "end_options" + }, + "INTERSECT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "EXCEPT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION ALL": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION DISTINCT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "ALTER": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "ANALYZE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "BACKUP": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CALL": { + "class": "PhpMyAdmin\\SqlParser\\Components\\FunctionCall", + "field": "call" + }, + "CHECK": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CHECKSUM": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CROSS JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "DROP": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "fields", + "options": { + "parseField": "table" + } + }, + "FORCE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "FROM": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "from", + "options": { + "field": "table" + } + }, + "GROUP BY": { + "class": "PhpMyAdmin\\SqlParser\\Components\\GroupKeyword", + "field": "group" + }, + "HAVING": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "field": "having" + }, + "IGNORE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "INTO": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IntoKeyword", + "field": "into" + }, + "JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LEFT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LEFT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "ON": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "RIGHT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "RIGHT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "INNER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "FULL JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "FULL OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL LEFT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL RIGHT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL LEFT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL RIGHT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "STRAIGHT_JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LIMIT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Limit", + "field": "limit" + }, + "OPTIMIZE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "ORDER BY": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OrderKeyword", + "field": "order" + }, + "PARTITION": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ArrayObj", + "field": "partition" + }, + "PROCEDURE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\FunctionCall", + "field": "procedure" + }, + "RENAME": { + "class": "PhpMyAdmin\\SqlParser\\Components\\RenameOperation", + "field": "renames" + }, + "REPAIR": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "RESTORE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "SET": { + "class": "PhpMyAdmin\\SqlParser\\Components\\SetOperation", + "field": "set" + }, + "SELECT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "expr" + }, + "TRUNCATE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "UPDATE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "USE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "VALUE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Array2d", + "field": "values" + }, + "VALUES": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Array2d", + "field": "values" + }, + "WHERE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "field": "where" + } + }, + "list": { + "@type": "@1" + }, + "statements": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Statements\\WithStatement", + "OPTIONS": { + "RECURSIVE": 1 + }, + "CLAUSES": { + "WITH": [ + "WITH", + 2 + ], + "_OPTIONS": [ + "_OPTIONS", + 1 + ], + "AS": [ + "AS", + 2 + ] + }, + "withers": { + "cte": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\WithKeyword", + "name": "cte", + "columns": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\ArrayObj", + "raw": [ + "col1" + ], + "values": [ + "col1" + ] + } + ], + "statement": { + "@type": "PhpMyAdmin\\SqlParser\\Parser", + "STATEMENT_PARSERS": { + "DESCRIBE": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "DESC": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "EXPLAIN": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "FLUSH": "", + "GRANT": "", + "HELP": "", + "SET PASSWORD": "", + "STATUS": "", + "USE": "", + "ANALYZE": "PhpMyAdmin\\SqlParser\\Statements\\AnalyzeStatement", + "BACKUP": "PhpMyAdmin\\SqlParser\\Statements\\BackupStatement", + "CHECK": "PhpMyAdmin\\SqlParser\\Statements\\CheckStatement", + "CHECKSUM": "PhpMyAdmin\\SqlParser\\Statements\\ChecksumStatement", + "OPTIMIZE": "PhpMyAdmin\\SqlParser\\Statements\\OptimizeStatement", + "REPAIR": "PhpMyAdmin\\SqlParser\\Statements\\RepairStatement", + "RESTORE": "PhpMyAdmin\\SqlParser\\Statements\\RestoreStatement", + "SET": "PhpMyAdmin\\SqlParser\\Statements\\SetStatement", + "SHOW": "PhpMyAdmin\\SqlParser\\Statements\\ShowStatement", + "ALTER": "PhpMyAdmin\\SqlParser\\Statements\\AlterStatement", + "CREATE": "PhpMyAdmin\\SqlParser\\Statements\\CreateStatement", + "DROP": "PhpMyAdmin\\SqlParser\\Statements\\DropStatement", + "RENAME": "PhpMyAdmin\\SqlParser\\Statements\\RenameStatement", + "TRUNCATE": "PhpMyAdmin\\SqlParser\\Statements\\TruncateStatement", + "CALL": "PhpMyAdmin\\SqlParser\\Statements\\CallStatement", + "DELETE": "PhpMyAdmin\\SqlParser\\Statements\\DeleteStatement", + "DO": "", + "HANDLER": "", + "INSERT": "PhpMyAdmin\\SqlParser\\Statements\\InsertStatement", + "LOAD DATA": "PhpMyAdmin\\SqlParser\\Statements\\LoadStatement", + "REPLACE": "PhpMyAdmin\\SqlParser\\Statements\\ReplaceStatement", + "SELECT": "PhpMyAdmin\\SqlParser\\Statements\\SelectStatement", + "UPDATE": "PhpMyAdmin\\SqlParser\\Statements\\UpdateStatement", + "WITH": "PhpMyAdmin\\SqlParser\\Statements\\WithStatement", + "DEALLOCATE": "", + "EXECUTE": "", + "PREPARE": "", + "BEGIN": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "COMMIT": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "ROLLBACK": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "START TRANSACTION": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "PURGE": "PhpMyAdmin\\SqlParser\\Statements\\PurgeStatement", + "LOCK": "PhpMyAdmin\\SqlParser\\Statements\\LockStatement", + "UNLOCK": "PhpMyAdmin\\SqlParser\\Statements\\LockStatement" + }, + "KEYWORD_PARSERS": { + "PARTITION BY": [], + "SUBPARTITION BY": [], + "_OPTIONS": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "field": "options" + }, + "_END_OPTIONS": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "field": "end_options" + }, + "INTERSECT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "EXCEPT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION ALL": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION DISTINCT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "ALTER": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "ANALYZE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "BACKUP": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CALL": { + "class": "PhpMyAdmin\\SqlParser\\Components\\FunctionCall", + "field": "call" + }, + "CHECK": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CHECKSUM": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CROSS JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "DROP": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "fields", + "options": { + "parseField": "table" + } + }, + "FORCE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "FROM": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "from", + "options": { + "field": "table" + } + }, + "GROUP BY": { + "class": "PhpMyAdmin\\SqlParser\\Components\\GroupKeyword", + "field": "group" + }, + "HAVING": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "field": "having" + }, + "IGNORE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "INTO": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IntoKeyword", + "field": "into" + }, + "JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LEFT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LEFT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "ON": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "RIGHT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "RIGHT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "INNER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "FULL JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "FULL OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL LEFT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL RIGHT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL LEFT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL RIGHT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "STRAIGHT_JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LIMIT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Limit", + "field": "limit" + }, + "OPTIMIZE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "ORDER BY": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OrderKeyword", + "field": "order" + }, + "PARTITION": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ArrayObj", + "field": "partition" + }, + "PROCEDURE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\FunctionCall", + "field": "procedure" + }, + "RENAME": { + "class": "PhpMyAdmin\\SqlParser\\Components\\RenameOperation", + "field": "renames" + }, + "REPAIR": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "RESTORE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "SET": { + "class": "PhpMyAdmin\\SqlParser\\Components\\SetOperation", + "field": "set" + }, + "SELECT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "expr" + }, + "TRUNCATE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "UPDATE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "USE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "VALUE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Array2d", + "field": "values" + }, + "VALUES": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Array2d", + "field": "values" + }, + "WHERE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "field": "where" + } + }, + "list": { + "@type": "PhpMyAdmin\\SqlParser\\TokensList", + "tokens": [ + { + "@type": "@13" + }, + { + "@type": "@14" + }, + { + "@type": "@15" + }, + { + "@type": "@16" + }, + { + "@type": "@17" + }, + { + "@type": "@18" + }, + { + "@type": "@19" + }, + { + "@type": "@20" + }, + { + "@type": "@21" + }, + { + "@type": "@22" + }, + { + "@type": "@23" + } + ], + "count": 11, + "idx": 11 + }, + "statements": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Statements\\SelectStatement", + "OPTIONS": { + "ALL": 1, + "DISTINCT": 1, + "DISTINCTROW": 1, + "HIGH_PRIORITY": 2, + "MAX_STATEMENT_TIME": [ + 3, + "var=" + ], + "STRAIGHT_JOIN": 4, + "SQL_SMALL_RESULT": 5, + "SQL_BIG_RESULT": 6, + "SQL_BUFFER_RESULT": 7, + "SQL_CACHE": 8, + "SQL_NO_CACHE": 8, + "SQL_CALC_FOUND_ROWS": 9 + }, + "END_OPTIONS": { + "FOR UPDATE": 1, + "LOCK IN SHARE MODE": 1 + }, + "CLAUSES": { + "SELECT": [ + "SELECT", + 2 + ], + "_OPTIONS": [ + "_OPTIONS", + 1 + ], + "_SELECT": [ + "SELECT", + 1 + ], + "INTO": [ + "INTO", + 3 + ], + "FROM": [ + "FROM", + 3 + ], + "FORCE": [ + "FORCE", + 1 + ], + "USE": [ + "USE", + 1 + ], + "IGNORE": [ + "IGNORE", + 3 + ], + "PARTITION": [ + "PARTITION", + 3 + ], + "JOIN": [ + "JOIN", + 1 + ], + "FULL JOIN": [ + "FULL JOIN", + 1 + ], + "INNER JOIN": [ + "INNER JOIN", + 1 + ], + "LEFT JOIN": [ + "LEFT JOIN", + 1 + ], + "LEFT OUTER JOIN": [ + "LEFT OUTER JOIN", + 1 + ], + "RIGHT JOIN": [ + "RIGHT JOIN", + 1 + ], + "RIGHT OUTER JOIN": [ + "RIGHT OUTER JOIN", + 1 + ], + "NATURAL JOIN": [ + "NATURAL JOIN", + 1 + ], + "NATURAL LEFT JOIN": [ + "NATURAL LEFT JOIN", + 1 + ], + "NATURAL RIGHT JOIN": [ + "NATURAL RIGHT JOIN", + 1 + ], + "NATURAL LEFT OUTER JOIN": [ + "NATURAL LEFT OUTER JOIN", + 1 + ], + "NATURAL RIGHT OUTER JOIN": [ + "NATURAL RIGHT JOIN", + 1 + ], + "WHERE": [ + "WHERE", + 3 + ], + "GROUP BY": [ + "GROUP BY", + 3 + ], + "HAVING": [ + "HAVING", + 3 + ], + "ORDER BY": [ + "ORDER BY", + 3 + ], + "LIMIT": [ + "LIMIT", + 3 + ], + "PROCEDURE": [ + "PROCEDURE", + 3 + ], + "UNION": [ + "UNION", + 1 + ], + "EXCEPT": [ + "EXCEPT", + 1 + ], + "INTERSECT": [ + "INTERSECT", + 1 + ], + "_END_OPTIONS": [ + "_END_OPTIONS", + 1 + ] + }, + "expr": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "ALLOWED_KEYWORDS": { + "AS": 1, + "DUAL": 1, + "NULL": 1, + "REGEXP": 1, + "CASE": 1, + "DIV": 1, + "AND": 1, + "OR": 1, + "XOR": 1, + "NOT": 1, + "MOD": 1, + "OVER": 2 + }, + "database": null, + "table": null, + "column": null, + "expr": "1", + "alias": null, + "function": null, + "subquery": null + } + ], + "from": [], + "index_hints": null, + "partition": null, + "where": null, + "group": null, + "having": null, + "order": null, + "limit": null, + "procedure": null, + "into": null, + "join": null, + "union": [ + [ + "UNION ALL", + { + "@type": "PhpMyAdmin\\SqlParser\\Statements\\SelectStatement", + "OPTIONS": { + "ALL": 1, + "DISTINCT": 1, + "DISTINCTROW": 1, + "HIGH_PRIORITY": 2, + "MAX_STATEMENT_TIME": [ + 3, + "var=" + ], + "STRAIGHT_JOIN": 4, + "SQL_SMALL_RESULT": 5, + "SQL_BIG_RESULT": 6, + "SQL_BUFFER_RESULT": 7, + "SQL_CACHE": 8, + "SQL_NO_CACHE": 8, + "SQL_CALC_FOUND_ROWS": 9 + }, + "END_OPTIONS": { + "FOR UPDATE": 1, + "LOCK IN SHARE MODE": 1 + }, + "CLAUSES": { + "SELECT": [ + "SELECT", + 2 + ], + "_OPTIONS": [ + "_OPTIONS", + 1 + ], + "_SELECT": [ + "SELECT", + 1 + ], + "INTO": [ + "INTO", + 3 + ], + "FROM": [ + "FROM", + 3 + ], + "FORCE": [ + "FORCE", + 1 + ], + "USE": [ + "USE", + 1 + ], + "IGNORE": [ + "IGNORE", + 3 + ], + "PARTITION": [ + "PARTITION", + 3 + ], + "JOIN": [ + "JOIN", + 1 + ], + "FULL JOIN": [ + "FULL JOIN", + 1 + ], + "INNER JOIN": [ + "INNER JOIN", + 1 + ], + "LEFT JOIN": [ + "LEFT JOIN", + 1 + ], + "LEFT OUTER JOIN": [ + "LEFT OUTER JOIN", + 1 + ], + "RIGHT JOIN": [ + "RIGHT JOIN", + 1 + ], + "RIGHT OUTER JOIN": [ + "RIGHT OUTER JOIN", + 1 + ], + "NATURAL JOIN": [ + "NATURAL JOIN", + 1 + ], + "NATURAL LEFT JOIN": [ + "NATURAL LEFT JOIN", + 1 + ], + "NATURAL RIGHT JOIN": [ + "NATURAL RIGHT JOIN", + 1 + ], + "NATURAL LEFT OUTER JOIN": [ + "NATURAL LEFT OUTER JOIN", + 1 + ], + "NATURAL RIGHT OUTER JOIN": [ + "NATURAL RIGHT JOIN", + 1 + ], + "WHERE": [ + "WHERE", + 3 + ], + "GROUP BY": [ + "GROUP BY", + 3 + ], + "HAVING": [ + "HAVING", + 3 + ], + "ORDER BY": [ + "ORDER BY", + 3 + ], + "LIMIT": [ + "LIMIT", + 3 + ], + "PROCEDURE": [ + "PROCEDURE", + 3 + ], + "UNION": [ + "UNION", + 1 + ], + "EXCEPT": [ + "EXCEPT", + 1 + ], + "INTERSECT": [ + "INTERSECT", + 1 + ], + "_END_OPTIONS": [ + "_END_OPTIONS", + 1 + ] + }, + "expr": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "ALLOWED_KEYWORDS": { + "AS": 1, + "DUAL": 1, + "NULL": 1, + "REGEXP": 1, + "CASE": 1, + "DIV": 1, + "AND": 1, + "OR": 1, + "XOR": 1, + "NOT": 1, + "MOD": 1, + "OVER": 2 + }, + "database": null, + "table": null, + "column": null, + "expr": "2", + "alias": null, + "function": null, + "subquery": null + } + ], + "from": [], + "index_hints": null, + "partition": null, + "where": null, + "group": null, + "having": null, + "order": [], + "limit": null, + "procedure": null, + "into": null, + "join": null, + "union": [], + "end_options": null, + "options": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "options": [] + }, + "first": 5, + "last": 10 + } + ] + ], + "end_options": null, + "options": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "options": [] + }, + "first": 0, + "last": 10 + } + ], + "brackets": 0, + "strict": false, + "errors": [] + } + } + }, + "END_OPTIONS": [], + "options": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "options": [] + }, + "first": 0, + "last": 30 + } + ], + "brackets": 0, + "strict": false, + "errors": [] + }, + "errors": { + "lexer": [], + "parser": [ + [ + "An alias was previously found.", + { + "@type": "@32" + }, + 0 + ], + [ + "Unexpected token.", + { + "@type": "@32" + }, + 0 + ] + ] + } +} \ No newline at end of file From 3516c9403e20628199dc13dc5245ca29e1bb447d Mon Sep 17 00:00:00 2001 From: "Fawzi E. Abdulfattah" Date: Mon, 6 Dec 2021 08:35:43 +0200 Subject: [PATCH 07/12] Uncommenting tests Signed-off-by: Fawzi E. Abdulfattah --- tests/Builder/CreateStatementTest.php | 100 +++++++++++++------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/tests/Builder/CreateStatementTest.php b/tests/Builder/CreateStatementTest.php index 4bf1c238a..9d5160c0d 100644 --- a/tests/Builder/CreateStatementTest.php +++ b/tests/Builder/CreateStatementTest.php @@ -287,42 +287,31 @@ public function testBuilderPartitionsEngine(string $query): void public function testBuilderView(): void { - // $parser = new Parser( - // 'CREATE VIEW myView (vid, vfirstname) AS ' . - // 'SELECT id, first_name FROM employee WHERE id = 1' - // ); - // $stmt = $parser->statements[0]; - - // $this->assertEquals( - // 'CREATE VIEW myView (vid, vfirstname) AS ' . - // 'SELECT id, first_name FROM employee WHERE id = 1 ', - // $stmt->build() - // ); - - // $parser = new Parser( - // 'CREATE OR REPLACE VIEW myView (vid, vfirstname) AS ' . - // 'SELECT id, first_name FROM employee WHERE id = 1' - // ); - // $stmt = $parser->statements[0]; - - // $this->assertEquals( - // 'CREATE OR REPLACE VIEW myView (vid, vfirstname) AS ' . - // 'SELECT id, first_name FROM employee WHERE id = 1 ', - // $stmt->build() - // ); - - // // Assert the builder can build wrong syntax select expressions - // $parser = new Parser( - // 'CREATE OR REPLACE VIEW myView (vid, vfirstname) AS ' . - // 'SELECT id, first_name, FROMzz employee WHERE id = 1' - // ); - // $stmt = $parser->statements[0]; - // $this->assertEquals( - // 'CREATE OR REPLACE VIEW myView (vid, vfirstname) AS ' . - // 'SELECT id, first_name, FROMzz employee WHERE id = 1 ', - // $stmt->build() - // ); + $parser = new Parser( + 'CREATE VIEW myView (vid, vfirstname) AS ' . + 'SELECT id, first_name FROM employee WHERE id = 1' + ); + $stmt = $parser->statements[0]; + + $this->assertEquals( + 'CREATE VIEW myView (vid, vfirstname) AS ' . + 'SELECT id, first_name FROM employee WHERE id = 1 ', + $stmt->build() + ); + $parser = new Parser( + 'CREATE OR REPLACE VIEW myView (vid, vfirstname) AS ' . + 'SELECT id, first_name FROM employee WHERE id = 1' + ); + $stmt = $parser->statements[0]; + + $this->assertEquals( + 'CREATE OR REPLACE VIEW myView (vid, vfirstname) AS ' . + 'SELECT id, first_name FROM employee WHERE id = 1 ', + $stmt->build() + ); + + // Assert the builder can build wrong syntax select expressions $parser = new Parser( 'CREATE OR REPLACE VIEW myView (vid, vfirstname) AS ' . 'SELECT id, first_name, FROMzz employee WHERE id = 1' @@ -334,21 +323,32 @@ public function testBuilderView(): void $stmt->build() ); - // $parser = new Parser( - // 'CREATE OR REPLACE VIEW myView (vid, vfirstname) AS ' . - // 'SELECT id, first_name, FROMzz employee WHERE id = 1 ' . - // 'UNION ' . - // 'SELECT id, first_name, FROMzz employee WHERE id = 2 ' - // ); - // $stmt = $parser->statements[0]; - - // $this->assertEquals( - // 'CREATE OR REPLACE VIEW myView (vid, vfirstname) AS ' . - // 'SELECT id, first_name, FROMzz employee WHERE id = 1 ' . - // 'UNION ' . - // 'SELECT id, first_name, FROMzz employee WHERE id = 2 ', - // $stmt->build() - // ); + $parser = new Parser( + 'CREATE OR REPLACE VIEW myView (vid, vfirstname) AS ' . + 'SELECT id, first_name, FROMzz employee WHERE id = 1' + ); + $stmt = $parser->statements[0]; + $this->assertEquals( + 'CREATE OR REPLACE VIEW myView (vid, vfirstname) AS ' . + 'SELECT id, first_name, FROMzz employee WHERE id = 1 ', + $stmt->build() + ); + + $parser = new Parser( + 'CREATE OR REPLACE VIEW myView (vid, vfirstname) AS ' . + 'SELECT id, first_name, FROMzz employee WHERE id = 1 ' . + 'UNION ' . + 'SELECT id, first_name, FROMzz employee WHERE id = 2 ' + ); + $stmt = $parser->statements[0]; + + $this->assertEquals( + 'CREATE OR REPLACE VIEW myView (vid, vfirstname) AS ' . + 'SELECT id, first_name, FROMzz employee WHERE id = 1 ' . + 'UNION ' . + 'SELECT id, first_name, FROMzz employee WHERE id = 2 ', + $stmt->build() + ); } public function testBuilderViewComplex(): void From 199ba667074430e2f4a66a77a74b67250b36c878 Mon Sep 17 00:00:00 2001 From: "Fawzi E. Abdulfattah" Date: Mon, 6 Dec 2021 08:52:51 +0200 Subject: [PATCH 08/12] updating comments Signed-off-by: Fawzi E. Abdulfattah --- src/Statements/WithStatement.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Statements/WithStatement.php b/src/Statements/WithStatement.php index d322e53e6..ea00cbc46 100644 --- a/src/Statements/WithStatement.php +++ b/src/Statements/WithStatement.php @@ -218,7 +218,9 @@ public function parse(Parser $parser, TokensList $list) $idxOfOn = $list->idx - 1; // Index of the last parsed token will be the token before the ON Keyword, therefore $idxOfOn - 1. $idxOfLastParsedToken = $idxOfOn - 1; - // The length of the expression tokens would be the position of + // The length of the expression tokens would be the difference + // between the first unrelated token `ON` and the idx + // before skipping the CTE tokens. $lengthOfExpressionTokens = $idxOfOn - $idxBeforeSearch; } From cd49677a17e807f2a8c244025e183c21a7603c92 Mon Sep 17 00:00:00 2001 From: "Fawzi E. Abdulfattah" Date: Mon, 6 Dec 2021 09:48:44 +0200 Subject: [PATCH 09/12] Explicitly check ON DUPLICATE KEY UPDATE and adding a test case Signed-off-by: Fawzi E. Abdulfattah --- src/Statements/WithStatement.php | 22 +- tests/Parser/WithStatementTest.php | 1 + tests/data/parser/parseWithStatement7.in | 1 + tests/data/parser/parseWithStatement7.out | 1550 +++++++++++++++++++++ 4 files changed, 1568 insertions(+), 6 deletions(-) create mode 100644 tests/data/parser/parseWithStatement7.in create mode 100644 tests/data/parser/parseWithStatement7.out diff --git a/src/Statements/WithStatement.php b/src/Statements/WithStatement.php index ea00cbc46..23e677019 100644 --- a/src/Statements/WithStatement.php +++ b/src/Statements/WithStatement.php @@ -216,12 +216,22 @@ public function parse(Parser $parser, TokensList $list) if ($list->getNextOfTypeAndValue(Token::TYPE_KEYWORD, 'ON')) { // (-1) because getNextOfTypeAndValue returned ON and increased the index. $idxOfOn = $list->idx - 1; - // Index of the last parsed token will be the token before the ON Keyword, therefore $idxOfOn - 1. - $idxOfLastParsedToken = $idxOfOn - 1; - // The length of the expression tokens would be the difference - // between the first unrelated token `ON` and the idx - // before skipping the CTE tokens. - $lengthOfExpressionTokens = $idxOfOn - $idxBeforeSearch; + // We want to make sure that it's `ON DUPLICATE KEY UPDATE` + $dubplicateToken = $list->getNext(); + $keyToken = $list->getNext(); + $updateToken = $list->getNext(); + if ( + $dubplicateToken && $dubplicateToken->keyword === 'DUPLICATE' + && ($keyToken && $keyToken->keyword === 'KEY') + && ($updateToken && $updateToken->keyword === 'UPDATE') + ) { + // Index of the last parsed token will be the token before the ON Keyword + $idxOfLastParsedToken = $idxOfOn - 1; + // The length of the expression tokens would be the difference + // between the first unrelated token `ON` and the idx + // before skipping the CTE tokens. + $lengthOfExpressionTokens = $idxOfOn - $idxBeforeSearch; + } } // Restore the index diff --git a/tests/Parser/WithStatementTest.php b/tests/Parser/WithStatementTest.php index 66c565511..c5b952930 100644 --- a/tests/Parser/WithStatementTest.php +++ b/tests/Parser/WithStatementTest.php @@ -33,6 +33,7 @@ public function parseWith(): array ['parser/parseWithStatement4'], ['parser/parseWithStatement5'], ['parser/parseWithStatement6'], + ['parser/parseWithStatement7'], ['parser/parseWithStatementErr'], ['parser/parseWithStatementErr1'], ['parser/parseWithStatementErr2'], diff --git a/tests/data/parser/parseWithStatement7.in b/tests/data/parser/parseWithStatement7.in new file mode 100644 index 000000000..ed1eb3163 --- /dev/null +++ b/tests/data/parser/parseWithStatement7.in @@ -0,0 +1 @@ +WITH cte (col1) AS ( SELECT 1 UNION ALL SELECT 2 ) SELECT * FROM cte INNER JOIN table2 ON table2.col1=cte.col1; \ No newline at end of file diff --git a/tests/data/parser/parseWithStatement7.out b/tests/data/parser/parseWithStatement7.out new file mode 100644 index 000000000..8b5c7d320 --- /dev/null +++ b/tests/data/parser/parseWithStatement7.out @@ -0,0 +1,1550 @@ +{ + "query": "WITH cte (col1) AS ( SELECT 1 UNION ALL SELECT 2 ) SELECT * FROM cte INNER JOIN table2 ON table2.col1=cte.col1;", + "lexer": { + "@type": "PhpMyAdmin\\SqlParser\\Lexer", + "PARSER_METHODS": [ + "parseDelimiter", + "parseWhitespace", + "parseNumber", + "parseComment", + "parseOperator", + "parseBool", + "parseString", + "parseSymbol", + "parseKeyword", + "parseLabel", + "parseUnknown" + ], + "str": "WITH cte (col1) AS ( SELECT 1 UNION ALL SELECT 2 ) SELECT * FROM cte INNER JOIN table2 ON table2.col1=cte.col1;", + "len": 111, + "last": 111, + "list": { + "@type": "PhpMyAdmin\\SqlParser\\TokensList", + "tokens": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "WITH", + "value": "WITH", + "keyword": "WITH", + "type": 1, + "flags": 3, + "position": 0 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 4 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "cte", + "value": "cte", + "keyword": null, + "type": 0, + "flags": 0, + "position": 5 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 8 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "(", + "value": "(", + "keyword": null, + "type": 2, + "flags": 16, + "position": 9 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "col1", + "value": "col1", + "keyword": null, + "type": 0, + "flags": 0, + "position": 10 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": ")", + "value": ")", + "keyword": null, + "type": 2, + "flags": 16, + "position": 14 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 15 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "AS", + "value": "AS", + "keyword": "AS", + "type": 1, + "flags": 3, + "position": 16 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 18 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "(", + "value": "(", + "keyword": null, + "type": 2, + "flags": 16, + "position": 19 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 20 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "SELECT", + "value": "SELECT", + "keyword": "SELECT", + "type": 1, + "flags": 3, + "position": 21 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 27 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "1", + "value": 1, + "keyword": null, + "type": 6, + "flags": 0, + "position": 28 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 29 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "UNION ALL", + "value": "UNION ALL", + "keyword": "UNION ALL", + "type": 1, + "flags": 7, + "position": 30 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 39 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "SELECT", + "value": "SELECT", + "keyword": "SELECT", + "type": 1, + "flags": 3, + "position": 40 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 46 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "2", + "value": 2, + "keyword": null, + "type": 6, + "flags": 0, + "position": 47 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 48 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": ")", + "value": ")", + "keyword": null, + "type": 2, + "flags": 16, + "position": 49 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 50 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "SELECT", + "value": "SELECT", + "keyword": "SELECT", + "type": 1, + "flags": 3, + "position": 51 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 57 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "*", + "value": "*", + "keyword": null, + "type": 2, + "flags": 16, + "position": 58 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 59 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "FROM", + "value": "FROM", + "keyword": "FROM", + "type": 1, + "flags": 3, + "position": 60 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 64 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "cte", + "value": "cte", + "keyword": null, + "type": 0, + "flags": 0, + "position": 65 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 68 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "INNER JOIN", + "value": "INNER JOIN", + "keyword": "INNER JOIN", + "type": 1, + "flags": 7, + "position": 69 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 79 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "table2", + "value": "table2", + "keyword": null, + "type": 0, + "flags": 0, + "position": 80 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 86 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "ON", + "value": "ON", + "keyword": "ON", + "type": 1, + "flags": 3, + "position": 87 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 89 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "table2", + "value": "table2", + "keyword": null, + "type": 0, + "flags": 0, + "position": 90 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": ".", + "value": ".", + "keyword": null, + "type": 2, + "flags": 16, + "position": 96 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "col1", + "value": "col1", + "keyword": null, + "type": 0, + "flags": 0, + "position": 97 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "=", + "value": "=", + "keyword": null, + "type": 2, + "flags": 2, + "position": 101 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "cte", + "value": "cte", + "keyword": null, + "type": 0, + "flags": 0, + "position": 102 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": ".", + "value": ".", + "keyword": null, + "type": 2, + "flags": 16, + "position": 105 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "col1", + "value": "col1", + "keyword": null, + "type": 0, + "flags": 0, + "position": 106 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": ";", + "value": ";", + "keyword": null, + "type": 9, + "flags": 0, + "position": 110 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": null, + "value": null, + "keyword": null, + "type": 9, + "flags": 0, + "position": null + } + ], + "count": 47, + "idx": 47 + }, + "DEFAULT_DELIMITER": ";", + "delimiter": ";", + "delimiterLen": 1, + "strict": false, + "errors": [] + }, + "parser": { + "@type": "PhpMyAdmin\\SqlParser\\Parser", + "STATEMENT_PARSERS": { + "DESCRIBE": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "DESC": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "EXPLAIN": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "FLUSH": "", + "GRANT": "", + "HELP": "", + "SET PASSWORD": "", + "STATUS": "", + "USE": "", + "ANALYZE": "PhpMyAdmin\\SqlParser\\Statements\\AnalyzeStatement", + "BACKUP": "PhpMyAdmin\\SqlParser\\Statements\\BackupStatement", + "CHECK": "PhpMyAdmin\\SqlParser\\Statements\\CheckStatement", + "CHECKSUM": "PhpMyAdmin\\SqlParser\\Statements\\ChecksumStatement", + "OPTIMIZE": "PhpMyAdmin\\SqlParser\\Statements\\OptimizeStatement", + "REPAIR": "PhpMyAdmin\\SqlParser\\Statements\\RepairStatement", + "RESTORE": "PhpMyAdmin\\SqlParser\\Statements\\RestoreStatement", + "SET": "PhpMyAdmin\\SqlParser\\Statements\\SetStatement", + "SHOW": "PhpMyAdmin\\SqlParser\\Statements\\ShowStatement", + "ALTER": "PhpMyAdmin\\SqlParser\\Statements\\AlterStatement", + "CREATE": "PhpMyAdmin\\SqlParser\\Statements\\CreateStatement", + "DROP": "PhpMyAdmin\\SqlParser\\Statements\\DropStatement", + "RENAME": "PhpMyAdmin\\SqlParser\\Statements\\RenameStatement", + "TRUNCATE": "PhpMyAdmin\\SqlParser\\Statements\\TruncateStatement", + "CALL": "PhpMyAdmin\\SqlParser\\Statements\\CallStatement", + "DELETE": "PhpMyAdmin\\SqlParser\\Statements\\DeleteStatement", + "DO": "", + "HANDLER": "", + "INSERT": "PhpMyAdmin\\SqlParser\\Statements\\InsertStatement", + "LOAD DATA": "PhpMyAdmin\\SqlParser\\Statements\\LoadStatement", + "REPLACE": "PhpMyAdmin\\SqlParser\\Statements\\ReplaceStatement", + "SELECT": "PhpMyAdmin\\SqlParser\\Statements\\SelectStatement", + "UPDATE": "PhpMyAdmin\\SqlParser\\Statements\\UpdateStatement", + "WITH": "PhpMyAdmin\\SqlParser\\Statements\\WithStatement", + "DEALLOCATE": "", + "EXECUTE": "", + "PREPARE": "", + "BEGIN": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "COMMIT": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "ROLLBACK": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "START TRANSACTION": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "PURGE": "PhpMyAdmin\\SqlParser\\Statements\\PurgeStatement", + "LOCK": "PhpMyAdmin\\SqlParser\\Statements\\LockStatement", + "UNLOCK": "PhpMyAdmin\\SqlParser\\Statements\\LockStatement" + }, + "KEYWORD_PARSERS": { + "PARTITION BY": [], + "SUBPARTITION BY": [], + "_OPTIONS": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "field": "options" + }, + "_END_OPTIONS": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "field": "end_options" + }, + "INTERSECT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "EXCEPT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION ALL": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION DISTINCT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "ALTER": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "ANALYZE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "BACKUP": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CALL": { + "class": "PhpMyAdmin\\SqlParser\\Components\\FunctionCall", + "field": "call" + }, + "CHECK": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CHECKSUM": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CROSS JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "DROP": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "fields", + "options": { + "parseField": "table" + } + }, + "FORCE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "FROM": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "from", + "options": { + "field": "table" + } + }, + "GROUP BY": { + "class": "PhpMyAdmin\\SqlParser\\Components\\GroupKeyword", + "field": "group" + }, + "HAVING": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "field": "having" + }, + "IGNORE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "INTO": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IntoKeyword", + "field": "into" + }, + "JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LEFT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LEFT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "ON": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "RIGHT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "RIGHT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "INNER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "FULL JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "FULL OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL LEFT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL RIGHT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL LEFT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL RIGHT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "STRAIGHT_JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LIMIT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Limit", + "field": "limit" + }, + "OPTIMIZE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "ORDER BY": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OrderKeyword", + "field": "order" + }, + "PARTITION": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ArrayObj", + "field": "partition" + }, + "PROCEDURE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\FunctionCall", + "field": "procedure" + }, + "RENAME": { + "class": "PhpMyAdmin\\SqlParser\\Components\\RenameOperation", + "field": "renames" + }, + "REPAIR": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "RESTORE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "SET": { + "class": "PhpMyAdmin\\SqlParser\\Components\\SetOperation", + "field": "set" + }, + "SELECT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "expr" + }, + "TRUNCATE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "UPDATE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "USE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "VALUE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Array2d", + "field": "values" + }, + "VALUES": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Array2d", + "field": "values" + }, + "WHERE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "field": "where" + } + }, + "list": { + "@type": "@1" + }, + "statements": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Statements\\WithStatement", + "OPTIONS": { + "RECURSIVE": 1 + }, + "CLAUSES": { + "WITH": [ + "WITH", + 2 + ], + "_OPTIONS": [ + "_OPTIONS", + 1 + ], + "AS": [ + "AS", + 2 + ] + }, + "withers": { + "cte": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\WithKeyword", + "name": "cte", + "columns": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\ArrayObj", + "raw": [ + "col1" + ], + "values": [ + "col1" + ] + } + ], + "statement": { + "@type": "PhpMyAdmin\\SqlParser\\Parser", + "STATEMENT_PARSERS": { + "DESCRIBE": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "DESC": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "EXPLAIN": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "FLUSH": "", + "GRANT": "", + "HELP": "", + "SET PASSWORD": "", + "STATUS": "", + "USE": "", + "ANALYZE": "PhpMyAdmin\\SqlParser\\Statements\\AnalyzeStatement", + "BACKUP": "PhpMyAdmin\\SqlParser\\Statements\\BackupStatement", + "CHECK": "PhpMyAdmin\\SqlParser\\Statements\\CheckStatement", + "CHECKSUM": "PhpMyAdmin\\SqlParser\\Statements\\ChecksumStatement", + "OPTIMIZE": "PhpMyAdmin\\SqlParser\\Statements\\OptimizeStatement", + "REPAIR": "PhpMyAdmin\\SqlParser\\Statements\\RepairStatement", + "RESTORE": "PhpMyAdmin\\SqlParser\\Statements\\RestoreStatement", + "SET": "PhpMyAdmin\\SqlParser\\Statements\\SetStatement", + "SHOW": "PhpMyAdmin\\SqlParser\\Statements\\ShowStatement", + "ALTER": "PhpMyAdmin\\SqlParser\\Statements\\AlterStatement", + "CREATE": "PhpMyAdmin\\SqlParser\\Statements\\CreateStatement", + "DROP": "PhpMyAdmin\\SqlParser\\Statements\\DropStatement", + "RENAME": "PhpMyAdmin\\SqlParser\\Statements\\RenameStatement", + "TRUNCATE": "PhpMyAdmin\\SqlParser\\Statements\\TruncateStatement", + "CALL": "PhpMyAdmin\\SqlParser\\Statements\\CallStatement", + "DELETE": "PhpMyAdmin\\SqlParser\\Statements\\DeleteStatement", + "DO": "", + "HANDLER": "", + "INSERT": "PhpMyAdmin\\SqlParser\\Statements\\InsertStatement", + "LOAD DATA": "PhpMyAdmin\\SqlParser\\Statements\\LoadStatement", + "REPLACE": "PhpMyAdmin\\SqlParser\\Statements\\ReplaceStatement", + "SELECT": "PhpMyAdmin\\SqlParser\\Statements\\SelectStatement", + "UPDATE": "PhpMyAdmin\\SqlParser\\Statements\\UpdateStatement", + "WITH": "PhpMyAdmin\\SqlParser\\Statements\\WithStatement", + "DEALLOCATE": "", + "EXECUTE": "", + "PREPARE": "", + "BEGIN": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "COMMIT": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "ROLLBACK": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "START TRANSACTION": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "PURGE": "PhpMyAdmin\\SqlParser\\Statements\\PurgeStatement", + "LOCK": "PhpMyAdmin\\SqlParser\\Statements\\LockStatement", + "UNLOCK": "PhpMyAdmin\\SqlParser\\Statements\\LockStatement" + }, + "KEYWORD_PARSERS": { + "PARTITION BY": [], + "SUBPARTITION BY": [], + "_OPTIONS": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "field": "options" + }, + "_END_OPTIONS": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "field": "end_options" + }, + "INTERSECT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "EXCEPT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION ALL": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION DISTINCT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "ALTER": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "ANALYZE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "BACKUP": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CALL": { + "class": "PhpMyAdmin\\SqlParser\\Components\\FunctionCall", + "field": "call" + }, + "CHECK": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CHECKSUM": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CROSS JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "DROP": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "fields", + "options": { + "parseField": "table" + } + }, + "FORCE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "FROM": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "from", + "options": { + "field": "table" + } + }, + "GROUP BY": { + "class": "PhpMyAdmin\\SqlParser\\Components\\GroupKeyword", + "field": "group" + }, + "HAVING": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "field": "having" + }, + "IGNORE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "INTO": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IntoKeyword", + "field": "into" + }, + "JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LEFT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LEFT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "ON": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "RIGHT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "RIGHT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "INNER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "FULL JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "FULL OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL LEFT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL RIGHT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL LEFT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL RIGHT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "STRAIGHT_JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LIMIT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Limit", + "field": "limit" + }, + "OPTIMIZE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "ORDER BY": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OrderKeyword", + "field": "order" + }, + "PARTITION": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ArrayObj", + "field": "partition" + }, + "PROCEDURE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\FunctionCall", + "field": "procedure" + }, + "RENAME": { + "class": "PhpMyAdmin\\SqlParser\\Components\\RenameOperation", + "field": "renames" + }, + "REPAIR": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "RESTORE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "SET": { + "class": "PhpMyAdmin\\SqlParser\\Components\\SetOperation", + "field": "set" + }, + "SELECT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "expr" + }, + "TRUNCATE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "UPDATE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "USE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "VALUE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Array2d", + "field": "values" + }, + "VALUES": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Array2d", + "field": "values" + }, + "WHERE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "field": "where" + } + }, + "list": { + "@type": "PhpMyAdmin\\SqlParser\\TokensList", + "tokens": [ + { + "@type": "@13" + }, + { + "@type": "@14" + }, + { + "@type": "@15" + }, + { + "@type": "@16" + }, + { + "@type": "@17" + }, + { + "@type": "@18" + }, + { + "@type": "@19" + }, + { + "@type": "@20" + }, + { + "@type": "@21" + }, + { + "@type": "@22" + }, + { + "@type": "@23" + } + ], + "count": 11, + "idx": 11 + }, + "statements": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Statements\\SelectStatement", + "OPTIONS": { + "ALL": 1, + "DISTINCT": 1, + "DISTINCTROW": 1, + "HIGH_PRIORITY": 2, + "MAX_STATEMENT_TIME": [ + 3, + "var=" + ], + "STRAIGHT_JOIN": 4, + "SQL_SMALL_RESULT": 5, + "SQL_BIG_RESULT": 6, + "SQL_BUFFER_RESULT": 7, + "SQL_CACHE": 8, + "SQL_NO_CACHE": 8, + "SQL_CALC_FOUND_ROWS": 9 + }, + "END_OPTIONS": { + "FOR UPDATE": 1, + "LOCK IN SHARE MODE": 1 + }, + "CLAUSES": { + "SELECT": [ + "SELECT", + 2 + ], + "_OPTIONS": [ + "_OPTIONS", + 1 + ], + "_SELECT": [ + "SELECT", + 1 + ], + "INTO": [ + "INTO", + 3 + ], + "FROM": [ + "FROM", + 3 + ], + "FORCE": [ + "FORCE", + 1 + ], + "USE": [ + "USE", + 1 + ], + "IGNORE": [ + "IGNORE", + 3 + ], + "PARTITION": [ + "PARTITION", + 3 + ], + "JOIN": [ + "JOIN", + 1 + ], + "FULL JOIN": [ + "FULL JOIN", + 1 + ], + "INNER JOIN": [ + "INNER JOIN", + 1 + ], + "LEFT JOIN": [ + "LEFT JOIN", + 1 + ], + "LEFT OUTER JOIN": [ + "LEFT OUTER JOIN", + 1 + ], + "RIGHT JOIN": [ + "RIGHT JOIN", + 1 + ], + "RIGHT OUTER JOIN": [ + "RIGHT OUTER JOIN", + 1 + ], + "NATURAL JOIN": [ + "NATURAL JOIN", + 1 + ], + "NATURAL LEFT JOIN": [ + "NATURAL LEFT JOIN", + 1 + ], + "NATURAL RIGHT JOIN": [ + "NATURAL RIGHT JOIN", + 1 + ], + "NATURAL LEFT OUTER JOIN": [ + "NATURAL LEFT OUTER JOIN", + 1 + ], + "NATURAL RIGHT OUTER JOIN": [ + "NATURAL RIGHT JOIN", + 1 + ], + "WHERE": [ + "WHERE", + 3 + ], + "GROUP BY": [ + "GROUP BY", + 3 + ], + "HAVING": [ + "HAVING", + 3 + ], + "ORDER BY": [ + "ORDER BY", + 3 + ], + "LIMIT": [ + "LIMIT", + 3 + ], + "PROCEDURE": [ + "PROCEDURE", + 3 + ], + "UNION": [ + "UNION", + 1 + ], + "EXCEPT": [ + "EXCEPT", + 1 + ], + "INTERSECT": [ + "INTERSECT", + 1 + ], + "_END_OPTIONS": [ + "_END_OPTIONS", + 1 + ] + }, + "expr": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "ALLOWED_KEYWORDS": { + "AS": 1, + "DUAL": 1, + "NULL": 1, + "REGEXP": 1, + "CASE": 1, + "DIV": 1, + "AND": 1, + "OR": 1, + "XOR": 1, + "NOT": 1, + "MOD": 1, + "OVER": 2 + }, + "database": null, + "table": null, + "column": null, + "expr": "1", + "alias": null, + "function": null, + "subquery": null + } + ], + "from": [], + "index_hints": null, + "partition": null, + "where": null, + "group": null, + "having": null, + "order": null, + "limit": null, + "procedure": null, + "into": null, + "join": null, + "union": [ + [ + "UNION ALL", + { + "@type": "PhpMyAdmin\\SqlParser\\Statements\\SelectStatement", + "OPTIONS": { + "ALL": 1, + "DISTINCT": 1, + "DISTINCTROW": 1, + "HIGH_PRIORITY": 2, + "MAX_STATEMENT_TIME": [ + 3, + "var=" + ], + "STRAIGHT_JOIN": 4, + "SQL_SMALL_RESULT": 5, + "SQL_BIG_RESULT": 6, + "SQL_BUFFER_RESULT": 7, + "SQL_CACHE": 8, + "SQL_NO_CACHE": 8, + "SQL_CALC_FOUND_ROWS": 9 + }, + "END_OPTIONS": { + "FOR UPDATE": 1, + "LOCK IN SHARE MODE": 1 + }, + "CLAUSES": { + "SELECT": [ + "SELECT", + 2 + ], + "_OPTIONS": [ + "_OPTIONS", + 1 + ], + "_SELECT": [ + "SELECT", + 1 + ], + "INTO": [ + "INTO", + 3 + ], + "FROM": [ + "FROM", + 3 + ], + "FORCE": [ + "FORCE", + 1 + ], + "USE": [ + "USE", + 1 + ], + "IGNORE": [ + "IGNORE", + 3 + ], + "PARTITION": [ + "PARTITION", + 3 + ], + "JOIN": [ + "JOIN", + 1 + ], + "FULL JOIN": [ + "FULL JOIN", + 1 + ], + "INNER JOIN": [ + "INNER JOIN", + 1 + ], + "LEFT JOIN": [ + "LEFT JOIN", + 1 + ], + "LEFT OUTER JOIN": [ + "LEFT OUTER JOIN", + 1 + ], + "RIGHT JOIN": [ + "RIGHT JOIN", + 1 + ], + "RIGHT OUTER JOIN": [ + "RIGHT OUTER JOIN", + 1 + ], + "NATURAL JOIN": [ + "NATURAL JOIN", + 1 + ], + "NATURAL LEFT JOIN": [ + "NATURAL LEFT JOIN", + 1 + ], + "NATURAL RIGHT JOIN": [ + "NATURAL RIGHT JOIN", + 1 + ], + "NATURAL LEFT OUTER JOIN": [ + "NATURAL LEFT OUTER JOIN", + 1 + ], + "NATURAL RIGHT OUTER JOIN": [ + "NATURAL RIGHT JOIN", + 1 + ], + "WHERE": [ + "WHERE", + 3 + ], + "GROUP BY": [ + "GROUP BY", + 3 + ], + "HAVING": [ + "HAVING", + 3 + ], + "ORDER BY": [ + "ORDER BY", + 3 + ], + "LIMIT": [ + "LIMIT", + 3 + ], + "PROCEDURE": [ + "PROCEDURE", + 3 + ], + "UNION": [ + "UNION", + 1 + ], + "EXCEPT": [ + "EXCEPT", + 1 + ], + "INTERSECT": [ + "INTERSECT", + 1 + ], + "_END_OPTIONS": [ + "_END_OPTIONS", + 1 + ] + }, + "expr": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "ALLOWED_KEYWORDS": { + "AS": 1, + "DUAL": 1, + "NULL": 1, + "REGEXP": 1, + "CASE": 1, + "DIV": 1, + "AND": 1, + "OR": 1, + "XOR": 1, + "NOT": 1, + "MOD": 1, + "OVER": 2 + }, + "database": null, + "table": null, + "column": null, + "expr": "2", + "alias": null, + "function": null, + "subquery": null + } + ], + "from": [], + "index_hints": null, + "partition": null, + "where": null, + "group": null, + "having": null, + "order": [], + "limit": null, + "procedure": null, + "into": null, + "join": null, + "union": [], + "end_options": null, + "options": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "options": [] + }, + "first": 5, + "last": 10 + } + ] + ], + "end_options": null, + "options": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "options": [] + }, + "first": 0, + "last": 10 + } + ], + "brackets": 0, + "strict": false, + "errors": [] + } + } + }, + "END_OPTIONS": [], + "options": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "options": [] + }, + "first": 0, + "last": 45 + } + ], + "brackets": 0, + "strict": false, + "errors": [] + }, + "errors": { + "lexer": [], + "parser": [] + } +} \ No newline at end of file From f1585a9dc8671e8e5eb90b7addf0482c0db50dc6 Mon Sep 17 00:00:00 2001 From: "Fawzi E. Abdulfattah" Date: Tue, 7 Dec 2021 10:07:14 +0200 Subject: [PATCH 10/12] Update the with Build statement to build the cteStatement Signed-off-by: Fawzi E. Abdulfattah --- src/Statements/WithStatement.php | 17 + tests/Builder/CreateStatementTest.php | 17 +- tests/Parser/WithStatementTest.php | 4 +- tests/data/parser/parseCreateViewAsWithAs.out | 3157 +++++++++++++++++ tests/data/parser/parseWithStatement.out | 555 +++ tests/data/parser/parseWithStatement1.out | 555 +++ tests/data/parser/parseWithStatement2.out | 555 +++ tests/data/parser/parseWithStatement3.out | 555 +++ tests/data/parser/parseWithStatement4.out | 1 + tests/data/parser/parseWithStatement5.out | 555 +++ tests/data/parser/parseWithStatement7.out | 687 ++++ tests/data/parser/parseWithStatementErr.out | 1 + tests/data/parser/parseWithStatementErr1.out | 1 + tests/data/parser/parseWithStatementErr2.out | 1 + tests/data/parser/parseWithStatementErr3.out | 1 + tests/data/parser/parseWithStatementErr4.out | 1 + tests/data/parser/parseWithStatementErr5.out | 1 + tests/data/parser/parseWithStatementErr6.out | 1 + tests/data/parser/parseWithStatementErr7.out | 1 + tests/data/parser/parseWithStatementErr8.out | 210 ++ 20 files changed, 6869 insertions(+), 7 deletions(-) diff --git a/src/Statements/WithStatement.php b/src/Statements/WithStatement.php index 23e677019..fc8de2438 100644 --- a/src/Statements/WithStatement.php +++ b/src/Statements/WithStatement.php @@ -60,6 +60,13 @@ final class WithStatement extends Statement /** @var WithKeyword[] */ public $withers = []; + /** + * holds the CTE parser. + * + * @var Parser + */ + public $cteStatementParser; + /** * @param Parser $parser the instance that requests parsing * @param TokensList $list the list of tokens to be parsed @@ -243,8 +250,12 @@ public function parse(Parser $parser, TokensList $list) foreach ($subParser->errors as $error) { $parser->errors[] = $error; } + + break; } + $this->cteStatementParser = $subParser; + $list->idx = $idxOfLastParsedToken; break; } @@ -277,6 +288,12 @@ public function build() $str .= WithKeyword::build($wither); } + $str .= ' '; + + foreach ($this->cteStatementParser->statements as $statement) { + $str .= $statement->build(); + } + return $str; } diff --git a/tests/Builder/CreateStatementTest.php b/tests/Builder/CreateStatementTest.php index 9d5160c0d..8b6a36edc 100644 --- a/tests/Builder/CreateStatementTest.php +++ b/tests/Builder/CreateStatementTest.php @@ -175,7 +175,8 @@ public function testBuilderTable(): void $this->assertEquals( 'CREATE TABLE table_name WITH' . - ' cte(col1) AS (SELECT 1 UNION ALL SELECT 2)', + ' cte(col1) AS (SELECT 1 UNION ALL SELECT 2)' . + ' SELECT col1 FROM cte', $stmt->build() ); } @@ -370,9 +371,12 @@ public function testBuilderViewComplex(): void $this->assertEquals( 'CREATE VIEW withclause AS ' . 'WITH cte AS (' - . 'SELECT p.name, p.shape' - . ' FROM gis_all AS `p`' - . ') ', + . 'SELECT p.name, p.shape ' + . 'FROM gis_all AS `p`' + . ') ' + . 'SELECT cte.* ' + . 'FROM cte ' + . 'CROSS JOIN gis_all ', $stmt->build() ); $parser = new Parser( @@ -400,7 +404,10 @@ public function testBuilderViewComplex(): void . '), cte2 AS (' . 'SELECT p.name AS `n2`, p.shape AS `sh2`' . ' FROM gis_all AS `p`' - . ') ', + . ')' + . ' SELECT cte.*, cte2.* ' + . 'FROM cte, cte2' + . ' CROSS JOIN gis_all ', $stmt->build() ); } diff --git a/tests/Parser/WithStatementTest.php b/tests/Parser/WithStatementTest.php index c5b952930..0aca29809 100644 --- a/tests/Parser/WithStatementTest.php +++ b/tests/Parser/WithStatementTest.php @@ -68,7 +68,7 @@ public function testWith(): void // phpcs:disable Generic.Files.LineLength.TooLong $expected = <<assertEquals($expected, $parser->statements[0]->build()); @@ -110,7 +110,7 @@ public function testWithEmbedParenthesis(): void // phpcs:disable Generic.Files.LineLength.TooLong $expected = <<assertEquals($expected, $parser->statements[0]->build()); diff --git a/tests/data/parser/parseCreateViewAsWithAs.out b/tests/data/parser/parseCreateViewAsWithAs.out index db43cdd6e..a3243fadb 100644 --- a/tests/data/parser/parseCreateViewAsWithAs.out +++ b/tests/data/parser/parseCreateViewAsWithAs.out @@ -2564,6 +2564,3163 @@ } } }, + "cteStatementParser": { + "@type": "PhpMyAdmin\\SqlParser\\Parser", + "STATEMENT_PARSERS": { + "DESCRIBE": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "DESC": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "EXPLAIN": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "FLUSH": "", + "GRANT": "", + "HELP": "", + "SET PASSWORD": "", + "STATUS": "", + "USE": "", + "ANALYZE": "PhpMyAdmin\\SqlParser\\Statements\\AnalyzeStatement", + "BACKUP": "PhpMyAdmin\\SqlParser\\Statements\\BackupStatement", + "CHECK": "PhpMyAdmin\\SqlParser\\Statements\\CheckStatement", + "CHECKSUM": "PhpMyAdmin\\SqlParser\\Statements\\ChecksumStatement", + "OPTIMIZE": "PhpMyAdmin\\SqlParser\\Statements\\OptimizeStatement", + "REPAIR": "PhpMyAdmin\\SqlParser\\Statements\\RepairStatement", + "RESTORE": "PhpMyAdmin\\SqlParser\\Statements\\RestoreStatement", + "SET": "PhpMyAdmin\\SqlParser\\Statements\\SetStatement", + "SHOW": "PhpMyAdmin\\SqlParser\\Statements\\ShowStatement", + "ALTER": "PhpMyAdmin\\SqlParser\\Statements\\AlterStatement", + "CREATE": "PhpMyAdmin\\SqlParser\\Statements\\CreateStatement", + "DROP": "PhpMyAdmin\\SqlParser\\Statements\\DropStatement", + "RENAME": "PhpMyAdmin\\SqlParser\\Statements\\RenameStatement", + "TRUNCATE": "PhpMyAdmin\\SqlParser\\Statements\\TruncateStatement", + "CALL": "PhpMyAdmin\\SqlParser\\Statements\\CallStatement", + "DELETE": "PhpMyAdmin\\SqlParser\\Statements\\DeleteStatement", + "DO": "", + "HANDLER": "", + "INSERT": "PhpMyAdmin\\SqlParser\\Statements\\InsertStatement", + "LOAD DATA": "PhpMyAdmin\\SqlParser\\Statements\\LoadStatement", + "REPLACE": "PhpMyAdmin\\SqlParser\\Statements\\ReplaceStatement", + "SELECT": "PhpMyAdmin\\SqlParser\\Statements\\SelectStatement", + "UPDATE": "PhpMyAdmin\\SqlParser\\Statements\\UpdateStatement", + "WITH": "PhpMyAdmin\\SqlParser\\Statements\\WithStatement", + "DEALLOCATE": "", + "EXECUTE": "", + "PREPARE": "", + "BEGIN": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "COMMIT": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "ROLLBACK": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "START TRANSACTION": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "PURGE": "PhpMyAdmin\\SqlParser\\Statements\\PurgeStatement", + "LOCK": "PhpMyAdmin\\SqlParser\\Statements\\LockStatement", + "UNLOCK": "PhpMyAdmin\\SqlParser\\Statements\\LockStatement" + }, + "KEYWORD_PARSERS": { + "PARTITION BY": [], + "SUBPARTITION BY": [], + "_OPTIONS": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "field": "options" + }, + "_END_OPTIONS": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "field": "end_options" + }, + "INTERSECT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "EXCEPT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION ALL": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION DISTINCT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "ALTER": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "ANALYZE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "BACKUP": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CALL": { + "class": "PhpMyAdmin\\SqlParser\\Components\\FunctionCall", + "field": "call" + }, + "CHECK": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CHECKSUM": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CROSS JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "DROP": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "fields", + "options": { + "parseField": "table" + } + }, + "FORCE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "FROM": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "from", + "options": { + "field": "table" + } + }, + "GROUP BY": { + "class": "PhpMyAdmin\\SqlParser\\Components\\GroupKeyword", + "field": "group" + }, + "HAVING": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "field": "having" + }, + "IGNORE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "INTO": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IntoKeyword", + "field": "into" + }, + "JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LEFT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LEFT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "ON": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "RIGHT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "RIGHT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "INNER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "FULL JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "FULL OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL LEFT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL RIGHT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL LEFT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL RIGHT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "STRAIGHT_JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LIMIT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Limit", + "field": "limit" + }, + "OPTIMIZE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "ORDER BY": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OrderKeyword", + "field": "order" + }, + "PARTITION": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ArrayObj", + "field": "partition" + }, + "PROCEDURE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\FunctionCall", + "field": "procedure" + }, + "RENAME": { + "class": "PhpMyAdmin\\SqlParser\\Components\\RenameOperation", + "field": "renames" + }, + "REPAIR": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "RESTORE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "SET": { + "class": "PhpMyAdmin\\SqlParser\\Components\\SetOperation", + "field": "set" + }, + "SELECT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "expr" + }, + "TRUNCATE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "UPDATE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "USE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "VALUE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Array2d", + "field": "values" + }, + "VALUES": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Array2d", + "field": "values" + }, + "WHERE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "field": "where" + } + }, + "list": { + "@type": "PhpMyAdmin\\SqlParser\\TokensList", + "tokens": [ + { + "@type": "@41" + }, + { + "@type": "@42" + }, + { + "@type": "@43" + }, + { + "@type": "@44" + }, + { + "@type": "@45" + }, + { + "@type": "@46" + }, + { + "@type": "@47" + }, + { + "@type": "@48" + }, + { + "@type": "@49" + }, + { + "@type": "@50" + }, + { + "@type": "@51" + }, + { + "@type": "@52" + }, + { + "@type": "@53" + }, + { + "@type": "@54" + }, + { + "@type": "@55" + }, + { + "@type": "@56" + }, + { + "@type": "@57" + }, + { + "@type": "@58" + }, + { + "@type": "@59" + }, + { + "@type": "@60" + }, + { + "@type": "@61" + }, + { + "@type": "@62" + }, + { + "@type": "@63" + }, + { + "@type": "@64" + }, + { + "@type": "@65" + }, + { + "@type": "@66" + }, + { + "@type": "@67" + }, + { + "@type": "@68" + }, + { + "@type": "@69" + }, + { + "@type": "@70" + }, + { + "@type": "@71" + }, + { + "@type": "@72" + }, + { + "@type": "@73" + }, + { + "@type": "@74" + }, + { + "@type": "@75" + }, + { + "@type": "@76" + }, + { + "@type": "@77" + }, + { + "@type": "@78" + }, + { + "@type": "@79" + }, + { + "@type": "@80" + }, + { + "@type": "@81" + }, + { + "@type": "@82" + }, + { + "@type": "@83" + }, + { + "@type": "@84" + }, + { + "@type": "@85" + }, + { + "@type": "@86" + }, + { + "@type": "@87" + }, + { + "@type": "@88" + }, + { + "@type": "@89" + }, + { + "@type": "@90" + }, + { + "@type": "@91" + }, + { + "@type": "@92" + }, + { + "@type": "@93" + }, + { + "@type": "@94" + }, + { + "@type": "@95" + }, + { + "@type": "@96" + }, + { + "@type": "@97" + }, + { + "@type": "@98" + }, + { + "@type": "@99" + }, + { + "@type": "@100" + }, + { + "@type": "@101" + }, + { + "@type": "@102" + }, + { + "@type": "@103" + }, + { + "@type": "@104" + }, + { + "@type": "@105" + }, + { + "@type": "@106" + }, + { + "@type": "@107" + }, + { + "@type": "@108" + }, + { + "@type": "@109" + }, + { + "@type": "@110" + }, + { + "@type": "@111" + }, + { + "@type": "@112" + }, + { + "@type": "@113" + }, + { + "@type": "@114" + }, + { + "@type": "@115" + }, + { + "@type": "@116" + }, + { + "@type": "@117" + }, + { + "@type": "@118" + }, + { + "@type": "@119" + }, + { + "@type": "@120" + }, + { + "@type": "@121" + }, + { + "@type": "@122" + }, + { + "@type": "@123" + }, + { + "@type": "@124" + }, + { + "@type": "@125" + }, + { + "@type": "@126" + }, + { + "@type": "@127" + }, + { + "@type": "@128" + }, + { + "@type": "@129" + }, + { + "@type": "@130" + }, + { + "@type": "@131" + }, + { + "@type": "@132" + }, + { + "@type": "@133" + }, + { + "@type": "@134" + }, + { + "@type": "@135" + }, + { + "@type": "@136" + }, + { + "@type": "@137" + }, + { + "@type": "@138" + }, + { + "@type": "@139" + }, + { + "@type": "@140" + }, + { + "@type": "@141" + }, + { + "@type": "@142" + }, + { + "@type": "@143" + }, + { + "@type": "@144" + }, + { + "@type": "@145" + }, + { + "@type": "@146" + }, + { + "@type": "@147" + }, + { + "@type": "@148" + }, + { + "@type": "@149" + }, + { + "@type": "@150" + }, + { + "@type": "@151" + } + ], + "count": 111, + "idx": 111 + }, + "statements": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Statements\\SelectStatement", + "OPTIONS": { + "ALL": 1, + "DISTINCT": 1, + "DISTINCTROW": 1, + "HIGH_PRIORITY": 2, + "MAX_STATEMENT_TIME": [ + 3, + "var=" + ], + "STRAIGHT_JOIN": 4, + "SQL_SMALL_RESULT": 5, + "SQL_BIG_RESULT": 6, + "SQL_BUFFER_RESULT": 7, + "SQL_CACHE": 8, + "SQL_NO_CACHE": 8, + "SQL_CALC_FOUND_ROWS": 9 + }, + "END_OPTIONS": { + "FOR UPDATE": 1, + "LOCK IN SHARE MODE": 1 + }, + "CLAUSES": { + "SELECT": [ + "SELECT", + 2 + ], + "_OPTIONS": [ + "_OPTIONS", + 1 + ], + "_SELECT": [ + "SELECT", + 1 + ], + "INTO": [ + "INTO", + 3 + ], + "FROM": [ + "FROM", + 3 + ], + "FORCE": [ + "FORCE", + 1 + ], + "USE": [ + "USE", + 1 + ], + "IGNORE": [ + "IGNORE", + 3 + ], + "PARTITION": [ + "PARTITION", + 3 + ], + "JOIN": [ + "JOIN", + 1 + ], + "FULL JOIN": [ + "FULL JOIN", + 1 + ], + "INNER JOIN": [ + "INNER JOIN", + 1 + ], + "LEFT JOIN": [ + "LEFT JOIN", + 1 + ], + "LEFT OUTER JOIN": [ + "LEFT OUTER JOIN", + 1 + ], + "RIGHT JOIN": [ + "RIGHT JOIN", + 1 + ], + "RIGHT OUTER JOIN": [ + "RIGHT OUTER JOIN", + 1 + ], + "NATURAL JOIN": [ + "NATURAL JOIN", + 1 + ], + "NATURAL LEFT JOIN": [ + "NATURAL LEFT JOIN", + 1 + ], + "NATURAL RIGHT JOIN": [ + "NATURAL RIGHT JOIN", + 1 + ], + "NATURAL LEFT OUTER JOIN": [ + "NATURAL LEFT OUTER JOIN", + 1 + ], + "NATURAL RIGHT OUTER JOIN": [ + "NATURAL RIGHT JOIN", + 1 + ], + "WHERE": [ + "WHERE", + 3 + ], + "GROUP BY": [ + "GROUP BY", + 3 + ], + "HAVING": [ + "HAVING", + 3 + ], + "ORDER BY": [ + "ORDER BY", + 3 + ], + "LIMIT": [ + "LIMIT", + 3 + ], + "PROCEDURE": [ + "PROCEDURE", + 3 + ], + "UNION": [ + "UNION", + 1 + ], + "EXCEPT": [ + "EXCEPT", + 1 + ], + "INTERSECT": [ + "INTERSECT", + 1 + ], + "_END_OPTIONS": [ + "_END_OPTIONS", + 1 + ] + }, + "expr": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "ALLOWED_KEYWORDS": { + "AS": 1, + "DUAL": 1, + "NULL": 1, + "REGEXP": 1, + "CASE": 1, + "DIV": 1, + "AND": 1, + "OR": 1, + "XOR": 1, + "NOT": 1, + "MOD": 1, + "OVER": 2 + }, + "database": null, + "table": "cte", + "column": null, + "expr": "cte.*", + "alias": null, + "function": null, + "subquery": null + } + ], + "from": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "ALLOWED_KEYWORDS": { + "AS": 1, + "DUAL": 1, + "NULL": 1, + "REGEXP": 1, + "CASE": 1, + "DIV": 1, + "AND": 1, + "OR": 1, + "XOR": 1, + "NOT": 1, + "MOD": 1, + "OVER": 2 + }, + "database": null, + "table": "cte", + "column": null, + "expr": "cte", + "alias": null, + "function": null, + "subquery": null + } + ], + "index_hints": null, + "partition": null, + "where": null, + "group": null, + "having": null, + "order": null, + "limit": null, + "procedure": null, + "into": null, + "join": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "JOINS": { + "CROSS JOIN": "CROSS", + "FULL JOIN": "FULL", + "FULL OUTER JOIN": "FULL", + "INNER JOIN": "INNER", + "JOIN": "JOIN", + "LEFT JOIN": "LEFT", + "LEFT OUTER JOIN": "LEFT", + "RIGHT JOIN": "RIGHT", + "RIGHT OUTER JOIN": "RIGHT", + "NATURAL JOIN": "NATURAL", + "NATURAL LEFT JOIN": "NATURAL LEFT", + "NATURAL RIGHT JOIN": "NATURAL RIGHT", + "NATURAL LEFT OUTER JOIN": "NATURAL LEFT OUTER", + "NATURAL RIGHT OUTER JOIN": "NATURAL RIGHT OUTER", + "STRAIGHT_JOIN": "STRAIGHT" + }, + "type": "CROSS", + "expr": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "ALLOWED_KEYWORDS": { + "AS": 1, + "DUAL": 1, + "NULL": 1, + "REGEXP": 1, + "CASE": 1, + "DIV": 1, + "AND": 1, + "OR": 1, + "XOR": 1, + "NOT": 1, + "MOD": 1, + "OVER": 2 + }, + "database": null, + "table": "gis_all", + "column": null, + "expr": "gis_all", + "alias": null, + "function": null, + "subquery": null + }, + "on": null, + "using": null + } + ], + "union": [], + "end_options": null, + "options": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "options": [] + }, + "first": 0, + "last": 12 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Statements\\CreateStatement", + "OPTIONS": { + "TEMPORARY": 1, + "OR REPLACE": 2, + "ALGORITHM": [ + 3, + "var=" + ], + "DEFINER": [ + 4, + "expr=" + ], + "SQL SECURITY": [ + 5, + "var" + ], + "DATABASE": 6, + "EVENT": 6, + "FUNCTION": 6, + "INDEX": 6, + "UNIQUE INDEX": 6, + "FULLTEXT INDEX": 6, + "SPATIAL INDEX": 6, + "PROCEDURE": 6, + "SERVER": 6, + "TABLE": 6, + "TABLESPACE": 6, + "TRIGGER": 6, + "USER": 6, + "VIEW": 6, + "SCHEMA": 6, + "IF NOT EXISTS": 7 + }, + "DB_OPTIONS": { + "CHARACTER SET": [ + 1, + "var=" + ], + "CHARSET": [ + 1, + "var=" + ], + "DEFAULT CHARACTER SET": [ + 1, + "var=" + ], + "DEFAULT CHARSET": [ + 1, + "var=" + ], + "DEFAULT COLLATE": [ + 2, + "var=" + ], + "COLLATE": [ + 2, + "var=" + ] + }, + "TABLE_OPTIONS": { + "ENGINE": [ + 1, + "var=" + ], + "AUTO_INCREMENT": [ + 2, + "var=" + ], + "AVG_ROW_LENGTH": [ + 3, + "var" + ], + "CHARACTER SET": [ + 4, + "var=" + ], + "CHARSET": [ + 4, + "var=" + ], + "DEFAULT CHARACTER SET": [ + 4, + "var=" + ], + "DEFAULT CHARSET": [ + 4, + "var=" + ], + "CHECKSUM": [ + 5, + "var" + ], + "DEFAULT COLLATE": [ + 6, + "var=" + ], + "COLLATE": [ + 6, + "var=" + ], + "COMMENT": [ + 7, + "var=" + ], + "CONNECTION": [ + 8, + "var" + ], + "DATA DIRECTORY": [ + 9, + "var" + ], + "DELAY_KEY_WRITE": [ + 10, + "var" + ], + "INDEX DIRECTORY": [ + 11, + "var" + ], + "INSERT_METHOD": [ + 12, + "var" + ], + "KEY_BLOCK_SIZE": [ + 13, + "var" + ], + "MAX_ROWS": [ + 14, + "var" + ], + "MIN_ROWS": [ + 15, + "var" + ], + "PACK_KEYS": [ + 16, + "var" + ], + "PASSWORD": [ + 17, + "var" + ], + "ROW_FORMAT": [ + 18, + "var" + ], + "TABLESPACE": [ + 19, + "var" + ], + "STORAGE": [ + 20, + "var" + ], + "UNION": [ + 21, + "var" + ] + }, + "FUNC_OPTIONS": { + "NOT": [ + 2, + "var" + ], + "FUNCTION": [ + 3, + "var=" + ], + "PROCEDURE": [ + 3, + "var=" + ], + "CONTAINS": [ + 4, + "expr" + ], + "NO": [ + 4, + "var" + ], + "READS": [ + 4, + "var" + ], + "MODIFIES": [ + 4, + "expr" + ], + "SQL SECURITY": [ + 6, + "var" + ], + "LANGUAGE": [ + 7, + "var" + ], + "COMMENT": [ + 8, + "var" + ], + "CREATE": 1, + "DETERMINISTIC": 2, + "DATA": 5 + }, + "TRIGGER_OPTIONS": { + "BEFORE": 1, + "AFTER": 1, + "INSERT": 2, + "UPDATE": 2, + "DELETE": 2 + }, + "name": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "ALLOWED_KEYWORDS": { + "AS": 1, + "DUAL": 1, + "NULL": 1, + "REGEXP": 1, + "CASE": 1, + "DIV": 1, + "AND": 1, + "OR": 1, + "XOR": 1, + "NOT": 1, + "MOD": 1, + "OVER": 2 + }, + "database": null, + "table": "withclause2", + "column": null, + "expr": "withclause2", + "alias": null, + "function": null, + "subquery": null + }, + "entityOptions": null, + "fields": null, + "with": { + "@type": "PhpMyAdmin\\SqlParser\\Statements\\WithStatement", + "OPTIONS": { + "RECURSIVE": 1 + }, + "CLAUSES": { + "WITH": [ + "WITH", + 2 + ], + "_OPTIONS": [ + "_OPTIONS", + 1 + ], + "AS": [ + "AS", + 2 + ] + }, + "withers": { + "cte": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\WithKeyword", + "name": "cte", + "columns": [], + "statement": { + "@type": "PhpMyAdmin\\SqlParser\\Parser", + "STATEMENT_PARSERS": { + "DESCRIBE": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "DESC": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "EXPLAIN": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "FLUSH": "", + "GRANT": "", + "HELP": "", + "SET PASSWORD": "", + "STATUS": "", + "USE": "", + "ANALYZE": "PhpMyAdmin\\SqlParser\\Statements\\AnalyzeStatement", + "BACKUP": "PhpMyAdmin\\SqlParser\\Statements\\BackupStatement", + "CHECK": "PhpMyAdmin\\SqlParser\\Statements\\CheckStatement", + "CHECKSUM": "PhpMyAdmin\\SqlParser\\Statements\\ChecksumStatement", + "OPTIMIZE": "PhpMyAdmin\\SqlParser\\Statements\\OptimizeStatement", + "REPAIR": "PhpMyAdmin\\SqlParser\\Statements\\RepairStatement", + "RESTORE": "PhpMyAdmin\\SqlParser\\Statements\\RestoreStatement", + "SET": "PhpMyAdmin\\SqlParser\\Statements\\SetStatement", + "SHOW": "PhpMyAdmin\\SqlParser\\Statements\\ShowStatement", + "ALTER": "PhpMyAdmin\\SqlParser\\Statements\\AlterStatement", + "CREATE": "PhpMyAdmin\\SqlParser\\Statements\\CreateStatement", + "DROP": "PhpMyAdmin\\SqlParser\\Statements\\DropStatement", + "RENAME": "PhpMyAdmin\\SqlParser\\Statements\\RenameStatement", + "TRUNCATE": "PhpMyAdmin\\SqlParser\\Statements\\TruncateStatement", + "CALL": "PhpMyAdmin\\SqlParser\\Statements\\CallStatement", + "DELETE": "PhpMyAdmin\\SqlParser\\Statements\\DeleteStatement", + "DO": "", + "HANDLER": "", + "INSERT": "PhpMyAdmin\\SqlParser\\Statements\\InsertStatement", + "LOAD DATA": "PhpMyAdmin\\SqlParser\\Statements\\LoadStatement", + "REPLACE": "PhpMyAdmin\\SqlParser\\Statements\\ReplaceStatement", + "SELECT": "PhpMyAdmin\\SqlParser\\Statements\\SelectStatement", + "UPDATE": "PhpMyAdmin\\SqlParser\\Statements\\UpdateStatement", + "WITH": "PhpMyAdmin\\SqlParser\\Statements\\WithStatement", + "DEALLOCATE": "", + "EXECUTE": "", + "PREPARE": "", + "BEGIN": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "COMMIT": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "ROLLBACK": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "START TRANSACTION": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "PURGE": "PhpMyAdmin\\SqlParser\\Statements\\PurgeStatement", + "LOCK": "PhpMyAdmin\\SqlParser\\Statements\\LockStatement", + "UNLOCK": "PhpMyAdmin\\SqlParser\\Statements\\LockStatement" + }, + "KEYWORD_PARSERS": { + "PARTITION BY": [], + "SUBPARTITION BY": [], + "_OPTIONS": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "field": "options" + }, + "_END_OPTIONS": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "field": "end_options" + }, + "INTERSECT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "EXCEPT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION ALL": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION DISTINCT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "ALTER": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "ANALYZE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "BACKUP": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CALL": { + "class": "PhpMyAdmin\\SqlParser\\Components\\FunctionCall", + "field": "call" + }, + "CHECK": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CHECKSUM": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CROSS JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "DROP": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "fields", + "options": { + "parseField": "table" + } + }, + "FORCE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "FROM": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "from", + "options": { + "field": "table" + } + }, + "GROUP BY": { + "class": "PhpMyAdmin\\SqlParser\\Components\\GroupKeyword", + "field": "group" + }, + "HAVING": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "field": "having" + }, + "IGNORE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "INTO": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IntoKeyword", + "field": "into" + }, + "JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LEFT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LEFT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "ON": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "RIGHT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "RIGHT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "INNER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "FULL JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "FULL OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL LEFT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL RIGHT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL LEFT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL RIGHT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "STRAIGHT_JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LIMIT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Limit", + "field": "limit" + }, + "OPTIMIZE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "ORDER BY": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OrderKeyword", + "field": "order" + }, + "PARTITION": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ArrayObj", + "field": "partition" + }, + "PROCEDURE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\FunctionCall", + "field": "procedure" + }, + "RENAME": { + "class": "PhpMyAdmin\\SqlParser\\Components\\RenameOperation", + "field": "renames" + }, + "REPAIR": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "RESTORE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "SET": { + "class": "PhpMyAdmin\\SqlParser\\Components\\SetOperation", + "field": "set" + }, + "SELECT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "expr" + }, + "TRUNCATE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "UPDATE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "USE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "VALUE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Array2d", + "field": "values" + }, + "VALUES": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Array2d", + "field": "values" + }, + "WHERE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "field": "where" + } + }, + "list": { + "@type": "PhpMyAdmin\\SqlParser\\TokensList", + "tokens": [ + { + "@type": "@73" + }, + { + "@type": "@74" + }, + { + "@type": "@75" + }, + { + "@type": "@76" + }, + { + "@type": "@77" + }, + { + "@type": "@78" + }, + { + "@type": "@79" + }, + { + "@type": "@80" + }, + { + "@type": "@81" + }, + { + "@type": "@82" + }, + { + "@type": "@83" + }, + { + "@type": "@84" + }, + { + "@type": "@85" + }, + { + "@type": "@86" + }, + { + "@type": "@87" + }, + { + "@type": "@88" + }, + { + "@type": "@89" + }, + { + "@type": "@90" + }, + { + "@type": "@91" + }, + { + "@type": "@92" + } + ], + "count": 20, + "idx": 20 + }, + "statements": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Statements\\SelectStatement", + "OPTIONS": { + "ALL": 1, + "DISTINCT": 1, + "DISTINCTROW": 1, + "HIGH_PRIORITY": 2, + "MAX_STATEMENT_TIME": [ + 3, + "var=" + ], + "STRAIGHT_JOIN": 4, + "SQL_SMALL_RESULT": 5, + "SQL_BIG_RESULT": 6, + "SQL_BUFFER_RESULT": 7, + "SQL_CACHE": 8, + "SQL_NO_CACHE": 8, + "SQL_CALC_FOUND_ROWS": 9 + }, + "END_OPTIONS": { + "FOR UPDATE": 1, + "LOCK IN SHARE MODE": 1 + }, + "CLAUSES": { + "SELECT": [ + "SELECT", + 2 + ], + "_OPTIONS": [ + "_OPTIONS", + 1 + ], + "_SELECT": [ + "SELECT", + 1 + ], + "INTO": [ + "INTO", + 3 + ], + "FROM": [ + "FROM", + 3 + ], + "FORCE": [ + "FORCE", + 1 + ], + "USE": [ + "USE", + 1 + ], + "IGNORE": [ + "IGNORE", + 3 + ], + "PARTITION": [ + "PARTITION", + 3 + ], + "JOIN": [ + "JOIN", + 1 + ], + "FULL JOIN": [ + "FULL JOIN", + 1 + ], + "INNER JOIN": [ + "INNER JOIN", + 1 + ], + "LEFT JOIN": [ + "LEFT JOIN", + 1 + ], + "LEFT OUTER JOIN": [ + "LEFT OUTER JOIN", + 1 + ], + "RIGHT JOIN": [ + "RIGHT JOIN", + 1 + ], + "RIGHT OUTER JOIN": [ + "RIGHT OUTER JOIN", + 1 + ], + "NATURAL JOIN": [ + "NATURAL JOIN", + 1 + ], + "NATURAL LEFT JOIN": [ + "NATURAL LEFT JOIN", + 1 + ], + "NATURAL RIGHT JOIN": [ + "NATURAL RIGHT JOIN", + 1 + ], + "NATURAL LEFT OUTER JOIN": [ + "NATURAL LEFT OUTER JOIN", + 1 + ], + "NATURAL RIGHT OUTER JOIN": [ + "NATURAL RIGHT JOIN", + 1 + ], + "WHERE": [ + "WHERE", + 3 + ], + "GROUP BY": [ + "GROUP BY", + 3 + ], + "HAVING": [ + "HAVING", + 3 + ], + "ORDER BY": [ + "ORDER BY", + 3 + ], + "LIMIT": [ + "LIMIT", + 3 + ], + "PROCEDURE": [ + "PROCEDURE", + 3 + ], + "UNION": [ + "UNION", + 1 + ], + "EXCEPT": [ + "EXCEPT", + 1 + ], + "INTERSECT": [ + "INTERSECT", + 1 + ], + "_END_OPTIONS": [ + "_END_OPTIONS", + 1 + ] + }, + "expr": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "ALLOWED_KEYWORDS": { + "AS": 1, + "DUAL": 1, + "NULL": 1, + "REGEXP": 1, + "CASE": 1, + "DIV": 1, + "AND": 1, + "OR": 1, + "XOR": 1, + "NOT": 1, + "MOD": 1, + "OVER": 2 + }, + "database": null, + "table": "p", + "column": "name", + "expr": "p.name", + "alias": null, + "function": null, + "subquery": null + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "ALLOWED_KEYWORDS": { + "AS": 1, + "DUAL": 1, + "NULL": 1, + "REGEXP": 1, + "CASE": 1, + "DIV": 1, + "AND": 1, + "OR": 1, + "XOR": 1, + "NOT": 1, + "MOD": 1, + "OVER": 2 + }, + "database": null, + "table": "p", + "column": "shape", + "expr": "p.shape", + "alias": null, + "function": null, + "subquery": null + } + ], + "from": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "ALLOWED_KEYWORDS": { + "AS": 1, + "DUAL": 1, + "NULL": 1, + "REGEXP": 1, + "CASE": 1, + "DIV": 1, + "AND": 1, + "OR": 1, + "XOR": 1, + "NOT": 1, + "MOD": 1, + "OVER": 2 + }, + "database": null, + "table": "gis_all", + "column": null, + "expr": "gis_all", + "alias": "p", + "function": null, + "subquery": null + } + ], + "index_hints": null, + "partition": null, + "where": null, + "group": null, + "having": null, + "order": null, + "limit": null, + "procedure": null, + "into": null, + "join": null, + "union": [], + "end_options": null, + "options": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "options": [] + }, + "first": 0, + "last": 19 + } + ], + "brackets": 0, + "strict": false, + "errors": [] + } + }, + "cte2": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\WithKeyword", + "name": "cte2", + "columns": [], + "statement": { + "@type": "PhpMyAdmin\\SqlParser\\Parser", + "STATEMENT_PARSERS": { + "DESCRIBE": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "DESC": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "EXPLAIN": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "FLUSH": "", + "GRANT": "", + "HELP": "", + "SET PASSWORD": "", + "STATUS": "", + "USE": "", + "ANALYZE": "PhpMyAdmin\\SqlParser\\Statements\\AnalyzeStatement", + "BACKUP": "PhpMyAdmin\\SqlParser\\Statements\\BackupStatement", + "CHECK": "PhpMyAdmin\\SqlParser\\Statements\\CheckStatement", + "CHECKSUM": "PhpMyAdmin\\SqlParser\\Statements\\ChecksumStatement", + "OPTIMIZE": "PhpMyAdmin\\SqlParser\\Statements\\OptimizeStatement", + "REPAIR": "PhpMyAdmin\\SqlParser\\Statements\\RepairStatement", + "RESTORE": "PhpMyAdmin\\SqlParser\\Statements\\RestoreStatement", + "SET": "PhpMyAdmin\\SqlParser\\Statements\\SetStatement", + "SHOW": "PhpMyAdmin\\SqlParser\\Statements\\ShowStatement", + "ALTER": "PhpMyAdmin\\SqlParser\\Statements\\AlterStatement", + "CREATE": "PhpMyAdmin\\SqlParser\\Statements\\CreateStatement", + "DROP": "PhpMyAdmin\\SqlParser\\Statements\\DropStatement", + "RENAME": "PhpMyAdmin\\SqlParser\\Statements\\RenameStatement", + "TRUNCATE": "PhpMyAdmin\\SqlParser\\Statements\\TruncateStatement", + "CALL": "PhpMyAdmin\\SqlParser\\Statements\\CallStatement", + "DELETE": "PhpMyAdmin\\SqlParser\\Statements\\DeleteStatement", + "DO": "", + "HANDLER": "", + "INSERT": "PhpMyAdmin\\SqlParser\\Statements\\InsertStatement", + "LOAD DATA": "PhpMyAdmin\\SqlParser\\Statements\\LoadStatement", + "REPLACE": "PhpMyAdmin\\SqlParser\\Statements\\ReplaceStatement", + "SELECT": "PhpMyAdmin\\SqlParser\\Statements\\SelectStatement", + "UPDATE": "PhpMyAdmin\\SqlParser\\Statements\\UpdateStatement", + "WITH": "PhpMyAdmin\\SqlParser\\Statements\\WithStatement", + "DEALLOCATE": "", + "EXECUTE": "", + "PREPARE": "", + "BEGIN": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "COMMIT": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "ROLLBACK": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "START TRANSACTION": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "PURGE": "PhpMyAdmin\\SqlParser\\Statements\\PurgeStatement", + "LOCK": "PhpMyAdmin\\SqlParser\\Statements\\LockStatement", + "UNLOCK": "PhpMyAdmin\\SqlParser\\Statements\\LockStatement" + }, + "KEYWORD_PARSERS": { + "PARTITION BY": [], + "SUBPARTITION BY": [], + "_OPTIONS": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "field": "options" + }, + "_END_OPTIONS": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "field": "end_options" + }, + "INTERSECT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "EXCEPT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION ALL": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION DISTINCT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "ALTER": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "ANALYZE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "BACKUP": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CALL": { + "class": "PhpMyAdmin\\SqlParser\\Components\\FunctionCall", + "field": "call" + }, + "CHECK": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CHECKSUM": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CROSS JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "DROP": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "fields", + "options": { + "parseField": "table" + } + }, + "FORCE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "FROM": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "from", + "options": { + "field": "table" + } + }, + "GROUP BY": { + "class": "PhpMyAdmin\\SqlParser\\Components\\GroupKeyword", + "field": "group" + }, + "HAVING": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "field": "having" + }, + "IGNORE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "INTO": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IntoKeyword", + "field": "into" + }, + "JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LEFT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LEFT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "ON": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "RIGHT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "RIGHT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "INNER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "FULL JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "FULL OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL LEFT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL RIGHT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL LEFT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL RIGHT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "STRAIGHT_JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LIMIT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Limit", + "field": "limit" + }, + "OPTIMIZE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "ORDER BY": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OrderKeyword", + "field": "order" + }, + "PARTITION": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ArrayObj", + "field": "partition" + }, + "PROCEDURE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\FunctionCall", + "field": "procedure" + }, + "RENAME": { + "class": "PhpMyAdmin\\SqlParser\\Components\\RenameOperation", + "field": "renames" + }, + "REPAIR": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "RESTORE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "SET": { + "class": "PhpMyAdmin\\SqlParser\\Components\\SetOperation", + "field": "set" + }, + "SELECT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "expr" + }, + "TRUNCATE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "UPDATE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "USE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "VALUE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Array2d", + "field": "values" + }, + "VALUES": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Array2d", + "field": "values" + }, + "WHERE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "field": "where" + } + }, + "list": { + "@type": "PhpMyAdmin\\SqlParser\\TokensList", + "tokens": [ + { + "@type": "@101" + }, + { + "@type": "@102" + }, + { + "@type": "@103" + }, + { + "@type": "@104" + }, + { + "@type": "@105" + }, + { + "@type": "@106" + }, + { + "@type": "@107" + }, + { + "@type": "@108" + }, + { + "@type": "@109" + }, + { + "@type": "@110" + }, + { + "@type": "@111" + }, + { + "@type": "@112" + }, + { + "@type": "@113" + }, + { + "@type": "@114" + }, + { + "@type": "@115" + }, + { + "@type": "@116" + }, + { + "@type": "@117" + }, + { + "@type": "@118" + }, + { + "@type": "@119" + }, + { + "@type": "@120" + }, + { + "@type": "@121" + }, + { + "@type": "@122" + }, + { + "@type": "@123" + }, + { + "@type": "@124" + }, + { + "@type": "@125" + }, + { + "@type": "@126" + }, + { + "@type": "@127" + }, + { + "@type": "@128" + } + ], + "count": 28, + "idx": 28 + }, + "statements": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Statements\\SelectStatement", + "OPTIONS": { + "ALL": 1, + "DISTINCT": 1, + "DISTINCTROW": 1, + "HIGH_PRIORITY": 2, + "MAX_STATEMENT_TIME": [ + 3, + "var=" + ], + "STRAIGHT_JOIN": 4, + "SQL_SMALL_RESULT": 5, + "SQL_BIG_RESULT": 6, + "SQL_BUFFER_RESULT": 7, + "SQL_CACHE": 8, + "SQL_NO_CACHE": 8, + "SQL_CALC_FOUND_ROWS": 9 + }, + "END_OPTIONS": { + "FOR UPDATE": 1, + "LOCK IN SHARE MODE": 1 + }, + "CLAUSES": { + "SELECT": [ + "SELECT", + 2 + ], + "_OPTIONS": [ + "_OPTIONS", + 1 + ], + "_SELECT": [ + "SELECT", + 1 + ], + "INTO": [ + "INTO", + 3 + ], + "FROM": [ + "FROM", + 3 + ], + "FORCE": [ + "FORCE", + 1 + ], + "USE": [ + "USE", + 1 + ], + "IGNORE": [ + "IGNORE", + 3 + ], + "PARTITION": [ + "PARTITION", + 3 + ], + "JOIN": [ + "JOIN", + 1 + ], + "FULL JOIN": [ + "FULL JOIN", + 1 + ], + "INNER JOIN": [ + "INNER JOIN", + 1 + ], + "LEFT JOIN": [ + "LEFT JOIN", + 1 + ], + "LEFT OUTER JOIN": [ + "LEFT OUTER JOIN", + 1 + ], + "RIGHT JOIN": [ + "RIGHT JOIN", + 1 + ], + "RIGHT OUTER JOIN": [ + "RIGHT OUTER JOIN", + 1 + ], + "NATURAL JOIN": [ + "NATURAL JOIN", + 1 + ], + "NATURAL LEFT JOIN": [ + "NATURAL LEFT JOIN", + 1 + ], + "NATURAL RIGHT JOIN": [ + "NATURAL RIGHT JOIN", + 1 + ], + "NATURAL LEFT OUTER JOIN": [ + "NATURAL LEFT OUTER JOIN", + 1 + ], + "NATURAL RIGHT OUTER JOIN": [ + "NATURAL RIGHT JOIN", + 1 + ], + "WHERE": [ + "WHERE", + 3 + ], + "GROUP BY": [ + "GROUP BY", + 3 + ], + "HAVING": [ + "HAVING", + 3 + ], + "ORDER BY": [ + "ORDER BY", + 3 + ], + "LIMIT": [ + "LIMIT", + 3 + ], + "PROCEDURE": [ + "PROCEDURE", + 3 + ], + "UNION": [ + "UNION", + 1 + ], + "EXCEPT": [ + "EXCEPT", + 1 + ], + "INTERSECT": [ + "INTERSECT", + 1 + ], + "_END_OPTIONS": [ + "_END_OPTIONS", + 1 + ] + }, + "expr": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "ALLOWED_KEYWORDS": { + "AS": 1, + "DUAL": 1, + "NULL": 1, + "REGEXP": 1, + "CASE": 1, + "DIV": 1, + "AND": 1, + "OR": 1, + "XOR": 1, + "NOT": 1, + "MOD": 1, + "OVER": 2 + }, + "database": null, + "table": "p", + "column": "name", + "expr": "p.name", + "alias": "n2", + "function": null, + "subquery": null + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "ALLOWED_KEYWORDS": { + "AS": 1, + "DUAL": 1, + "NULL": 1, + "REGEXP": 1, + "CASE": 1, + "DIV": 1, + "AND": 1, + "OR": 1, + "XOR": 1, + "NOT": 1, + "MOD": 1, + "OVER": 2 + }, + "database": null, + "table": "p", + "column": "shape", + "expr": "p.shape", + "alias": "sh2", + "function": null, + "subquery": null + } + ], + "from": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "ALLOWED_KEYWORDS": { + "AS": 1, + "DUAL": 1, + "NULL": 1, + "REGEXP": 1, + "CASE": 1, + "DIV": 1, + "AND": 1, + "OR": 1, + "XOR": 1, + "NOT": 1, + "MOD": 1, + "OVER": 2 + }, + "database": null, + "table": "gis_all", + "column": null, + "expr": "gis_all", + "alias": "p", + "function": null, + "subquery": null + } + ], + "index_hints": null, + "partition": null, + "where": null, + "group": null, + "having": null, + "order": null, + "limit": null, + "procedure": null, + "into": null, + "join": null, + "union": [], + "end_options": null, + "options": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "options": [] + }, + "first": 0, + "last": 27 + } + ], + "brackets": 0, + "strict": false, + "errors": [] + } + } + }, + "cteStatementParser": { + "@type": "PhpMyAdmin\\SqlParser\\Parser", + "STATEMENT_PARSERS": { + "DESCRIBE": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "DESC": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "EXPLAIN": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "FLUSH": "", + "GRANT": "", + "HELP": "", + "SET PASSWORD": "", + "STATUS": "", + "USE": "", + "ANALYZE": "PhpMyAdmin\\SqlParser\\Statements\\AnalyzeStatement", + "BACKUP": "PhpMyAdmin\\SqlParser\\Statements\\BackupStatement", + "CHECK": "PhpMyAdmin\\SqlParser\\Statements\\CheckStatement", + "CHECKSUM": "PhpMyAdmin\\SqlParser\\Statements\\ChecksumStatement", + "OPTIMIZE": "PhpMyAdmin\\SqlParser\\Statements\\OptimizeStatement", + "REPAIR": "PhpMyAdmin\\SqlParser\\Statements\\RepairStatement", + "RESTORE": "PhpMyAdmin\\SqlParser\\Statements\\RestoreStatement", + "SET": "PhpMyAdmin\\SqlParser\\Statements\\SetStatement", + "SHOW": "PhpMyAdmin\\SqlParser\\Statements\\ShowStatement", + "ALTER": "PhpMyAdmin\\SqlParser\\Statements\\AlterStatement", + "CREATE": "PhpMyAdmin\\SqlParser\\Statements\\CreateStatement", + "DROP": "PhpMyAdmin\\SqlParser\\Statements\\DropStatement", + "RENAME": "PhpMyAdmin\\SqlParser\\Statements\\RenameStatement", + "TRUNCATE": "PhpMyAdmin\\SqlParser\\Statements\\TruncateStatement", + "CALL": "PhpMyAdmin\\SqlParser\\Statements\\CallStatement", + "DELETE": "PhpMyAdmin\\SqlParser\\Statements\\DeleteStatement", + "DO": "", + "HANDLER": "", + "INSERT": "PhpMyAdmin\\SqlParser\\Statements\\InsertStatement", + "LOAD DATA": "PhpMyAdmin\\SqlParser\\Statements\\LoadStatement", + "REPLACE": "PhpMyAdmin\\SqlParser\\Statements\\ReplaceStatement", + "SELECT": "PhpMyAdmin\\SqlParser\\Statements\\SelectStatement", + "UPDATE": "PhpMyAdmin\\SqlParser\\Statements\\UpdateStatement", + "WITH": "PhpMyAdmin\\SqlParser\\Statements\\WithStatement", + "DEALLOCATE": "", + "EXECUTE": "", + "PREPARE": "", + "BEGIN": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "COMMIT": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "ROLLBACK": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "START TRANSACTION": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "PURGE": "PhpMyAdmin\\SqlParser\\Statements\\PurgeStatement", + "LOCK": "PhpMyAdmin\\SqlParser\\Statements\\LockStatement", + "UNLOCK": "PhpMyAdmin\\SqlParser\\Statements\\LockStatement" + }, + "KEYWORD_PARSERS": { + "PARTITION BY": [], + "SUBPARTITION BY": [], + "_OPTIONS": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "field": "options" + }, + "_END_OPTIONS": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "field": "end_options" + }, + "INTERSECT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "EXCEPT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION ALL": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION DISTINCT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "ALTER": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "ANALYZE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "BACKUP": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CALL": { + "class": "PhpMyAdmin\\SqlParser\\Components\\FunctionCall", + "field": "call" + }, + "CHECK": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CHECKSUM": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CROSS JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "DROP": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "fields", + "options": { + "parseField": "table" + } + }, + "FORCE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "FROM": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "from", + "options": { + "field": "table" + } + }, + "GROUP BY": { + "class": "PhpMyAdmin\\SqlParser\\Components\\GroupKeyword", + "field": "group" + }, + "HAVING": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "field": "having" + }, + "IGNORE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "INTO": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IntoKeyword", + "field": "into" + }, + "JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LEFT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LEFT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "ON": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "RIGHT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "RIGHT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "INNER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "FULL JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "FULL OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL LEFT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL RIGHT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL LEFT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL RIGHT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "STRAIGHT_JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LIMIT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Limit", + "field": "limit" + }, + "OPTIMIZE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "ORDER BY": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OrderKeyword", + "field": "order" + }, + "PARTITION": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ArrayObj", + "field": "partition" + }, + "PROCEDURE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\FunctionCall", + "field": "procedure" + }, + "RENAME": { + "class": "PhpMyAdmin\\SqlParser\\Components\\RenameOperation", + "field": "renames" + }, + "REPAIR": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "RESTORE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "SET": { + "class": "PhpMyAdmin\\SqlParser\\Components\\SetOperation", + "field": "set" + }, + "SELECT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "expr" + }, + "TRUNCATE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "UPDATE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "USE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "VALUE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Array2d", + "field": "values" + }, + "VALUES": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Array2d", + "field": "values" + }, + "WHERE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "field": "where" + } + }, + "list": { + "@type": "PhpMyAdmin\\SqlParser\\TokensList", + "tokens": [ + { + "@type": "@131" + }, + { + "@type": "@132" + }, + { + "@type": "@133" + }, + { + "@type": "@134" + }, + { + "@type": "@135" + }, + { + "@type": "@136" + }, + { + "@type": "@137" + }, + { + "@type": "@138" + }, + { + "@type": "@139" + }, + { + "@type": "@140" + }, + { + "@type": "@141" + }, + { + "@type": "@142" + }, + { + "@type": "@143" + }, + { + "@type": "@144" + }, + { + "@type": "@145" + }, + { + "@type": "@146" + }, + { + "@type": "@147" + }, + { + "@type": "@148" + }, + { + "@type": "@149" + }, + { + "@type": "@150" + }, + { + "@type": "@151" + } + ], + "count": 21, + "idx": 21 + }, + "statements": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Statements\\SelectStatement", + "OPTIONS": { + "ALL": 1, + "DISTINCT": 1, + "DISTINCTROW": 1, + "HIGH_PRIORITY": 2, + "MAX_STATEMENT_TIME": [ + 3, + "var=" + ], + "STRAIGHT_JOIN": 4, + "SQL_SMALL_RESULT": 5, + "SQL_BIG_RESULT": 6, + "SQL_BUFFER_RESULT": 7, + "SQL_CACHE": 8, + "SQL_NO_CACHE": 8, + "SQL_CALC_FOUND_ROWS": 9 + }, + "END_OPTIONS": { + "FOR UPDATE": 1, + "LOCK IN SHARE MODE": 1 + }, + "CLAUSES": { + "SELECT": [ + "SELECT", + 2 + ], + "_OPTIONS": [ + "_OPTIONS", + 1 + ], + "_SELECT": [ + "SELECT", + 1 + ], + "INTO": [ + "INTO", + 3 + ], + "FROM": [ + "FROM", + 3 + ], + "FORCE": [ + "FORCE", + 1 + ], + "USE": [ + "USE", + 1 + ], + "IGNORE": [ + "IGNORE", + 3 + ], + "PARTITION": [ + "PARTITION", + 3 + ], + "JOIN": [ + "JOIN", + 1 + ], + "FULL JOIN": [ + "FULL JOIN", + 1 + ], + "INNER JOIN": [ + "INNER JOIN", + 1 + ], + "LEFT JOIN": [ + "LEFT JOIN", + 1 + ], + "LEFT OUTER JOIN": [ + "LEFT OUTER JOIN", + 1 + ], + "RIGHT JOIN": [ + "RIGHT JOIN", + 1 + ], + "RIGHT OUTER JOIN": [ + "RIGHT OUTER JOIN", + 1 + ], + "NATURAL JOIN": [ + "NATURAL JOIN", + 1 + ], + "NATURAL LEFT JOIN": [ + "NATURAL LEFT JOIN", + 1 + ], + "NATURAL RIGHT JOIN": [ + "NATURAL RIGHT JOIN", + 1 + ], + "NATURAL LEFT OUTER JOIN": [ + "NATURAL LEFT OUTER JOIN", + 1 + ], + "NATURAL RIGHT OUTER JOIN": [ + "NATURAL RIGHT JOIN", + 1 + ], + "WHERE": [ + "WHERE", + 3 + ], + "GROUP BY": [ + "GROUP BY", + 3 + ], + "HAVING": [ + "HAVING", + 3 + ], + "ORDER BY": [ + "ORDER BY", + 3 + ], + "LIMIT": [ + "LIMIT", + 3 + ], + "PROCEDURE": [ + "PROCEDURE", + 3 + ], + "UNION": [ + "UNION", + 1 + ], + "EXCEPT": [ + "EXCEPT", + 1 + ], + "INTERSECT": [ + "INTERSECT", + 1 + ], + "_END_OPTIONS": [ + "_END_OPTIONS", + 1 + ] + }, + "expr": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "ALLOWED_KEYWORDS": { + "AS": 1, + "DUAL": 1, + "NULL": 1, + "REGEXP": 1, + "CASE": 1, + "DIV": 1, + "AND": 1, + "OR": 1, + "XOR": 1, + "NOT": 1, + "MOD": 1, + "OVER": 2 + }, + "database": null, + "table": "cte", + "column": null, + "expr": "cte.*", + "alias": null, + "function": null, + "subquery": null + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "ALLOWED_KEYWORDS": { + "AS": 1, + "DUAL": 1, + "NULL": 1, + "REGEXP": 1, + "CASE": 1, + "DIV": 1, + "AND": 1, + "OR": 1, + "XOR": 1, + "NOT": 1, + "MOD": 1, + "OVER": 2 + }, + "database": null, + "table": "cte2", + "column": null, + "expr": "cte2.*", + "alias": null, + "function": null, + "subquery": null + } + ], + "from": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "ALLOWED_KEYWORDS": { + "AS": 1, + "DUAL": 1, + "NULL": 1, + "REGEXP": 1, + "CASE": 1, + "DIV": 1, + "AND": 1, + "OR": 1, + "XOR": 1, + "NOT": 1, + "MOD": 1, + "OVER": 2 + }, + "database": null, + "table": "cte", + "column": null, + "expr": "cte", + "alias": null, + "function": null, + "subquery": null + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "ALLOWED_KEYWORDS": { + "AS": 1, + "DUAL": 1, + "NULL": 1, + "REGEXP": 1, + "CASE": 1, + "DIV": 1, + "AND": 1, + "OR": 1, + "XOR": 1, + "NOT": 1, + "MOD": 1, + "OVER": 2 + }, + "database": null, + "table": "cte2", + "column": null, + "expr": "cte2", + "alias": null, + "function": null, + "subquery": null + } + ], + "index_hints": null, + "partition": null, + "where": null, + "group": null, + "having": null, + "order": null, + "limit": null, + "procedure": null, + "into": null, + "join": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "JOINS": { + "CROSS JOIN": "CROSS", + "FULL JOIN": "FULL", + "FULL OUTER JOIN": "FULL", + "INNER JOIN": "INNER", + "JOIN": "JOIN", + "LEFT JOIN": "LEFT", + "LEFT OUTER JOIN": "LEFT", + "RIGHT JOIN": "RIGHT", + "RIGHT OUTER JOIN": "RIGHT", + "NATURAL JOIN": "NATURAL", + "NATURAL LEFT JOIN": "NATURAL LEFT", + "NATURAL RIGHT JOIN": "NATURAL RIGHT", + "NATURAL LEFT OUTER JOIN": "NATURAL LEFT OUTER", + "NATURAL RIGHT OUTER JOIN": "NATURAL RIGHT OUTER", + "STRAIGHT_JOIN": "STRAIGHT" + }, + "type": "CROSS", + "expr": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "ALLOWED_KEYWORDS": { + "AS": 1, + "DUAL": 1, + "NULL": 1, + "REGEXP": 1, + "CASE": 1, + "DIV": 1, + "AND": 1, + "OR": 1, + "XOR": 1, + "NOT": 1, + "MOD": 1, + "OVER": 2 + }, + "database": null, + "table": "gis_all", + "column": null, + "expr": "gis_all", + "alias": null, + "function": null, + "subquery": null + }, + "on": null, + "using": null + } + ], + "union": [], + "end_options": null, + "options": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "options": [] + }, + "first": 0, + "last": 18 + } + ], + "brackets": 0, + "strict": false, + "errors": [] + }, + "END_OPTIONS": [], + "options": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "options": [] + }, + "first": null, + "last": null + }, + "select": null, + "like": null, + "partitionBy": null, + "partitionsNum": null, + "subpartitionBy": null, + "subpartitionsNum": null, + "partitions": null, + "table": null, + "return": null, + "parameters": null, + "body": [], + "CLAUSES": [], + "END_OPTIONS": [], + "options": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "options": { + "6": "VIEW" + } + }, + "first": 13, + "last": 109 + } + ], + "brackets": 0, + "strict": false, + "errors": [] + }, "END_OPTIONS": [], "options": { "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", diff --git a/tests/data/parser/parseWithStatement.out b/tests/data/parser/parseWithStatement.out index 9fa3073b6..ec40be51b 100644 --- a/tests/data/parser/parseWithStatement.out +++ b/tests/data/parser/parseWithStatement.out @@ -1518,6 +1518,561 @@ } } }, + "cteStatementParser": { + "@type": "PhpMyAdmin\\SqlParser\\Parser", + "STATEMENT_PARSERS": { + "DESCRIBE": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "DESC": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "EXPLAIN": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "FLUSH": "", + "GRANT": "", + "HELP": "", + "SET PASSWORD": "", + "STATUS": "", + "USE": "", + "ANALYZE": "PhpMyAdmin\\SqlParser\\Statements\\AnalyzeStatement", + "BACKUP": "PhpMyAdmin\\SqlParser\\Statements\\BackupStatement", + "CHECK": "PhpMyAdmin\\SqlParser\\Statements\\CheckStatement", + "CHECKSUM": "PhpMyAdmin\\SqlParser\\Statements\\ChecksumStatement", + "OPTIMIZE": "PhpMyAdmin\\SqlParser\\Statements\\OptimizeStatement", + "REPAIR": "PhpMyAdmin\\SqlParser\\Statements\\RepairStatement", + "RESTORE": "PhpMyAdmin\\SqlParser\\Statements\\RestoreStatement", + "SET": "PhpMyAdmin\\SqlParser\\Statements\\SetStatement", + "SHOW": "PhpMyAdmin\\SqlParser\\Statements\\ShowStatement", + "ALTER": "PhpMyAdmin\\SqlParser\\Statements\\AlterStatement", + "CREATE": "PhpMyAdmin\\SqlParser\\Statements\\CreateStatement", + "DROP": "PhpMyAdmin\\SqlParser\\Statements\\DropStatement", + "RENAME": "PhpMyAdmin\\SqlParser\\Statements\\RenameStatement", + "TRUNCATE": "PhpMyAdmin\\SqlParser\\Statements\\TruncateStatement", + "CALL": "PhpMyAdmin\\SqlParser\\Statements\\CallStatement", + "DELETE": "PhpMyAdmin\\SqlParser\\Statements\\DeleteStatement", + "DO": "", + "HANDLER": "", + "INSERT": "PhpMyAdmin\\SqlParser\\Statements\\InsertStatement", + "LOAD DATA": "PhpMyAdmin\\SqlParser\\Statements\\LoadStatement", + "REPLACE": "PhpMyAdmin\\SqlParser\\Statements\\ReplaceStatement", + "SELECT": "PhpMyAdmin\\SqlParser\\Statements\\SelectStatement", + "UPDATE": "PhpMyAdmin\\SqlParser\\Statements\\UpdateStatement", + "WITH": "PhpMyAdmin\\SqlParser\\Statements\\WithStatement", + "DEALLOCATE": "", + "EXECUTE": "", + "PREPARE": "", + "BEGIN": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "COMMIT": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "ROLLBACK": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "START TRANSACTION": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "PURGE": "PhpMyAdmin\\SqlParser\\Statements\\PurgeStatement", + "LOCK": "PhpMyAdmin\\SqlParser\\Statements\\LockStatement", + "UNLOCK": "PhpMyAdmin\\SqlParser\\Statements\\LockStatement" + }, + "KEYWORD_PARSERS": { + "PARTITION BY": [], + "SUBPARTITION BY": [], + "_OPTIONS": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "field": "options" + }, + "_END_OPTIONS": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "field": "end_options" + }, + "INTERSECT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "EXCEPT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION ALL": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION DISTINCT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "ALTER": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "ANALYZE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "BACKUP": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CALL": { + "class": "PhpMyAdmin\\SqlParser\\Components\\FunctionCall", + "field": "call" + }, + "CHECK": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CHECKSUM": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CROSS JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "DROP": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "fields", + "options": { + "parseField": "table" + } + }, + "FORCE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "FROM": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "from", + "options": { + "field": "table" + } + }, + "GROUP BY": { + "class": "PhpMyAdmin\\SqlParser\\Components\\GroupKeyword", + "field": "group" + }, + "HAVING": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "field": "having" + }, + "IGNORE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "INTO": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IntoKeyword", + "field": "into" + }, + "JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LEFT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LEFT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "ON": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "RIGHT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "RIGHT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "INNER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "FULL JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "FULL OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL LEFT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL RIGHT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL LEFT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL RIGHT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "STRAIGHT_JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LIMIT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Limit", + "field": "limit" + }, + "OPTIMIZE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "ORDER BY": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OrderKeyword", + "field": "order" + }, + "PARTITION": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ArrayObj", + "field": "partition" + }, + "PROCEDURE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\FunctionCall", + "field": "procedure" + }, + "RENAME": { + "class": "PhpMyAdmin\\SqlParser\\Components\\RenameOperation", + "field": "renames" + }, + "REPAIR": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "RESTORE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "SET": { + "class": "PhpMyAdmin\\SqlParser\\Components\\SetOperation", + "field": "set" + }, + "SELECT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "expr" + }, + "TRUNCATE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "UPDATE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "USE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "VALUE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Array2d", + "field": "values" + }, + "VALUES": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Array2d", + "field": "values" + }, + "WHERE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "field": "where" + } + }, + "list": { + "@type": "PhpMyAdmin\\SqlParser\\TokensList", + "tokens": [ + { + "@type": "@32" + }, + { + "@type": "@33" + }, + { + "@type": "@34" + }, + { + "@type": "@35" + }, + { + "@type": "@36" + }, + { + "@type": "@37" + }, + { + "@type": "@38" + }, + { + "@type": "@39" + } + ], + "count": 8, + "idx": 8 + }, + "statements": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Statements\\SelectStatement", + "OPTIONS": { + "ALL": 1, + "DISTINCT": 1, + "DISTINCTROW": 1, + "HIGH_PRIORITY": 2, + "MAX_STATEMENT_TIME": [ + 3, + "var=" + ], + "STRAIGHT_JOIN": 4, + "SQL_SMALL_RESULT": 5, + "SQL_BIG_RESULT": 6, + "SQL_BUFFER_RESULT": 7, + "SQL_CACHE": 8, + "SQL_NO_CACHE": 8, + "SQL_CALC_FOUND_ROWS": 9 + }, + "END_OPTIONS": { + "FOR UPDATE": 1, + "LOCK IN SHARE MODE": 1 + }, + "CLAUSES": { + "SELECT": [ + "SELECT", + 2 + ], + "_OPTIONS": [ + "_OPTIONS", + 1 + ], + "_SELECT": [ + "SELECT", + 1 + ], + "INTO": [ + "INTO", + 3 + ], + "FROM": [ + "FROM", + 3 + ], + "FORCE": [ + "FORCE", + 1 + ], + "USE": [ + "USE", + 1 + ], + "IGNORE": [ + "IGNORE", + 3 + ], + "PARTITION": [ + "PARTITION", + 3 + ], + "JOIN": [ + "JOIN", + 1 + ], + "FULL JOIN": [ + "FULL JOIN", + 1 + ], + "INNER JOIN": [ + "INNER JOIN", + 1 + ], + "LEFT JOIN": [ + "LEFT JOIN", + 1 + ], + "LEFT OUTER JOIN": [ + "LEFT OUTER JOIN", + 1 + ], + "RIGHT JOIN": [ + "RIGHT JOIN", + 1 + ], + "RIGHT OUTER JOIN": [ + "RIGHT OUTER JOIN", + 1 + ], + "NATURAL JOIN": [ + "NATURAL JOIN", + 1 + ], + "NATURAL LEFT JOIN": [ + "NATURAL LEFT JOIN", + 1 + ], + "NATURAL RIGHT JOIN": [ + "NATURAL RIGHT JOIN", + 1 + ], + "NATURAL LEFT OUTER JOIN": [ + "NATURAL LEFT OUTER JOIN", + 1 + ], + "NATURAL RIGHT OUTER JOIN": [ + "NATURAL RIGHT JOIN", + 1 + ], + "WHERE": [ + "WHERE", + 3 + ], + "GROUP BY": [ + "GROUP BY", + 3 + ], + "HAVING": [ + "HAVING", + 3 + ], + "ORDER BY": [ + "ORDER BY", + 3 + ], + "LIMIT": [ + "LIMIT", + 3 + ], + "PROCEDURE": [ + "PROCEDURE", + 3 + ], + "UNION": [ + "UNION", + 1 + ], + "EXCEPT": [ + "EXCEPT", + 1 + ], + "INTERSECT": [ + "INTERSECT", + 1 + ], + "_END_OPTIONS": [ + "_END_OPTIONS", + 1 + ] + }, + "expr": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "ALLOWED_KEYWORDS": { + "AS": 1, + "DUAL": 1, + "NULL": 1, + "REGEXP": 1, + "CASE": 1, + "DIV": 1, + "AND": 1, + "OR": 1, + "XOR": 1, + "NOT": 1, + "MOD": 1, + "OVER": 2 + }, + "database": null, + "table": null, + "column": "col1", + "expr": "col1", + "alias": null, + "function": null, + "subquery": null + } + ], + "from": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "ALLOWED_KEYWORDS": { + "AS": 1, + "DUAL": 1, + "NULL": 1, + "REGEXP": 1, + "CASE": 1, + "DIV": 1, + "AND": 1, + "OR": 1, + "XOR": 1, + "NOT": 1, + "MOD": 1, + "OVER": 2 + }, + "database": null, + "table": "cte", + "column": null, + "expr": "cte", + "alias": null, + "function": null, + "subquery": null + } + ], + "index_hints": null, + "partition": null, + "where": null, + "group": null, + "having": null, + "order": null, + "limit": null, + "procedure": null, + "into": null, + "join": null, + "union": [], + "end_options": null, + "options": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "options": [] + }, + "first": 0, + "last": 6 + } + ], + "brackets": 0, + "strict": false, + "errors": [] + }, "END_OPTIONS": [], "options": { "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", diff --git a/tests/data/parser/parseWithStatement1.out b/tests/data/parser/parseWithStatement1.out index cf0fff230..d6549d7a2 100644 --- a/tests/data/parser/parseWithStatement1.out +++ b/tests/data/parser/parseWithStatement1.out @@ -1689,6 +1689,561 @@ } } }, + "cteStatementParser": { + "@type": "PhpMyAdmin\\SqlParser\\Parser", + "STATEMENT_PARSERS": { + "DESCRIBE": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "DESC": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "EXPLAIN": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "FLUSH": "", + "GRANT": "", + "HELP": "", + "SET PASSWORD": "", + "STATUS": "", + "USE": "", + "ANALYZE": "PhpMyAdmin\\SqlParser\\Statements\\AnalyzeStatement", + "BACKUP": "PhpMyAdmin\\SqlParser\\Statements\\BackupStatement", + "CHECK": "PhpMyAdmin\\SqlParser\\Statements\\CheckStatement", + "CHECKSUM": "PhpMyAdmin\\SqlParser\\Statements\\ChecksumStatement", + "OPTIMIZE": "PhpMyAdmin\\SqlParser\\Statements\\OptimizeStatement", + "REPAIR": "PhpMyAdmin\\SqlParser\\Statements\\RepairStatement", + "RESTORE": "PhpMyAdmin\\SqlParser\\Statements\\RestoreStatement", + "SET": "PhpMyAdmin\\SqlParser\\Statements\\SetStatement", + "SHOW": "PhpMyAdmin\\SqlParser\\Statements\\ShowStatement", + "ALTER": "PhpMyAdmin\\SqlParser\\Statements\\AlterStatement", + "CREATE": "PhpMyAdmin\\SqlParser\\Statements\\CreateStatement", + "DROP": "PhpMyAdmin\\SqlParser\\Statements\\DropStatement", + "RENAME": "PhpMyAdmin\\SqlParser\\Statements\\RenameStatement", + "TRUNCATE": "PhpMyAdmin\\SqlParser\\Statements\\TruncateStatement", + "CALL": "PhpMyAdmin\\SqlParser\\Statements\\CallStatement", + "DELETE": "PhpMyAdmin\\SqlParser\\Statements\\DeleteStatement", + "DO": "", + "HANDLER": "", + "INSERT": "PhpMyAdmin\\SqlParser\\Statements\\InsertStatement", + "LOAD DATA": "PhpMyAdmin\\SqlParser\\Statements\\LoadStatement", + "REPLACE": "PhpMyAdmin\\SqlParser\\Statements\\ReplaceStatement", + "SELECT": "PhpMyAdmin\\SqlParser\\Statements\\SelectStatement", + "UPDATE": "PhpMyAdmin\\SqlParser\\Statements\\UpdateStatement", + "WITH": "PhpMyAdmin\\SqlParser\\Statements\\WithStatement", + "DEALLOCATE": "", + "EXECUTE": "", + "PREPARE": "", + "BEGIN": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "COMMIT": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "ROLLBACK": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "START TRANSACTION": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "PURGE": "PhpMyAdmin\\SqlParser\\Statements\\PurgeStatement", + "LOCK": "PhpMyAdmin\\SqlParser\\Statements\\LockStatement", + "UNLOCK": "PhpMyAdmin\\SqlParser\\Statements\\LockStatement" + }, + "KEYWORD_PARSERS": { + "PARTITION BY": [], + "SUBPARTITION BY": [], + "_OPTIONS": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "field": "options" + }, + "_END_OPTIONS": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "field": "end_options" + }, + "INTERSECT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "EXCEPT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION ALL": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION DISTINCT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "ALTER": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "ANALYZE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "BACKUP": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CALL": { + "class": "PhpMyAdmin\\SqlParser\\Components\\FunctionCall", + "field": "call" + }, + "CHECK": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CHECKSUM": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CROSS JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "DROP": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "fields", + "options": { + "parseField": "table" + } + }, + "FORCE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "FROM": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "from", + "options": { + "field": "table" + } + }, + "GROUP BY": { + "class": "PhpMyAdmin\\SqlParser\\Components\\GroupKeyword", + "field": "group" + }, + "HAVING": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "field": "having" + }, + "IGNORE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "INTO": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IntoKeyword", + "field": "into" + }, + "JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LEFT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LEFT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "ON": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "RIGHT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "RIGHT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "INNER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "FULL JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "FULL OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL LEFT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL RIGHT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL LEFT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL RIGHT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "STRAIGHT_JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LIMIT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Limit", + "field": "limit" + }, + "OPTIMIZE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "ORDER BY": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OrderKeyword", + "field": "order" + }, + "PARTITION": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ArrayObj", + "field": "partition" + }, + "PROCEDURE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\FunctionCall", + "field": "procedure" + }, + "RENAME": { + "class": "PhpMyAdmin\\SqlParser\\Components\\RenameOperation", + "field": "renames" + }, + "REPAIR": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "RESTORE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "SET": { + "class": "PhpMyAdmin\\SqlParser\\Components\\SetOperation", + "field": "set" + }, + "SELECT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "expr" + }, + "TRUNCATE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "UPDATE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "USE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "VALUE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Array2d", + "field": "values" + }, + "VALUES": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Array2d", + "field": "values" + }, + "WHERE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "field": "where" + } + }, + "list": { + "@type": "PhpMyAdmin\\SqlParser\\TokensList", + "tokens": [ + { + "@type": "@32" + }, + { + "@type": "@33" + }, + { + "@type": "@34" + }, + { + "@type": "@35" + }, + { + "@type": "@36" + }, + { + "@type": "@37" + }, + { + "@type": "@38" + }, + { + "@type": "@39" + } + ], + "count": 8, + "idx": 8 + }, + "statements": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Statements\\SelectStatement", + "OPTIONS": { + "ALL": 1, + "DISTINCT": 1, + "DISTINCTROW": 1, + "HIGH_PRIORITY": 2, + "MAX_STATEMENT_TIME": [ + 3, + "var=" + ], + "STRAIGHT_JOIN": 4, + "SQL_SMALL_RESULT": 5, + "SQL_BIG_RESULT": 6, + "SQL_BUFFER_RESULT": 7, + "SQL_CACHE": 8, + "SQL_NO_CACHE": 8, + "SQL_CALC_FOUND_ROWS": 9 + }, + "END_OPTIONS": { + "FOR UPDATE": 1, + "LOCK IN SHARE MODE": 1 + }, + "CLAUSES": { + "SELECT": [ + "SELECT", + 2 + ], + "_OPTIONS": [ + "_OPTIONS", + 1 + ], + "_SELECT": [ + "SELECT", + 1 + ], + "INTO": [ + "INTO", + 3 + ], + "FROM": [ + "FROM", + 3 + ], + "FORCE": [ + "FORCE", + 1 + ], + "USE": [ + "USE", + 1 + ], + "IGNORE": [ + "IGNORE", + 3 + ], + "PARTITION": [ + "PARTITION", + 3 + ], + "JOIN": [ + "JOIN", + 1 + ], + "FULL JOIN": [ + "FULL JOIN", + 1 + ], + "INNER JOIN": [ + "INNER JOIN", + 1 + ], + "LEFT JOIN": [ + "LEFT JOIN", + 1 + ], + "LEFT OUTER JOIN": [ + "LEFT OUTER JOIN", + 1 + ], + "RIGHT JOIN": [ + "RIGHT JOIN", + 1 + ], + "RIGHT OUTER JOIN": [ + "RIGHT OUTER JOIN", + 1 + ], + "NATURAL JOIN": [ + "NATURAL JOIN", + 1 + ], + "NATURAL LEFT JOIN": [ + "NATURAL LEFT JOIN", + 1 + ], + "NATURAL RIGHT JOIN": [ + "NATURAL RIGHT JOIN", + 1 + ], + "NATURAL LEFT OUTER JOIN": [ + "NATURAL LEFT OUTER JOIN", + 1 + ], + "NATURAL RIGHT OUTER JOIN": [ + "NATURAL RIGHT JOIN", + 1 + ], + "WHERE": [ + "WHERE", + 3 + ], + "GROUP BY": [ + "GROUP BY", + 3 + ], + "HAVING": [ + "HAVING", + 3 + ], + "ORDER BY": [ + "ORDER BY", + 3 + ], + "LIMIT": [ + "LIMIT", + 3 + ], + "PROCEDURE": [ + "PROCEDURE", + 3 + ], + "UNION": [ + "UNION", + 1 + ], + "EXCEPT": [ + "EXCEPT", + 1 + ], + "INTERSECT": [ + "INTERSECT", + 1 + ], + "_END_OPTIONS": [ + "_END_OPTIONS", + 1 + ] + }, + "expr": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "ALLOWED_KEYWORDS": { + "AS": 1, + "DUAL": 1, + "NULL": 1, + "REGEXP": 1, + "CASE": 1, + "DIV": 1, + "AND": 1, + "OR": 1, + "XOR": 1, + "NOT": 1, + "MOD": 1, + "OVER": 2 + }, + "database": null, + "table": null, + "column": "col1", + "expr": "col1", + "alias": null, + "function": null, + "subquery": null + } + ], + "from": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "ALLOWED_KEYWORDS": { + "AS": 1, + "DUAL": 1, + "NULL": 1, + "REGEXP": 1, + "CASE": 1, + "DIV": 1, + "AND": 1, + "OR": 1, + "XOR": 1, + "NOT": 1, + "MOD": 1, + "OVER": 2 + }, + "database": null, + "table": "cte", + "column": null, + "expr": "cte", + "alias": null, + "function": null, + "subquery": null + } + ], + "index_hints": null, + "partition": null, + "where": null, + "group": null, + "having": null, + "order": null, + "limit": null, + "procedure": null, + "into": null, + "join": null, + "union": [], + "end_options": null, + "options": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "options": [] + }, + "first": 0, + "last": 6 + } + ], + "brackets": 0, + "strict": false, + "errors": [] + }, "END_OPTIONS": [], "options": { "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", diff --git a/tests/data/parser/parseWithStatement2.out b/tests/data/parser/parseWithStatement2.out index 677aa58c5..f9541c022 100644 --- a/tests/data/parser/parseWithStatement2.out +++ b/tests/data/parser/parseWithStatement2.out @@ -1373,6 +1373,561 @@ } } }, + "cteStatementParser": { + "@type": "PhpMyAdmin\\SqlParser\\Parser", + "STATEMENT_PARSERS": { + "DESCRIBE": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "DESC": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "EXPLAIN": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "FLUSH": "", + "GRANT": "", + "HELP": "", + "SET PASSWORD": "", + "STATUS": "", + "USE": "", + "ANALYZE": "PhpMyAdmin\\SqlParser\\Statements\\AnalyzeStatement", + "BACKUP": "PhpMyAdmin\\SqlParser\\Statements\\BackupStatement", + "CHECK": "PhpMyAdmin\\SqlParser\\Statements\\CheckStatement", + "CHECKSUM": "PhpMyAdmin\\SqlParser\\Statements\\ChecksumStatement", + "OPTIMIZE": "PhpMyAdmin\\SqlParser\\Statements\\OptimizeStatement", + "REPAIR": "PhpMyAdmin\\SqlParser\\Statements\\RepairStatement", + "RESTORE": "PhpMyAdmin\\SqlParser\\Statements\\RestoreStatement", + "SET": "PhpMyAdmin\\SqlParser\\Statements\\SetStatement", + "SHOW": "PhpMyAdmin\\SqlParser\\Statements\\ShowStatement", + "ALTER": "PhpMyAdmin\\SqlParser\\Statements\\AlterStatement", + "CREATE": "PhpMyAdmin\\SqlParser\\Statements\\CreateStatement", + "DROP": "PhpMyAdmin\\SqlParser\\Statements\\DropStatement", + "RENAME": "PhpMyAdmin\\SqlParser\\Statements\\RenameStatement", + "TRUNCATE": "PhpMyAdmin\\SqlParser\\Statements\\TruncateStatement", + "CALL": "PhpMyAdmin\\SqlParser\\Statements\\CallStatement", + "DELETE": "PhpMyAdmin\\SqlParser\\Statements\\DeleteStatement", + "DO": "", + "HANDLER": "", + "INSERT": "PhpMyAdmin\\SqlParser\\Statements\\InsertStatement", + "LOAD DATA": "PhpMyAdmin\\SqlParser\\Statements\\LoadStatement", + "REPLACE": "PhpMyAdmin\\SqlParser\\Statements\\ReplaceStatement", + "SELECT": "PhpMyAdmin\\SqlParser\\Statements\\SelectStatement", + "UPDATE": "PhpMyAdmin\\SqlParser\\Statements\\UpdateStatement", + "WITH": "PhpMyAdmin\\SqlParser\\Statements\\WithStatement", + "DEALLOCATE": "", + "EXECUTE": "", + "PREPARE": "", + "BEGIN": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "COMMIT": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "ROLLBACK": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "START TRANSACTION": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "PURGE": "PhpMyAdmin\\SqlParser\\Statements\\PurgeStatement", + "LOCK": "PhpMyAdmin\\SqlParser\\Statements\\LockStatement", + "UNLOCK": "PhpMyAdmin\\SqlParser\\Statements\\LockStatement" + }, + "KEYWORD_PARSERS": { + "PARTITION BY": [], + "SUBPARTITION BY": [], + "_OPTIONS": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "field": "options" + }, + "_END_OPTIONS": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "field": "end_options" + }, + "INTERSECT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "EXCEPT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION ALL": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION DISTINCT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "ALTER": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "ANALYZE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "BACKUP": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CALL": { + "class": "PhpMyAdmin\\SqlParser\\Components\\FunctionCall", + "field": "call" + }, + "CHECK": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CHECKSUM": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CROSS JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "DROP": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "fields", + "options": { + "parseField": "table" + } + }, + "FORCE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "FROM": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "from", + "options": { + "field": "table" + } + }, + "GROUP BY": { + "class": "PhpMyAdmin\\SqlParser\\Components\\GroupKeyword", + "field": "group" + }, + "HAVING": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "field": "having" + }, + "IGNORE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "INTO": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IntoKeyword", + "field": "into" + }, + "JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LEFT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LEFT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "ON": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "RIGHT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "RIGHT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "INNER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "FULL JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "FULL OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL LEFT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL RIGHT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL LEFT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL RIGHT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "STRAIGHT_JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LIMIT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Limit", + "field": "limit" + }, + "OPTIMIZE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "ORDER BY": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OrderKeyword", + "field": "order" + }, + "PARTITION": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ArrayObj", + "field": "partition" + }, + "PROCEDURE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\FunctionCall", + "field": "procedure" + }, + "RENAME": { + "class": "PhpMyAdmin\\SqlParser\\Components\\RenameOperation", + "field": "renames" + }, + "REPAIR": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "RESTORE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "SET": { + "class": "PhpMyAdmin\\SqlParser\\Components\\SetOperation", + "field": "set" + }, + "SELECT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "expr" + }, + "TRUNCATE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "UPDATE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "USE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "VALUE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Array2d", + "field": "values" + }, + "VALUES": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Array2d", + "field": "values" + }, + "WHERE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "field": "where" + } + }, + "list": { + "@type": "PhpMyAdmin\\SqlParser\\TokensList", + "tokens": [ + { + "@type": "@26" + }, + { + "@type": "@27" + }, + { + "@type": "@28" + }, + { + "@type": "@29" + }, + { + "@type": "@30" + }, + { + "@type": "@31" + }, + { + "@type": "@32" + }, + { + "@type": "@33" + } + ], + "count": 8, + "idx": 8 + }, + "statements": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Statements\\SelectStatement", + "OPTIONS": { + "ALL": 1, + "DISTINCT": 1, + "DISTINCTROW": 1, + "HIGH_PRIORITY": 2, + "MAX_STATEMENT_TIME": [ + 3, + "var=" + ], + "STRAIGHT_JOIN": 4, + "SQL_SMALL_RESULT": 5, + "SQL_BIG_RESULT": 6, + "SQL_BUFFER_RESULT": 7, + "SQL_CACHE": 8, + "SQL_NO_CACHE": 8, + "SQL_CALC_FOUND_ROWS": 9 + }, + "END_OPTIONS": { + "FOR UPDATE": 1, + "LOCK IN SHARE MODE": 1 + }, + "CLAUSES": { + "SELECT": [ + "SELECT", + 2 + ], + "_OPTIONS": [ + "_OPTIONS", + 1 + ], + "_SELECT": [ + "SELECT", + 1 + ], + "INTO": [ + "INTO", + 3 + ], + "FROM": [ + "FROM", + 3 + ], + "FORCE": [ + "FORCE", + 1 + ], + "USE": [ + "USE", + 1 + ], + "IGNORE": [ + "IGNORE", + 3 + ], + "PARTITION": [ + "PARTITION", + 3 + ], + "JOIN": [ + "JOIN", + 1 + ], + "FULL JOIN": [ + "FULL JOIN", + 1 + ], + "INNER JOIN": [ + "INNER JOIN", + 1 + ], + "LEFT JOIN": [ + "LEFT JOIN", + 1 + ], + "LEFT OUTER JOIN": [ + "LEFT OUTER JOIN", + 1 + ], + "RIGHT JOIN": [ + "RIGHT JOIN", + 1 + ], + "RIGHT OUTER JOIN": [ + "RIGHT OUTER JOIN", + 1 + ], + "NATURAL JOIN": [ + "NATURAL JOIN", + 1 + ], + "NATURAL LEFT JOIN": [ + "NATURAL LEFT JOIN", + 1 + ], + "NATURAL RIGHT JOIN": [ + "NATURAL RIGHT JOIN", + 1 + ], + "NATURAL LEFT OUTER JOIN": [ + "NATURAL LEFT OUTER JOIN", + 1 + ], + "NATURAL RIGHT OUTER JOIN": [ + "NATURAL RIGHT JOIN", + 1 + ], + "WHERE": [ + "WHERE", + 3 + ], + "GROUP BY": [ + "GROUP BY", + 3 + ], + "HAVING": [ + "HAVING", + 3 + ], + "ORDER BY": [ + "ORDER BY", + 3 + ], + "LIMIT": [ + "LIMIT", + 3 + ], + "PROCEDURE": [ + "PROCEDURE", + 3 + ], + "UNION": [ + "UNION", + 1 + ], + "EXCEPT": [ + "EXCEPT", + 1 + ], + "INTERSECT": [ + "INTERSECT", + 1 + ], + "_END_OPTIONS": [ + "_END_OPTIONS", + 1 + ] + }, + "expr": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "ALLOWED_KEYWORDS": { + "AS": 1, + "DUAL": 1, + "NULL": 1, + "REGEXP": 1, + "CASE": 1, + "DIV": 1, + "AND": 1, + "OR": 1, + "XOR": 1, + "NOT": 1, + "MOD": 1, + "OVER": 2 + }, + "database": null, + "table": null, + "column": "col1", + "expr": "col1", + "alias": null, + "function": null, + "subquery": null + } + ], + "from": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "ALLOWED_KEYWORDS": { + "AS": 1, + "DUAL": 1, + "NULL": 1, + "REGEXP": 1, + "CASE": 1, + "DIV": 1, + "AND": 1, + "OR": 1, + "XOR": 1, + "NOT": 1, + "MOD": 1, + "OVER": 2 + }, + "database": null, + "table": "cte", + "column": null, + "expr": "cte", + "alias": null, + "function": null, + "subquery": null + } + ], + "index_hints": null, + "partition": null, + "where": null, + "group": null, + "having": null, + "order": null, + "limit": null, + "procedure": null, + "into": null, + "join": null, + "union": [], + "end_options": null, + "options": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "options": [] + }, + "first": 0, + "last": 7 + } + ], + "brackets": 0, + "strict": false, + "errors": [] + }, "END_OPTIONS": [], "options": { "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", diff --git a/tests/data/parser/parseWithStatement3.out b/tests/data/parser/parseWithStatement3.out index a60bf90d2..8c5280d2d 100644 --- a/tests/data/parser/parseWithStatement3.out +++ b/tests/data/parser/parseWithStatement3.out @@ -3141,6 +3141,561 @@ } } }, + "cteStatementParser": { + "@type": "PhpMyAdmin\\SqlParser\\Parser", + "STATEMENT_PARSERS": { + "DESCRIBE": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "DESC": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "EXPLAIN": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "FLUSH": "", + "GRANT": "", + "HELP": "", + "SET PASSWORD": "", + "STATUS": "", + "USE": "", + "ANALYZE": "PhpMyAdmin\\SqlParser\\Statements\\AnalyzeStatement", + "BACKUP": "PhpMyAdmin\\SqlParser\\Statements\\BackupStatement", + "CHECK": "PhpMyAdmin\\SqlParser\\Statements\\CheckStatement", + "CHECKSUM": "PhpMyAdmin\\SqlParser\\Statements\\ChecksumStatement", + "OPTIMIZE": "PhpMyAdmin\\SqlParser\\Statements\\OptimizeStatement", + "REPAIR": "PhpMyAdmin\\SqlParser\\Statements\\RepairStatement", + "RESTORE": "PhpMyAdmin\\SqlParser\\Statements\\RestoreStatement", + "SET": "PhpMyAdmin\\SqlParser\\Statements\\SetStatement", + "SHOW": "PhpMyAdmin\\SqlParser\\Statements\\ShowStatement", + "ALTER": "PhpMyAdmin\\SqlParser\\Statements\\AlterStatement", + "CREATE": "PhpMyAdmin\\SqlParser\\Statements\\CreateStatement", + "DROP": "PhpMyAdmin\\SqlParser\\Statements\\DropStatement", + "RENAME": "PhpMyAdmin\\SqlParser\\Statements\\RenameStatement", + "TRUNCATE": "PhpMyAdmin\\SqlParser\\Statements\\TruncateStatement", + "CALL": "PhpMyAdmin\\SqlParser\\Statements\\CallStatement", + "DELETE": "PhpMyAdmin\\SqlParser\\Statements\\DeleteStatement", + "DO": "", + "HANDLER": "", + "INSERT": "PhpMyAdmin\\SqlParser\\Statements\\InsertStatement", + "LOAD DATA": "PhpMyAdmin\\SqlParser\\Statements\\LoadStatement", + "REPLACE": "PhpMyAdmin\\SqlParser\\Statements\\ReplaceStatement", + "SELECT": "PhpMyAdmin\\SqlParser\\Statements\\SelectStatement", + "UPDATE": "PhpMyAdmin\\SqlParser\\Statements\\UpdateStatement", + "WITH": "PhpMyAdmin\\SqlParser\\Statements\\WithStatement", + "DEALLOCATE": "", + "EXECUTE": "", + "PREPARE": "", + "BEGIN": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "COMMIT": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "ROLLBACK": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "START TRANSACTION": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "PURGE": "PhpMyAdmin\\SqlParser\\Statements\\PurgeStatement", + "LOCK": "PhpMyAdmin\\SqlParser\\Statements\\LockStatement", + "UNLOCK": "PhpMyAdmin\\SqlParser\\Statements\\LockStatement" + }, + "KEYWORD_PARSERS": { + "PARTITION BY": [], + "SUBPARTITION BY": [], + "_OPTIONS": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "field": "options" + }, + "_END_OPTIONS": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "field": "end_options" + }, + "INTERSECT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "EXCEPT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION ALL": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION DISTINCT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "ALTER": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "ANALYZE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "BACKUP": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CALL": { + "class": "PhpMyAdmin\\SqlParser\\Components\\FunctionCall", + "field": "call" + }, + "CHECK": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CHECKSUM": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CROSS JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "DROP": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "fields", + "options": { + "parseField": "table" + } + }, + "FORCE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "FROM": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "from", + "options": { + "field": "table" + } + }, + "GROUP BY": { + "class": "PhpMyAdmin\\SqlParser\\Components\\GroupKeyword", + "field": "group" + }, + "HAVING": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "field": "having" + }, + "IGNORE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "INTO": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IntoKeyword", + "field": "into" + }, + "JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LEFT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LEFT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "ON": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "RIGHT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "RIGHT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "INNER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "FULL JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "FULL OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL LEFT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL RIGHT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL LEFT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL RIGHT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "STRAIGHT_JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LIMIT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Limit", + "field": "limit" + }, + "OPTIMIZE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "ORDER BY": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OrderKeyword", + "field": "order" + }, + "PARTITION": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ArrayObj", + "field": "partition" + }, + "PROCEDURE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\FunctionCall", + "field": "procedure" + }, + "RENAME": { + "class": "PhpMyAdmin\\SqlParser\\Components\\RenameOperation", + "field": "renames" + }, + "REPAIR": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "RESTORE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "SET": { + "class": "PhpMyAdmin\\SqlParser\\Components\\SetOperation", + "field": "set" + }, + "SELECT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "expr" + }, + "TRUNCATE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "UPDATE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "USE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "VALUE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Array2d", + "field": "values" + }, + "VALUES": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Array2d", + "field": "values" + }, + "WHERE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "field": "where" + } + }, + "list": { + "@type": "PhpMyAdmin\\SqlParser\\TokensList", + "tokens": [ + { + "@type": "@109" + }, + { + "@type": "@110" + }, + { + "@type": "@111" + }, + { + "@type": "@112" + }, + { + "@type": "@113" + }, + { + "@type": "@114" + }, + { + "@type": "@115" + }, + { + "@type": "@116" + } + ], + "count": 8, + "idx": 8 + }, + "statements": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Statements\\SelectStatement", + "OPTIONS": { + "ALL": 1, + "DISTINCT": 1, + "DISTINCTROW": 1, + "HIGH_PRIORITY": 2, + "MAX_STATEMENT_TIME": [ + 3, + "var=" + ], + "STRAIGHT_JOIN": 4, + "SQL_SMALL_RESULT": 5, + "SQL_BIG_RESULT": 6, + "SQL_BUFFER_RESULT": 7, + "SQL_CACHE": 8, + "SQL_NO_CACHE": 8, + "SQL_CALC_FOUND_ROWS": 9 + }, + "END_OPTIONS": { + "FOR UPDATE": 1, + "LOCK IN SHARE MODE": 1 + }, + "CLAUSES": { + "SELECT": [ + "SELECT", + 2 + ], + "_OPTIONS": [ + "_OPTIONS", + 1 + ], + "_SELECT": [ + "SELECT", + 1 + ], + "INTO": [ + "INTO", + 3 + ], + "FROM": [ + "FROM", + 3 + ], + "FORCE": [ + "FORCE", + 1 + ], + "USE": [ + "USE", + 1 + ], + "IGNORE": [ + "IGNORE", + 3 + ], + "PARTITION": [ + "PARTITION", + 3 + ], + "JOIN": [ + "JOIN", + 1 + ], + "FULL JOIN": [ + "FULL JOIN", + 1 + ], + "INNER JOIN": [ + "INNER JOIN", + 1 + ], + "LEFT JOIN": [ + "LEFT JOIN", + 1 + ], + "LEFT OUTER JOIN": [ + "LEFT OUTER JOIN", + 1 + ], + "RIGHT JOIN": [ + "RIGHT JOIN", + 1 + ], + "RIGHT OUTER JOIN": [ + "RIGHT OUTER JOIN", + 1 + ], + "NATURAL JOIN": [ + "NATURAL JOIN", + 1 + ], + "NATURAL LEFT JOIN": [ + "NATURAL LEFT JOIN", + 1 + ], + "NATURAL RIGHT JOIN": [ + "NATURAL RIGHT JOIN", + 1 + ], + "NATURAL LEFT OUTER JOIN": [ + "NATURAL LEFT OUTER JOIN", + 1 + ], + "NATURAL RIGHT OUTER JOIN": [ + "NATURAL RIGHT JOIN", + 1 + ], + "WHERE": [ + "WHERE", + 3 + ], + "GROUP BY": [ + "GROUP BY", + 3 + ], + "HAVING": [ + "HAVING", + 3 + ], + "ORDER BY": [ + "ORDER BY", + 3 + ], + "LIMIT": [ + "LIMIT", + 3 + ], + "PROCEDURE": [ + "PROCEDURE", + 3 + ], + "UNION": [ + "UNION", + 1 + ], + "EXCEPT": [ + "EXCEPT", + 1 + ], + "INTERSECT": [ + "INTERSECT", + 1 + ], + "_END_OPTIONS": [ + "_END_OPTIONS", + 1 + ] + }, + "expr": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "ALLOWED_KEYWORDS": { + "AS": 1, + "DUAL": 1, + "NULL": 1, + "REGEXP": 1, + "CASE": 1, + "DIV": 1, + "AND": 1, + "OR": 1, + "XOR": 1, + "NOT": 1, + "MOD": 1, + "OVER": 2 + }, + "database": null, + "table": null, + "column": null, + "expr": "*", + "alias": null, + "function": null, + "subquery": null + } + ], + "from": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "ALLOWED_KEYWORDS": { + "AS": 1, + "DUAL": 1, + "NULL": 1, + "REGEXP": 1, + "CASE": 1, + "DIV": 1, + "AND": 1, + "OR": 1, + "XOR": 1, + "NOT": 1, + "MOD": 1, + "OVER": 2 + }, + "database": null, + "table": "categories", + "column": null, + "expr": "categories", + "alias": null, + "function": null, + "subquery": null + } + ], + "index_hints": null, + "partition": null, + "where": null, + "group": null, + "having": null, + "order": null, + "limit": null, + "procedure": null, + "into": null, + "join": null, + "union": [], + "end_options": null, + "options": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "options": [] + }, + "first": 0, + "last": 6 + } + ], + "brackets": 0, + "strict": false, + "errors": [] + }, "END_OPTIONS": [], "options": { "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", diff --git a/tests/data/parser/parseWithStatement4.out b/tests/data/parser/parseWithStatement4.out index 571cb3f60..f6aa29a4d 100644 --- a/tests/data/parser/parseWithStatement4.out +++ b/tests/data/parser/parseWithStatement4.out @@ -1653,6 +1653,7 @@ } } }, + "cteStatementParser": null, "END_OPTIONS": [], "options": { "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", diff --git a/tests/data/parser/parseWithStatement5.out b/tests/data/parser/parseWithStatement5.out index ee4b7b813..d3f99e332 100644 --- a/tests/data/parser/parseWithStatement5.out +++ b/tests/data/parser/parseWithStatement5.out @@ -1698,6 +1698,561 @@ } } }, + "cteStatementParser": { + "@type": "PhpMyAdmin\\SqlParser\\Parser", + "STATEMENT_PARSERS": { + "DESCRIBE": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "DESC": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "EXPLAIN": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "FLUSH": "", + "GRANT": "", + "HELP": "", + "SET PASSWORD": "", + "STATUS": "", + "USE": "", + "ANALYZE": "PhpMyAdmin\\SqlParser\\Statements\\AnalyzeStatement", + "BACKUP": "PhpMyAdmin\\SqlParser\\Statements\\BackupStatement", + "CHECK": "PhpMyAdmin\\SqlParser\\Statements\\CheckStatement", + "CHECKSUM": "PhpMyAdmin\\SqlParser\\Statements\\ChecksumStatement", + "OPTIMIZE": "PhpMyAdmin\\SqlParser\\Statements\\OptimizeStatement", + "REPAIR": "PhpMyAdmin\\SqlParser\\Statements\\RepairStatement", + "RESTORE": "PhpMyAdmin\\SqlParser\\Statements\\RestoreStatement", + "SET": "PhpMyAdmin\\SqlParser\\Statements\\SetStatement", + "SHOW": "PhpMyAdmin\\SqlParser\\Statements\\ShowStatement", + "ALTER": "PhpMyAdmin\\SqlParser\\Statements\\AlterStatement", + "CREATE": "PhpMyAdmin\\SqlParser\\Statements\\CreateStatement", + "DROP": "PhpMyAdmin\\SqlParser\\Statements\\DropStatement", + "RENAME": "PhpMyAdmin\\SqlParser\\Statements\\RenameStatement", + "TRUNCATE": "PhpMyAdmin\\SqlParser\\Statements\\TruncateStatement", + "CALL": "PhpMyAdmin\\SqlParser\\Statements\\CallStatement", + "DELETE": "PhpMyAdmin\\SqlParser\\Statements\\DeleteStatement", + "DO": "", + "HANDLER": "", + "INSERT": "PhpMyAdmin\\SqlParser\\Statements\\InsertStatement", + "LOAD DATA": "PhpMyAdmin\\SqlParser\\Statements\\LoadStatement", + "REPLACE": "PhpMyAdmin\\SqlParser\\Statements\\ReplaceStatement", + "SELECT": "PhpMyAdmin\\SqlParser\\Statements\\SelectStatement", + "UPDATE": "PhpMyAdmin\\SqlParser\\Statements\\UpdateStatement", + "WITH": "PhpMyAdmin\\SqlParser\\Statements\\WithStatement", + "DEALLOCATE": "", + "EXECUTE": "", + "PREPARE": "", + "BEGIN": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "COMMIT": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "ROLLBACK": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "START TRANSACTION": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "PURGE": "PhpMyAdmin\\SqlParser\\Statements\\PurgeStatement", + "LOCK": "PhpMyAdmin\\SqlParser\\Statements\\LockStatement", + "UNLOCK": "PhpMyAdmin\\SqlParser\\Statements\\LockStatement" + }, + "KEYWORD_PARSERS": { + "PARTITION BY": [], + "SUBPARTITION BY": [], + "_OPTIONS": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "field": "options" + }, + "_END_OPTIONS": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "field": "end_options" + }, + "INTERSECT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "EXCEPT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION ALL": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION DISTINCT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "ALTER": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "ANALYZE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "BACKUP": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CALL": { + "class": "PhpMyAdmin\\SqlParser\\Components\\FunctionCall", + "field": "call" + }, + "CHECK": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CHECKSUM": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CROSS JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "DROP": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "fields", + "options": { + "parseField": "table" + } + }, + "FORCE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "FROM": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "from", + "options": { + "field": "table" + } + }, + "GROUP BY": { + "class": "PhpMyAdmin\\SqlParser\\Components\\GroupKeyword", + "field": "group" + }, + "HAVING": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "field": "having" + }, + "IGNORE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "INTO": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IntoKeyword", + "field": "into" + }, + "JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LEFT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LEFT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "ON": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "RIGHT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "RIGHT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "INNER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "FULL JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "FULL OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL LEFT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL RIGHT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL LEFT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL RIGHT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "STRAIGHT_JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LIMIT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Limit", + "field": "limit" + }, + "OPTIMIZE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "ORDER BY": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OrderKeyword", + "field": "order" + }, + "PARTITION": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ArrayObj", + "field": "partition" + }, + "PROCEDURE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\FunctionCall", + "field": "procedure" + }, + "RENAME": { + "class": "PhpMyAdmin\\SqlParser\\Components\\RenameOperation", + "field": "renames" + }, + "REPAIR": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "RESTORE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "SET": { + "class": "PhpMyAdmin\\SqlParser\\Components\\SetOperation", + "field": "set" + }, + "SELECT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "expr" + }, + "TRUNCATE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "UPDATE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "USE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "VALUE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Array2d", + "field": "values" + }, + "VALUES": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Array2d", + "field": "values" + }, + "WHERE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "field": "where" + } + }, + "list": { + "@type": "PhpMyAdmin\\SqlParser\\TokensList", + "tokens": [ + { + "@type": "@33" + }, + { + "@type": "@34" + }, + { + "@type": "@35" + }, + { + "@type": "@36" + }, + { + "@type": "@37" + }, + { + "@type": "@38" + }, + { + "@type": "@39" + }, + { + "@type": "@40" + } + ], + "count": 8, + "idx": 8 + }, + "statements": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Statements\\SelectStatement", + "OPTIONS": { + "ALL": 1, + "DISTINCT": 1, + "DISTINCTROW": 1, + "HIGH_PRIORITY": 2, + "MAX_STATEMENT_TIME": [ + 3, + "var=" + ], + "STRAIGHT_JOIN": 4, + "SQL_SMALL_RESULT": 5, + "SQL_BIG_RESULT": 6, + "SQL_BUFFER_RESULT": 7, + "SQL_CACHE": 8, + "SQL_NO_CACHE": 8, + "SQL_CALC_FOUND_ROWS": 9 + }, + "END_OPTIONS": { + "FOR UPDATE": 1, + "LOCK IN SHARE MODE": 1 + }, + "CLAUSES": { + "SELECT": [ + "SELECT", + 2 + ], + "_OPTIONS": [ + "_OPTIONS", + 1 + ], + "_SELECT": [ + "SELECT", + 1 + ], + "INTO": [ + "INTO", + 3 + ], + "FROM": [ + "FROM", + 3 + ], + "FORCE": [ + "FORCE", + 1 + ], + "USE": [ + "USE", + 1 + ], + "IGNORE": [ + "IGNORE", + 3 + ], + "PARTITION": [ + "PARTITION", + 3 + ], + "JOIN": [ + "JOIN", + 1 + ], + "FULL JOIN": [ + "FULL JOIN", + 1 + ], + "INNER JOIN": [ + "INNER JOIN", + 1 + ], + "LEFT JOIN": [ + "LEFT JOIN", + 1 + ], + "LEFT OUTER JOIN": [ + "LEFT OUTER JOIN", + 1 + ], + "RIGHT JOIN": [ + "RIGHT JOIN", + 1 + ], + "RIGHT OUTER JOIN": [ + "RIGHT OUTER JOIN", + 1 + ], + "NATURAL JOIN": [ + "NATURAL JOIN", + 1 + ], + "NATURAL LEFT JOIN": [ + "NATURAL LEFT JOIN", + 1 + ], + "NATURAL RIGHT JOIN": [ + "NATURAL RIGHT JOIN", + 1 + ], + "NATURAL LEFT OUTER JOIN": [ + "NATURAL LEFT OUTER JOIN", + 1 + ], + "NATURAL RIGHT OUTER JOIN": [ + "NATURAL RIGHT JOIN", + 1 + ], + "WHERE": [ + "WHERE", + 3 + ], + "GROUP BY": [ + "GROUP BY", + 3 + ], + "HAVING": [ + "HAVING", + 3 + ], + "ORDER BY": [ + "ORDER BY", + 3 + ], + "LIMIT": [ + "LIMIT", + 3 + ], + "PROCEDURE": [ + "PROCEDURE", + 3 + ], + "UNION": [ + "UNION", + 1 + ], + "EXCEPT": [ + "EXCEPT", + 1 + ], + "INTERSECT": [ + "INTERSECT", + 1 + ], + "_END_OPTIONS": [ + "_END_OPTIONS", + 1 + ] + }, + "expr": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "ALLOWED_KEYWORDS": { + "AS": 1, + "DUAL": 1, + "NULL": 1, + "REGEXP": 1, + "CASE": 1, + "DIV": 1, + "AND": 1, + "OR": 1, + "XOR": 1, + "NOT": 1, + "MOD": 1, + "OVER": 2 + }, + "database": null, + "table": null, + "column": "col1", + "expr": "col1", + "alias": null, + "function": null, + "subquery": null + } + ], + "from": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "ALLOWED_KEYWORDS": { + "AS": 1, + "DUAL": 1, + "NULL": 1, + "REGEXP": 1, + "CASE": 1, + "DIV": 1, + "AND": 1, + "OR": 1, + "XOR": 1, + "NOT": 1, + "MOD": 1, + "OVER": 2 + }, + "database": null, + "table": "cte", + "column": null, + "expr": "cte", + "alias": null, + "function": null, + "subquery": null + } + ], + "index_hints": null, + "partition": null, + "where": null, + "group": null, + "having": null, + "order": null, + "limit": null, + "procedure": null, + "into": null, + "join": null, + "union": [], + "end_options": null, + "options": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "options": [] + }, + "first": 0, + "last": 6 + } + ], + "brackets": 0, + "strict": false, + "errors": [] + }, "END_OPTIONS": [], "options": { "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", diff --git a/tests/data/parser/parseWithStatement7.out b/tests/data/parser/parseWithStatement7.out index 8b5c7d320..8dcef2eb2 100644 --- a/tests/data/parser/parseWithStatement7.out +++ b/tests/data/parser/parseWithStatement7.out @@ -1530,6 +1530,693 @@ } } }, + "cteStatementParser": { + "@type": "PhpMyAdmin\\SqlParser\\Parser", + "STATEMENT_PARSERS": { + "DESCRIBE": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "DESC": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "EXPLAIN": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement", + "FLUSH": "", + "GRANT": "", + "HELP": "", + "SET PASSWORD": "", + "STATUS": "", + "USE": "", + "ANALYZE": "PhpMyAdmin\\SqlParser\\Statements\\AnalyzeStatement", + "BACKUP": "PhpMyAdmin\\SqlParser\\Statements\\BackupStatement", + "CHECK": "PhpMyAdmin\\SqlParser\\Statements\\CheckStatement", + "CHECKSUM": "PhpMyAdmin\\SqlParser\\Statements\\ChecksumStatement", + "OPTIMIZE": "PhpMyAdmin\\SqlParser\\Statements\\OptimizeStatement", + "REPAIR": "PhpMyAdmin\\SqlParser\\Statements\\RepairStatement", + "RESTORE": "PhpMyAdmin\\SqlParser\\Statements\\RestoreStatement", + "SET": "PhpMyAdmin\\SqlParser\\Statements\\SetStatement", + "SHOW": "PhpMyAdmin\\SqlParser\\Statements\\ShowStatement", + "ALTER": "PhpMyAdmin\\SqlParser\\Statements\\AlterStatement", + "CREATE": "PhpMyAdmin\\SqlParser\\Statements\\CreateStatement", + "DROP": "PhpMyAdmin\\SqlParser\\Statements\\DropStatement", + "RENAME": "PhpMyAdmin\\SqlParser\\Statements\\RenameStatement", + "TRUNCATE": "PhpMyAdmin\\SqlParser\\Statements\\TruncateStatement", + "CALL": "PhpMyAdmin\\SqlParser\\Statements\\CallStatement", + "DELETE": "PhpMyAdmin\\SqlParser\\Statements\\DeleteStatement", + "DO": "", + "HANDLER": "", + "INSERT": "PhpMyAdmin\\SqlParser\\Statements\\InsertStatement", + "LOAD DATA": "PhpMyAdmin\\SqlParser\\Statements\\LoadStatement", + "REPLACE": "PhpMyAdmin\\SqlParser\\Statements\\ReplaceStatement", + "SELECT": "PhpMyAdmin\\SqlParser\\Statements\\SelectStatement", + "UPDATE": "PhpMyAdmin\\SqlParser\\Statements\\UpdateStatement", + "WITH": "PhpMyAdmin\\SqlParser\\Statements\\WithStatement", + "DEALLOCATE": "", + "EXECUTE": "", + "PREPARE": "", + "BEGIN": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "COMMIT": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "ROLLBACK": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "START TRANSACTION": "PhpMyAdmin\\SqlParser\\Statements\\TransactionStatement", + "PURGE": "PhpMyAdmin\\SqlParser\\Statements\\PurgeStatement", + "LOCK": "PhpMyAdmin\\SqlParser\\Statements\\LockStatement", + "UNLOCK": "PhpMyAdmin\\SqlParser\\Statements\\LockStatement" + }, + "KEYWORD_PARSERS": { + "PARTITION BY": [], + "SUBPARTITION BY": [], + "_OPTIONS": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "field": "options" + }, + "_END_OPTIONS": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "field": "end_options" + }, + "INTERSECT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "EXCEPT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION ALL": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "UNION DISTINCT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\UnionKeyword", + "field": "union" + }, + "ALTER": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "ANALYZE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "BACKUP": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CALL": { + "class": "PhpMyAdmin\\SqlParser\\Components\\FunctionCall", + "field": "call" + }, + "CHECK": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CHECKSUM": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "CROSS JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "DROP": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "fields", + "options": { + "parseField": "table" + } + }, + "FORCE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "FROM": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "from", + "options": { + "field": "table" + } + }, + "GROUP BY": { + "class": "PhpMyAdmin\\SqlParser\\Components\\GroupKeyword", + "field": "group" + }, + "HAVING": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "field": "having" + }, + "IGNORE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "INTO": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IntoKeyword", + "field": "into" + }, + "JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LEFT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LEFT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "ON": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "RIGHT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "RIGHT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "INNER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "FULL JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "FULL OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL LEFT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL RIGHT JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL LEFT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "NATURAL RIGHT OUTER JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "STRAIGHT_JOIN": { + "class": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "field": "join" + }, + "LIMIT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Limit", + "field": "limit" + }, + "OPTIMIZE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "ORDER BY": { + "class": "PhpMyAdmin\\SqlParser\\Components\\OrderKeyword", + "field": "order" + }, + "PARTITION": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ArrayObj", + "field": "partition" + }, + "PROCEDURE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\FunctionCall", + "field": "procedure" + }, + "RENAME": { + "class": "PhpMyAdmin\\SqlParser\\Components\\RenameOperation", + "field": "renames" + }, + "REPAIR": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "RESTORE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "SET": { + "class": "PhpMyAdmin\\SqlParser\\Components\\SetOperation", + "field": "set" + }, + "SELECT": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "expr" + }, + "TRUNCATE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "field": "table", + "options": { + "parseField": "table" + } + }, + "UPDATE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\ExpressionArray", + "field": "tables", + "options": { + "parseField": "table" + } + }, + "USE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\IndexHint", + "field": "index_hints" + }, + "VALUE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Array2d", + "field": "values" + }, + "VALUES": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Array2d", + "field": "values" + }, + "WHERE": { + "class": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "field": "where" + } + }, + "list": { + "@type": "PhpMyAdmin\\SqlParser\\TokensList", + "tokens": [ + { + "@type": "@26" + }, + { + "@type": "@27" + }, + { + "@type": "@28" + }, + { + "@type": "@29" + }, + { + "@type": "@30" + }, + { + "@type": "@31" + }, + { + "@type": "@32" + }, + { + "@type": "@33" + }, + { + "@type": "@34" + }, + { + "@type": "@35" + }, + { + "@type": "@36" + }, + { + "@type": "@37" + }, + { + "@type": "@38" + }, + { + "@type": "@39" + }, + { + "@type": "@40" + }, + { + "@type": "@41" + }, + { + "@type": "@42" + }, + { + "@type": "@43" + }, + { + "@type": "@44" + }, + { + "@type": "@45" + }, + { + "@type": "@46" + }, + { + "@type": "@47" + }, + { + "@type": "@48" + } + ], + "count": 23, + "idx": 23 + }, + "statements": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Statements\\SelectStatement", + "OPTIONS": { + "ALL": 1, + "DISTINCT": 1, + "DISTINCTROW": 1, + "HIGH_PRIORITY": 2, + "MAX_STATEMENT_TIME": [ + 3, + "var=" + ], + "STRAIGHT_JOIN": 4, + "SQL_SMALL_RESULT": 5, + "SQL_BIG_RESULT": 6, + "SQL_BUFFER_RESULT": 7, + "SQL_CACHE": 8, + "SQL_NO_CACHE": 8, + "SQL_CALC_FOUND_ROWS": 9 + }, + "END_OPTIONS": { + "FOR UPDATE": 1, + "LOCK IN SHARE MODE": 1 + }, + "CLAUSES": { + "SELECT": [ + "SELECT", + 2 + ], + "_OPTIONS": [ + "_OPTIONS", + 1 + ], + "_SELECT": [ + "SELECT", + 1 + ], + "INTO": [ + "INTO", + 3 + ], + "FROM": [ + "FROM", + 3 + ], + "FORCE": [ + "FORCE", + 1 + ], + "USE": [ + "USE", + 1 + ], + "IGNORE": [ + "IGNORE", + 3 + ], + "PARTITION": [ + "PARTITION", + 3 + ], + "JOIN": [ + "JOIN", + 1 + ], + "FULL JOIN": [ + "FULL JOIN", + 1 + ], + "INNER JOIN": [ + "INNER JOIN", + 1 + ], + "LEFT JOIN": [ + "LEFT JOIN", + 1 + ], + "LEFT OUTER JOIN": [ + "LEFT OUTER JOIN", + 1 + ], + "RIGHT JOIN": [ + "RIGHT JOIN", + 1 + ], + "RIGHT OUTER JOIN": [ + "RIGHT OUTER JOIN", + 1 + ], + "NATURAL JOIN": [ + "NATURAL JOIN", + 1 + ], + "NATURAL LEFT JOIN": [ + "NATURAL LEFT JOIN", + 1 + ], + "NATURAL RIGHT JOIN": [ + "NATURAL RIGHT JOIN", + 1 + ], + "NATURAL LEFT OUTER JOIN": [ + "NATURAL LEFT OUTER JOIN", + 1 + ], + "NATURAL RIGHT OUTER JOIN": [ + "NATURAL RIGHT JOIN", + 1 + ], + "WHERE": [ + "WHERE", + 3 + ], + "GROUP BY": [ + "GROUP BY", + 3 + ], + "HAVING": [ + "HAVING", + 3 + ], + "ORDER BY": [ + "ORDER BY", + 3 + ], + "LIMIT": [ + "LIMIT", + 3 + ], + "PROCEDURE": [ + "PROCEDURE", + 3 + ], + "UNION": [ + "UNION", + 1 + ], + "EXCEPT": [ + "EXCEPT", + 1 + ], + "INTERSECT": [ + "INTERSECT", + 1 + ], + "_END_OPTIONS": [ + "_END_OPTIONS", + 1 + ] + }, + "expr": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "ALLOWED_KEYWORDS": { + "AS": 1, + "DUAL": 1, + "NULL": 1, + "REGEXP": 1, + "CASE": 1, + "DIV": 1, + "AND": 1, + "OR": 1, + "XOR": 1, + "NOT": 1, + "MOD": 1, + "OVER": 2 + }, + "database": null, + "table": null, + "column": null, + "expr": "*", + "alias": null, + "function": null, + "subquery": null + } + ], + "from": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "ALLOWED_KEYWORDS": { + "AS": 1, + "DUAL": 1, + "NULL": 1, + "REGEXP": 1, + "CASE": 1, + "DIV": 1, + "AND": 1, + "OR": 1, + "XOR": 1, + "NOT": 1, + "MOD": 1, + "OVER": 2 + }, + "database": null, + "table": "cte", + "column": null, + "expr": "cte", + "alias": null, + "function": null, + "subquery": null + } + ], + "index_hints": null, + "partition": null, + "where": null, + "group": null, + "having": null, + "order": null, + "limit": null, + "procedure": null, + "into": null, + "join": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\JoinKeyword", + "JOINS": { + "CROSS JOIN": "CROSS", + "FULL JOIN": "FULL", + "FULL OUTER JOIN": "FULL", + "INNER JOIN": "INNER", + "JOIN": "JOIN", + "LEFT JOIN": "LEFT", + "LEFT OUTER JOIN": "LEFT", + "RIGHT JOIN": "RIGHT", + "RIGHT OUTER JOIN": "RIGHT", + "NATURAL JOIN": "NATURAL", + "NATURAL LEFT JOIN": "NATURAL LEFT", + "NATURAL RIGHT JOIN": "NATURAL RIGHT", + "NATURAL LEFT OUTER JOIN": "NATURAL LEFT OUTER", + "NATURAL RIGHT OUTER JOIN": "NATURAL RIGHT OUTER", + "STRAIGHT_JOIN": "STRAIGHT" + }, + "type": "INNER", + "expr": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "ALLOWED_KEYWORDS": { + "AS": 1, + "DUAL": 1, + "NULL": 1, + "REGEXP": 1, + "CASE": 1, + "DIV": 1, + "AND": 1, + "OR": 1, + "XOR": 1, + "NOT": 1, + "MOD": 1, + "OVER": 2 + }, + "database": null, + "table": "table2", + "column": null, + "expr": "table2", + "alias": null, + "function": null, + "subquery": null + }, + "on": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Condition", + "DELIMITERS": [ + "&&", + "||", + "AND", + "OR", + "XOR" + ], + "ALLOWED_KEYWORDS": { + "ALL": 1, + "AND": 1, + "BETWEEN": 1, + "EXISTS": 1, + "IF": 1, + "IN": 1, + "INTERVAL": 1, + "IS": 1, + "LIKE": 1, + "MATCH": 1, + "NOT IN": 1, + "NOT NULL": 1, + "NOT": 1, + "NULL": 1, + "OR": 1, + "REGEXP": 1, + "RLIKE": 1, + "SOUNDS": 1, + "XOR": 1 + }, + "identifiers": [ + "table2", + "col1", + "cte" + ], + "isOperator": false, + "expr": "table2.col1=cte.col1" + } + ], + "using": null + } + ], + "union": [], + "end_options": null, + "options": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "options": [] + }, + "first": 0, + "last": 20 + } + ], + "brackets": 0, + "strict": false, + "errors": [] + }, "END_OPTIONS": [], "options": { "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", diff --git a/tests/data/parser/parseWithStatementErr.out b/tests/data/parser/parseWithStatementErr.out index 5c8c48979..081cf7bf3 100644 --- a/tests/data/parser/parseWithStatementErr.out +++ b/tests/data/parser/parseWithStatementErr.out @@ -762,6 +762,7 @@ "statement": null } }, + "cteStatementParser": null, "END_OPTIONS": [], "options": { "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", diff --git a/tests/data/parser/parseWithStatementErr1.out b/tests/data/parser/parseWithStatementErr1.out index f50cdc921..7f75ec587 100644 --- a/tests/data/parser/parseWithStatementErr1.out +++ b/tests/data/parser/parseWithStatementErr1.out @@ -934,6 +934,7 @@ "statement": null } }, + "cteStatementParser": null, "END_OPTIONS": [], "options": { "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", diff --git a/tests/data/parser/parseWithStatementErr2.out b/tests/data/parser/parseWithStatementErr2.out index d6a737148..6d69f8fe3 100644 --- a/tests/data/parser/parseWithStatementErr2.out +++ b/tests/data/parser/parseWithStatementErr2.out @@ -1323,6 +1323,7 @@ } } }, + "cteStatementParser": null, "END_OPTIONS": [], "options": { "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", diff --git a/tests/data/parser/parseWithStatementErr3.out b/tests/data/parser/parseWithStatementErr3.out index 2749b9518..ceaf1a827 100644 --- a/tests/data/parser/parseWithStatementErr3.out +++ b/tests/data/parser/parseWithStatementErr3.out @@ -1626,6 +1626,7 @@ } } }, + "cteStatementParser": null, "END_OPTIONS": [], "options": { "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", diff --git a/tests/data/parser/parseWithStatementErr4.out b/tests/data/parser/parseWithStatementErr4.out index 3231428ee..cf24c4b0b 100644 --- a/tests/data/parser/parseWithStatementErr4.out +++ b/tests/data/parser/parseWithStatementErr4.out @@ -1635,6 +1635,7 @@ } } }, + "cteStatementParser": null, "END_OPTIONS": [], "options": { "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", diff --git a/tests/data/parser/parseWithStatementErr5.out b/tests/data/parser/parseWithStatementErr5.out index 5b3fe7418..5a78e93e3 100644 --- a/tests/data/parser/parseWithStatementErr5.out +++ b/tests/data/parser/parseWithStatementErr5.out @@ -863,6 +863,7 @@ ] }, "withers": [], + "cteStatementParser": null, "END_OPTIONS": [], "options": { "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", diff --git a/tests/data/parser/parseWithStatementErr6.out b/tests/data/parser/parseWithStatementErr6.out index d538640e1..9add092a0 100644 --- a/tests/data/parser/parseWithStatementErr6.out +++ b/tests/data/parser/parseWithStatementErr6.out @@ -1069,6 +1069,7 @@ "statement": null } }, + "cteStatementParser": null, "END_OPTIONS": [], "options": { "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", diff --git a/tests/data/parser/parseWithStatementErr7.out b/tests/data/parser/parseWithStatementErr7.out index 163edc50b..f6bf16633 100644 --- a/tests/data/parser/parseWithStatementErr7.out +++ b/tests/data/parser/parseWithStatementErr7.out @@ -676,6 +676,7 @@ "statement": null } }, + "cteStatementParser": null, "END_OPTIONS": [], "options": { "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", diff --git a/tests/data/parser/parseWithStatementErr8.out b/tests/data/parser/parseWithStatementErr8.out index a31251f51..75bcc232f 100644 --- a/tests/data/parser/parseWithStatementErr8.out +++ b/tests/data/parser/parseWithStatementErr8.out @@ -1395,12 +1395,208 @@ } } }, + "cteStatementParser": null, "END_OPTIONS": [], "options": { "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", "options": [] }, "first": 0, + "last": 23 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Statements\\SelectStatement", + "OPTIONS": { + "ALL": 1, + "DISTINCT": 1, + "DISTINCTROW": 1, + "HIGH_PRIORITY": 2, + "MAX_STATEMENT_TIME": [ + 3, + "var=" + ], + "STRAIGHT_JOIN": 4, + "SQL_SMALL_RESULT": 5, + "SQL_BIG_RESULT": 6, + "SQL_BUFFER_RESULT": 7, + "SQL_CACHE": 8, + "SQL_NO_CACHE": 8, + "SQL_CALC_FOUND_ROWS": 9 + }, + "END_OPTIONS": { + "FOR UPDATE": 1, + "LOCK IN SHARE MODE": 1 + }, + "CLAUSES": { + "SELECT": [ + "SELECT", + 2 + ], + "_OPTIONS": [ + "_OPTIONS", + 1 + ], + "_SELECT": [ + "SELECT", + 1 + ], + "INTO": [ + "INTO", + 3 + ], + "FROM": [ + "FROM", + 3 + ], + "FORCE": [ + "FORCE", + 1 + ], + "USE": [ + "USE", + 1 + ], + "IGNORE": [ + "IGNORE", + 3 + ], + "PARTITION": [ + "PARTITION", + 3 + ], + "JOIN": [ + "JOIN", + 1 + ], + "FULL JOIN": [ + "FULL JOIN", + 1 + ], + "INNER JOIN": [ + "INNER JOIN", + 1 + ], + "LEFT JOIN": [ + "LEFT JOIN", + 1 + ], + "LEFT OUTER JOIN": [ + "LEFT OUTER JOIN", + 1 + ], + "RIGHT JOIN": [ + "RIGHT JOIN", + 1 + ], + "RIGHT OUTER JOIN": [ + "RIGHT OUTER JOIN", + 1 + ], + "NATURAL JOIN": [ + "NATURAL JOIN", + 1 + ], + "NATURAL LEFT JOIN": [ + "NATURAL LEFT JOIN", + 1 + ], + "NATURAL RIGHT JOIN": [ + "NATURAL RIGHT JOIN", + 1 + ], + "NATURAL LEFT OUTER JOIN": [ + "NATURAL LEFT OUTER JOIN", + 1 + ], + "NATURAL RIGHT OUTER JOIN": [ + "NATURAL RIGHT JOIN", + 1 + ], + "WHERE": [ + "WHERE", + 3 + ], + "GROUP BY": [ + "GROUP BY", + 3 + ], + "HAVING": [ + "HAVING", + 3 + ], + "ORDER BY": [ + "ORDER BY", + 3 + ], + "LIMIT": [ + "LIMIT", + 3 + ], + "PROCEDURE": [ + "PROCEDURE", + 3 + ], + "UNION": [ + "UNION", + 1 + ], + "EXCEPT": [ + "EXCEPT", + 1 + ], + "INTERSECT": [ + "INTERSECT", + 1 + ], + "_END_OPTIONS": [ + "_END_OPTIONS", + 1 + ] + }, + "expr": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "ALLOWED_KEYWORDS": { + "AS": 1, + "DUAL": 1, + "NULL": 1, + "REGEXP": 1, + "CASE": 1, + "DIV": 1, + "AND": 1, + "OR": 1, + "XOR": 1, + "NOT": 1, + "MOD": 1, + "OVER": 2 + }, + "database": null, + "table": null, + "column": "col1", + "expr": "col1", + "alias": "FR", + "function": null, + "subquery": null + } + ], + "from": [], + "index_hints": null, + "partition": null, + "where": null, + "group": null, + "having": null, + "order": null, + "limit": null, + "procedure": null, + "into": null, + "join": null, + "union": [], + "end_options": null, + "options": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "options": [] + }, + "first": 24, "last": 30 } ], @@ -1411,6 +1607,20 @@ "errors": { "lexer": [], "parser": [ + [ + "An alias was previously found.", + { + "@type": "@32" + }, + 0 + ], + [ + "Unexpected token.", + { + "@type": "@32" + }, + 0 + ], [ "An alias was previously found.", { From bd86fb3c6989c11062155a58abd273bed8ff1d51 Mon Sep 17 00:00:00 2001 From: "Fawzi E. Abdulfattah" Date: Tue, 7 Dec 2021 12:07:22 +0200 Subject: [PATCH 11/12] handle: cteStatementParser could be null Signed-off-by: Fawzi E. Abdulfattah --- src/Statements/WithStatement.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Statements/WithStatement.php b/src/Statements/WithStatement.php index fc8de2438..5740495e9 100644 --- a/src/Statements/WithStatement.php +++ b/src/Statements/WithStatement.php @@ -63,7 +63,7 @@ final class WithStatement extends Statement /** * holds the CTE parser. * - * @var Parser + * @var Parser|null */ public $cteStatementParser; @@ -290,8 +290,10 @@ public function build() $str .= ' '; - foreach ($this->cteStatementParser->statements as $statement) { - $str .= $statement->build(); + if ($this->cteStatementParser) { + foreach ($this->cteStatementParser->statements as $statement) { + $str .= $statement->build(); + } } return $str; From c8f72ec53193e416eaf3344ce5c4114cc842ba5d Mon Sep 17 00:00:00 2001 From: "Fawzi E. Abdulfattah" Date: Sat, 11 Dec 2021 13:40:33 +0200 Subject: [PATCH 12/12] remove duplicated test Signed-off-by: Fawzi E. Abdulfattah --- tests/Builder/CreateStatementTest.php | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/tests/Builder/CreateStatementTest.php b/tests/Builder/CreateStatementTest.php index 8b6a36edc..942e4c747 100644 --- a/tests/Builder/CreateStatementTest.php +++ b/tests/Builder/CreateStatementTest.php @@ -324,17 +324,6 @@ public function testBuilderView(): void $stmt->build() ); - $parser = new Parser( - 'CREATE OR REPLACE VIEW myView (vid, vfirstname) AS ' . - 'SELECT id, first_name, FROMzz employee WHERE id = 1' - ); - $stmt = $parser->statements[0]; - $this->assertEquals( - 'CREATE OR REPLACE VIEW myView (vid, vfirstname) AS ' . - 'SELECT id, first_name, FROMzz employee WHERE id = 1 ', - $stmt->build() - ); - $parser = new Parser( 'CREATE OR REPLACE VIEW myView (vid, vfirstname) AS ' . 'SELECT id, first_name, FROMzz employee WHERE id = 1 ' .