Skip to content

Commit 38ae646

Browse files
authored
[MySql] Support mixed-parenthesis syntax for unions (#3824)
1 parent d939aad commit 38ae646

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

sql/mysql/Positive-Technologies/MySqlParser.g4

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,8 @@ replaceStatement
901901
selectStatement
902902
: querySpecification lockClause? #simpleSelect
903903
| queryExpression lockClause? #parenthesisSelect
904-
| querySpecificationNointo unionStatement+
904+
| (querySpecificationNointo | queryExpressionNointo)
905+
unionStatement+
905906
(
906907
UNION unionType=(ALL | DISTINCT)?
907908
(querySpecification | queryExpression)

sql/mysql/Positive-Technologies/examples/ddl_create.sql

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,3 +683,34 @@ SELECT
683683
,@N_latin;
684684
END
685685
#end
686+
687+
#begin
688+
CREATE PROCEDURE test_union()
689+
BEGIN
690+
(SELECT id FROM test_auto_inc)
691+
UNION ALL
692+
SELECT id FROM test_auto_inc;
693+
END
694+
#end
695+
696+
#begin
697+
CREATE PROCEDURE test_union()
698+
BEGIN
699+
(SELECT id FROM test_auto_inc)
700+
UNION ALL
701+
SELECT id FROM test_auto_inc
702+
UNION ALL
703+
SELECT id FROM test_auto_inc ORDER BY id;
704+
END
705+
#end
706+
707+
#begin
708+
CREATE PROCEDURE test_union()
709+
BEGIN
710+
(SELECT id FROM test_auto_inc)
711+
UNION ALL
712+
(SELECT id FROM test_auto_inc)
713+
UNION ALL
714+
SELECT id FROM test_auto_inc ORDER BY id;
715+
END
716+
#end

0 commit comments

Comments
 (0)