GeezerVison is showing github.com — Fix way end of functions, procedures and triggers' bodies is identified · phpmyadmin/sql-parser@0ebfa9c
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: src/Statements/CreateStatement.php +8Lines changed: 8 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -718,6 +718,10 @@ public function parse(Parser $parser, TokensList $list) |
718 | 718 |
|
719 | 719 | for (; $list->idx < $list->count; ++$list->idx) { |
720 | 720 | $token = $list->tokens[$list->idx]; |
| 721 | + if ($token->type === Token::TYPE_DELIMITER) { |
| 722 | + break; |
| 723 | + } |
| 724 | + |
721 | 725 | $this->body[] = $token; |
722 | 726 | } |
723 | 727 | } elseif ($this->options->has('VIEW')) { |
@@ -781,6 +785,10 @@ public function parse(Parser $parser, TokensList $list) |
781 | 785 |
|
782 | 786 | for (; $list->idx < $list->count; ++$list->idx) { |
783 | 787 | $token = $list->tokens[$list->idx]; |
| 788 | + if ($token->type === Token::TYPE_DELIMITER) { |
| 789 | + break; |
| 790 | + } |
| 791 | + |
784 | 792 | $this->body[] = $token; |
785 | 793 | } |
786 | 794 | } else { |
|
Collapse file
Copy file name to clipboardExpand all lines: tests/Builder/CreateStatementTest.php +3-1Lines changed: 3 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -520,7 +520,8 @@ public function testBuilderCreateProcedure(): void |
520 | 520 | public function testBuilderCreateFunction(): void |
521 | 521 | { |
522 | 522 | $parser = new Parser( |
523 | | - 'CREATE DEFINER=`root`@`localhost`' |
| 523 | + 'DELIMITER $$' . "\n" |
| 524 | + . 'CREATE DEFINER=`root`@`localhost`' |
524 | 525 | . ' FUNCTION `inventory_in_stock`(`p_inventory_id` INT) RETURNS tinyint(1)' |
525 | 526 | . ' READS SQL DATA' |
526 | 527 | . ' COMMENT \'My best function written by a friend\'\'s friend\'' |
@@ -663,6 +664,7 @@ public function testBuilderTrigger(): void |
663 | 664 | public function testBuilderRoutine(): void |
664 | 665 | { |
665 | 666 | $parser = new Parser( |
| 667 | + 'DELIMITER $$' . "\n" . |
666 | 668 | 'CREATE FUNCTION test (IN `i` INT) RETURNS VARCHAR ' . |
667 | 669 | 'BEGIN ' . |
668 | 670 | 'DECLARE name VARCHAR DEFAULT ""; ' . |
|
Collapse file
Copy file name to clipboardExpand all lines: tests/Parser/ParserLongExportsTest.php +3Lines changed: 3 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -89,6 +89,9 @@ public function testParsephpMyAdminDump(): void |
89 | 89 | 'SET @OLD_CHARACTER_SET_RESULTS = @@CHARACTER_SET_RESULTS', |
90 | 90 | 'SET @OLD_COLLATION_CONNECTION = @@COLLATION_CONNECTION', |
91 | 91 | 'SET NAMES utf8mb4', |
| 92 | + 'SET CHARACTER_SET_CLIENT = @OLD_CHARACTER_SET_CLIENT', |
| 93 | + 'SET CHARACTER_SET_RESULTS = @OLD_CHARACTER_SET_RESULTS', |
| 94 | + 'SET COLLATION_CONNECTION = @OLD_COLLATION_CONNECTION', |
92 | 95 | ], $collectedSetStatements); |
93 | 96 |
|
94 | 97 | foreach ($parser->statements as $stmt) { |
|
Collapse file
Copy file name to clipboardExpand all lines: tests/data/parser/parseCreateFunction.in +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +DELIMITER $$ |
1 | 2 | CREATE FUNCTION F_TEST(uid INT) RETURNS VARCHAR |
2 | 3 | BEGIN |
3 | 4 | DECLARE username VARCHAR DEFAULT ""; |
|