Skip to content

Commit bed4e84

Browse files
committed
MDEV-8380: Subquery parse error
backport mysql parser fixes 0034963fbf199696792491bcb79d5f0731c98804 5948561812bc691bd0c13cf518a3fe77d9daf920
1 parent d6371d3 commit bed4e84

14 files changed

+780
-101
lines changed

mysql-test/r/parser.result

Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,3 +650,230 @@ CREATE TABLE t1(a INT);
650650
SELECT * FROM t1 JOIN ((SELECT 1 AS b) UNION ALL (SELECT 2 AS b) ORDER BY b DESC) s1 WHERE a=1;
651651
a b
652652
DROP TABLE t1;
653+
#
654+
# Test of collective fix for three parser bugs:
655+
#
656+
# Bug #17727401, Bug #17426017, Bug #17473479:
657+
# The server accepts wrong syntax and then fails in different ways
658+
#
659+
CREATE TABLE t1 (i INT);
660+
# bug #17426017
661+
SELECT (SELECT EXISTS(SELECT * LIMIT 1 ORDER BY VALUES (c00)));
662+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ORDER BY VALUES (c00)))' at line 1
663+
# bug#17473479
664+
CREATE TABLE a(a int);
665+
CREATE TABLE b(a int);
666+
DELETE FROM b ORDER BY(SELECT 1 FROM a ORDER BY a ORDER BY a);
667+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ORDER BY a)' at line 1
668+
DROP TABLE a, b;
669+
# bug #17727401
670+
SELECT '' IN (SELECT '1' c FROM t1 ORDER BY '' ORDER BY '') FROM t1;
671+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ORDER BY '') FROM t1' at line 1
672+
# regression & coverage tests
673+
# uniform syntax for FROM DUAL clause:
674+
SELECT 1 FROM DUAL WHERE 1 GROUP BY 1 HAVING 1 ORDER BY 1
675+
FOR UPDATE;
676+
1
677+
1
678+
SELECT 1 FROM DUAL WHERE 1 GROUP BY 1 HAVING 1 ORDER BY 1
679+
PROCEDURE ANALYSE() FOR UPDATE;
680+
ERROR HY000: Can't use ORDER clause with this procedure
681+
SELECT 1 FROM
682+
(SELECT 1 FROM DUAL WHERE 1 GROUP BY 1 HAVING 1 ORDER BY 1
683+
FOR UPDATE) a;
684+
1
685+
1
686+
SELECT 1 FROM
687+
(SELECT 1 FROM DUAL WHERE 1 GROUP BY 1 HAVING 1 ORDER BY 1
688+
PROCEDURE ANALYSE() FOR UPDATE) a;
689+
ERROR HY000: Incorrect usage of PROCEDURE and subquery
690+
SELECT 1 FROM t1
691+
WHERE EXISTS(SELECT 1 FROM DUAL WHERE 1 GROUP BY 1 HAVING 1 ORDER BY 1
692+
FOR UPDATE);
693+
1
694+
SELECT 1 FROM t1
695+
WHERE EXISTS(SELECT 1 FROM DUAL WHERE 1 GROUP BY 1 HAVING 1 ORDER BY 1
696+
PROCEDURE ANALYSE() FOR UPDATE);
697+
ERROR HY000: Incorrect usage of PROCEDURE and subquery
698+
SELECT 1 FROM t1
699+
UNION
700+
SELECT 1 FROM DUAL WHERE 1 GROUP BY 1 HAVING 1 ORDER BY 1
701+
FOR UPDATE;
702+
1
703+
1
704+
SELECT 1 FROM t1
705+
UNION
706+
SELECT 1 FROM DUAL WHERE 1 GROUP BY 1 HAVING 1 ORDER BY 1
707+
PROCEDURE ANALYSE() FOR UPDATE;
708+
ERROR HY000: Incorrect usage of PROCEDURE and subquery
709+
SELECT 1 FROM DUAL PROCEDURE ANALYSE()
710+
UNION
711+
SELECT 1 FROM t1;
712+
ERROR HY000: Incorrect usage of UNION and SELECT ... PROCEDURE ANALYSE()
713+
(SELECT 1 FROM t1)
714+
UNION
715+
(SELECT 1 FROM DUAL WHERE 1 GROUP BY 1 HAVING 1 ORDER BY 1
716+
FOR UPDATE);
717+
1
718+
1
719+
(SELECT 1 FROM t1)
720+
UNION
721+
(SELECT 1 FROM DUAL WHERE 1 GROUP BY 1 HAVING 1 ORDER BY 1
722+
PROCEDURE ANALYSE() FOR UPDATE);
723+
ERROR HY000: Incorrect usage of PROCEDURE and subquery
724+
# "FOR UPDATE" tests
725+
SELECT 1 FROM t1 UNION SELECT 1 FROM t1 ORDER BY 1 LIMIT 1;
726+
1
727+
SELECT 1 FROM t1 FOR UPDATE UNION SELECT 1 FROM t1 ORDER BY 1 LIMIT 1;
728+
1
729+
SELECT 1 FROM t1 UNION SELECT 1 FROM t1 ORDER BY 1 LIMIT 1 FOR UPDATE;
730+
1
731+
# "INTO" clause tests
732+
SELECT 1 FROM t1 INTO @var17727401;
733+
Warnings:
734+
Warning 1329 No data - zero rows fetched, selected, or processed
735+
SELECT 1 FROM DUAL INTO @var17727401;
736+
SELECT 1 INTO @var17727401;
737+
SELECT 1 INTO @var17727401 FROM t1;
738+
Warnings:
739+
Warning 1329 No data - zero rows fetched, selected, or processed
740+
SELECT 1 INTO @var17727401 FROM DUAL;
741+
SELECT 1 INTO @var17727401_1 FROM t1 INTO @var17727401_2;
742+
ERROR HY000: Incorrect usage of INTO and INTO
743+
SELECT 1 INTO @var17727401_1 FROM DUAL
744+
INTO @var17727401_2;
745+
ERROR HY000: Incorrect usage of INTO and INTO
746+
SELECT 1 INTO @var17727401 FROM t1 WHERE 1 GROUP BY 1 HAVING 1 ORDER BY 1 LIMIT 1;
747+
Warnings:
748+
Warning 1329 No data - zero rows fetched, selected, or processed
749+
SELECT 1 FROM t1 WHERE 1 GROUP BY 1 HAVING 1 ORDER BY 1 LIMIT 1 INTO @var17727401;
750+
Warnings:
751+
Warning 1329 No data - zero rows fetched, selected, or processed
752+
SELECT 1 FROM t1 WHERE 1 INTO @var17727401 GROUP BY 1 HAVING 1 ORDER BY 1 LIMIT 1;
753+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'GROUP BY 1 HAVING 1 ORDER BY 1 LIMIT 1' at line 1
754+
SELECT 1 INTO @var17727401_1
755+
FROM t1 WHERE 1 GROUP BY 1 HAVING 1 ORDER BY 1 LIMIT 1
756+
INTO @var17727401_2;
757+
ERROR HY000: Incorrect usage of INTO and INTO
758+
SELECT (SELECT 1 FROM t1 INTO @var17727401);
759+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'INTO @var17727401)' at line 1
760+
SELECT 1 FROM (SELECT 1 FROM t1 INTO @var17727401) a;
761+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'INTO @var17727401) a' at line 1
762+
SELECT EXISTS(SELECT 1 FROM t1 INTO @var17727401);
763+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'INTO @var17727401)' at line 1
764+
SELECT 1 FROM t1 INTO @var17727401 UNION SELECT 1 FROM t1 INTO t1;
765+
ERROR HY000: Incorrect usage of UNION and INTO
766+
(SELECT 1 FROM t1 INTO @var17727401) UNION (SELECT 1 FROM t1 INTO t1);
767+
ERROR HY000: Incorrect usage of UNION and INTO
768+
SELECT 1 FROM t1 UNION SELECT 1 FROM t1 INTO @var17727401;
769+
Warnings:
770+
Warning 1329 No data - zero rows fetched, selected, or processed
771+
SELECT 1 INTO @var17727401 FROM t1 PROCEDURE ANALYSE();
772+
ERROR HY000: Incorrect usage of PROCEDURE and INTO
773+
SELECT 1 FROM t1 PROCEDURE ANALYSE() INTO @var17727401;
774+
ERROR HY000: Incorrect usage of PROCEDURE and INTO
775+
# ORDER and LIMIT clause combinations
776+
(SELECT 1 FROM t1 ORDER BY 1) ORDER BY 1;
777+
1
778+
(SELECT 1 FROM t1 LIMIT 1) LIMIT 1;
779+
1
780+
((SELECT 1 FROM t1 ORDER BY 1) ORDER BY 1) ORDER BY 1;
781+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ORDER BY 1) ORDER BY 1' at line 1
782+
((SELECT 1 FROM t1 LIMIT 1) LIMIT 1) LIMIT 1;
783+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'LIMIT 1) LIMIT 1' at line 1
784+
(SELECT 1 FROM t1 ORDER BY 1) LIMIT 1;
785+
1
786+
(SELECT 1 FROM t1 LIMIT 1) ORDER BY 1;
787+
1
788+
((SELECT 1 FROM t1 ORDER BY 1) LIMIT 1) ORDER BY 1);
789+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'LIMIT 1) ORDER BY 1)' at line 1
790+
((SELECT 1 FROM t1 LIMIT 1) ORDER BY 1) LIMIT 1);
791+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ORDER BY 1) LIMIT 1)' at line 1
792+
SELECT 1 FROM t1 UNION SELECT 1 FROM t1 ORDER BY 1;
793+
1
794+
SELECT (SELECT 1 FROM t1 UNION SELECT 1 FROM t1 ORDER BY 1);
795+
(SELECT 1 FROM t1 UNION SELECT 1 FROM t1 ORDER BY 1)
796+
NULL
797+
SELECT 1 FROM (SELECT 1 FROM t1 UNION SELECT 1 FROM t1 ORDER BY 1) a;
798+
1
799+
SELECT 1 FROM t1 UNION SELECT 1 FROM t1 LIMIT 1;
800+
1
801+
SELECT (SELECT 1 FROM t1 UNION SELECT 1 FROM t1 LIMIT 1);
802+
(SELECT 1 FROM t1 UNION SELECT 1 FROM t1 LIMIT 1)
803+
NULL
804+
SELECT 1 FROM (SELECT 1 FROM t1 UNION SELECT 1 FROM t1 LIMIT 1) a;
805+
1
806+
SELECT 1 FROM t1 UNION SELECT 1 FROM t1 ORDER BY 1 LIMIT 1;
807+
1
808+
SELECT (SELECT 1 FROM t1 UNION SELECT 1 FROM t1 ORDER BY 1 LIMIT 1);
809+
(SELECT 1 FROM t1 UNION SELECT 1 FROM t1 ORDER BY 1 LIMIT 1)
810+
NULL
811+
SELECT 1 FROM (SELECT 1 FROM t1 UNION SELECT 1 FROM t1 ORDER BY 1 LIMIT 1) a;
812+
1
813+
SELECT 1 FROM t1 UNION SELECT 1 FROM t1 LIMIT 1 ORDER BY 1;
814+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ORDER BY 1' at line 1
815+
SELECT (SELECT 1 FROM t1 UNION SELECT 1 FROM t1 LIMIT 1 ORDER BY 1);
816+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ORDER BY 1)' at line 1
817+
SELECT 1 FROM (SELECT 1 FROM t1 UNION SELECT 1 FROM t1 LIMIT 1 ORDER BY 1) a;
818+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ORDER BY 1) a' at line 1
819+
SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1;
820+
ERROR HY000: Incorrect usage of UNION and ORDER BY
821+
SELECT (SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1);
822+
ERROR HY000: Incorrect usage of UNION and ORDER BY
823+
SELECT 1 FROM (SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1) a;
824+
ERROR HY000: Incorrect usage of UNION and ORDER BY
825+
SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1;
826+
ERROR HY000: Incorrect usage of UNION and LIMIT
827+
SELECT (SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1);
828+
ERROR HY000: Incorrect usage of UNION and LIMIT
829+
SELECT 1 FROM (SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1) a;
830+
ERROR HY000: Incorrect usage of UNION and LIMIT
831+
SELECT 1 FROM t1 ORDER BY 1 LIMIT 1 UNION SELECT 1 FROM t1;
832+
ERROR HY000: Incorrect usage of UNION and ORDER BY
833+
SELECT (SELECT 1 FROM t1 ORDER BY 1 LIMIT 1 UNION SELECT 1 FROM t1);
834+
ERROR HY000: Incorrect usage of UNION and ORDER BY
835+
SELECT 1 FROM (SELECT 1 FROM t1 ORDER BY 1 LIMIT 1 UNION SELECT 1 FROM t1) a;
836+
ERROR HY000: Incorrect usage of UNION and ORDER BY
837+
SELECT 1 FROM t1 LIMIT 1 ORDER BY 1 UNION SELECT 1 FROM t1;
838+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ORDER BY 1 UNION SELECT 1 FROM t1' at line 1
839+
SELECT (SELECT 1 FROM t1 LIMIT 1 ORDER BY 1 UNION SELECT 1 FROM t1);
840+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ORDER BY 1 UNION SELECT 1 FROM t1)' at line 1
841+
SELECT 1 FROM (SELECT 1 FROM t1 LIMIT 1 ORDER BY 1 UNION SELECT 1 FROM t1) a;
842+
ERROR HY000: Incorrect usage of UNION and ORDER BY
843+
SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1 ORDER BY 1;
844+
ERROR HY000: Incorrect usage of UNION and ORDER BY
845+
SELECT (SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1 ORDER BY 1);
846+
ERROR HY000: Incorrect usage of UNION and ORDER BY
847+
SELECT 1 FROM (SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1 ORDER BY 1) a;
848+
ERROR HY000: Incorrect usage of UNION and ORDER BY
849+
SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1 LIMIT 1;
850+
ERROR HY000: Incorrect usage of UNION and LIMIT
851+
SELECT (SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1 LIMIT 1);
852+
ERROR HY000: Incorrect usage of UNION and LIMIT
853+
SELECT 1 FROM (SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1 LIMIT 1) a;
854+
ERROR HY000: Incorrect usage of UNION and LIMIT
855+
SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1 ORDER BY 1;
856+
ERROR HY000: Incorrect usage of UNION and LIMIT
857+
SELECT (SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1 ORDER BY 1);
858+
ERROR HY000: Incorrect usage of UNION and LIMIT
859+
SELECT 1 FROM (SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1 ORDER BY 1) a;
860+
ERROR HY000: Incorrect usage of UNION and LIMIT
861+
SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1 LIMIT 1;
862+
ERROR HY000: Incorrect usage of UNION and ORDER BY
863+
SELECT (SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1 LIMIT 1);
864+
ERROR HY000: Incorrect usage of UNION and ORDER BY
865+
SELECT 1 FROM (SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1 LIMIT 1) a;
866+
ERROR HY000: Incorrect usage of UNION and ORDER BY
867+
DROP TABLE t1;
868+
#
869+
# MDEV-8380: Subquery parse error
870+
#
871+
CREATE TABLE t1 ( a INT);
872+
INSERT INTO t1 VALUES ( 2 );
873+
SELECT *
874+
FROM ( (SELECT a FROM t1 ORDER BY a) UNION (SELECT 1 as b ORDER BY b ) ) AS a1
875+
WHERE a1.a = 1 OR a1.a = 2;
876+
a
877+
2
878+
1
879+
DROP TABLE t1;

mysql-test/r/subselect.result

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5138,8 +5138,9 @@ SELECT a FROM t1 WHERE a = 2
51385138
a
51395139
1
51405140
2
5141-
SELECT * FROM ((SELECT 1 a) UNION SELECT 1 a);
5142-
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')' at line 1
5141+
SELECT * FROM ((SELECT 1 a) UNION SELECT 1 a) q;
5142+
a
5143+
1
51435144
SELECT * FROM (SELECT 1 a UNION (SELECT 1 a)) alias;
51445145
a
51455146
1
@@ -5181,7 +5182,7 @@ a 1
51815182
1 1
51825183
2 1
51835184
SELECT * FROM t1 JOIN ((SELECT 1 UNION SELECT 1)) ON 1;
5184-
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')) ON 1' at line 1
5185+
ERROR 42000: Every derived table must have its own alias
51855186
SELECT * FROM t1 JOIN (t1 t1a UNION SELECT 1) ON 1;
51865187
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ') ON 1' at line 1
51875188
SELECT * FROM t1 JOIN ((t1 t1a UNION SELECT 1)) ON 1;
@@ -5300,7 +5301,10 @@ SELECT ((SELECT 1 UNION SELECT 1 UNION SELECT 1));
53005301
SELECT * FROM ( SELECT 1 UNION ( SELECT 1 UNION SELECT 1 ) );
53015302
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UNION SELECT 1 ) )' at line 1
53025303
SELECT * FROM ( ( SELECT 1 UNION SELECT 1 ) UNION SELECT 1 );
5303-
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ') UNION SELECT 1 )' at line 1
5304+
ERROR 42000: Every derived table must have its own alias
5305+
SELECT * FROM ( ( SELECT 1 UNION SELECT 1 ) UNION SELECT 1 ) a;
5306+
1
5307+
1
53045308
SELECT * FROM ( SELECT 1 UNION SELECT 1 UNION SELECT 1 ) a;
53055309
1
53065310
1

mysql-test/r/subselect_no_exists_to_in.result

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5140,8 +5140,9 @@ SELECT a FROM t1 WHERE a = 2
51405140
a
51415141
1
51425142
2
5143-
SELECT * FROM ((SELECT 1 a) UNION SELECT 1 a);
5144-
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')' at line 1
5143+
SELECT * FROM ((SELECT 1 a) UNION SELECT 1 a) q;
5144+
a
5145+
1
51455146
SELECT * FROM (SELECT 1 a UNION (SELECT 1 a)) alias;
51465147
a
51475148
1
@@ -5183,7 +5184,7 @@ a 1
51835184
1 1
51845185
2 1
51855186
SELECT * FROM t1 JOIN ((SELECT 1 UNION SELECT 1)) ON 1;
5186-
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')) ON 1' at line 1
5187+
ERROR 42000: Every derived table must have its own alias
51875188
SELECT * FROM t1 JOIN (t1 t1a UNION SELECT 1) ON 1;
51885189
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ') ON 1' at line 1
51895190
SELECT * FROM t1 JOIN ((t1 t1a UNION SELECT 1)) ON 1;
@@ -5302,7 +5303,10 @@ SELECT ((SELECT 1 UNION SELECT 1 UNION SELECT 1));
53025303
SELECT * FROM ( SELECT 1 UNION ( SELECT 1 UNION SELECT 1 ) );
53035304
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UNION SELECT 1 ) )' at line 1
53045305
SELECT * FROM ( ( SELECT 1 UNION SELECT 1 ) UNION SELECT 1 );
5305-
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ') UNION SELECT 1 )' at line 1
5306+
ERROR 42000: Every derived table must have its own alias
5307+
SELECT * FROM ( ( SELECT 1 UNION SELECT 1 ) UNION SELECT 1 ) a;
5308+
1
5309+
1
53065310
SELECT * FROM ( SELECT 1 UNION SELECT 1 UNION SELECT 1 ) a;
53075311
1
53085312
1

mysql-test/r/subselect_no_mat.result

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5138,8 +5138,9 @@ SELECT a FROM t1 WHERE a = 2
51385138
a
51395139
1
51405140
2
5141-
SELECT * FROM ((SELECT 1 a) UNION SELECT 1 a);
5142-
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')' at line 1
5141+
SELECT * FROM ((SELECT 1 a) UNION SELECT 1 a) q;
5142+
a
5143+
1
51435144
SELECT * FROM (SELECT 1 a UNION (SELECT 1 a)) alias;
51445145
a
51455146
1
@@ -5181,7 +5182,7 @@ a 1
51815182
1 1
51825183
2 1
51835184
SELECT * FROM t1 JOIN ((SELECT 1 UNION SELECT 1)) ON 1;
5184-
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')) ON 1' at line 1
5185+
ERROR 42000: Every derived table must have its own alias
51855186
SELECT * FROM t1 JOIN (t1 t1a UNION SELECT 1) ON 1;
51865187
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ') ON 1' at line 1
51875188
SELECT * FROM t1 JOIN ((t1 t1a UNION SELECT 1)) ON 1;
@@ -5300,7 +5301,10 @@ SELECT ((SELECT 1 UNION SELECT 1 UNION SELECT 1));
53005301
SELECT * FROM ( SELECT 1 UNION ( SELECT 1 UNION SELECT 1 ) );
53015302
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UNION SELECT 1 ) )' at line 1
53025303
SELECT * FROM ( ( SELECT 1 UNION SELECT 1 ) UNION SELECT 1 );
5303-
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ') UNION SELECT 1 )' at line 1
5304+
ERROR 42000: Every derived table must have its own alias
5305+
SELECT * FROM ( ( SELECT 1 UNION SELECT 1 ) UNION SELECT 1 ) a;
5306+
1
5307+
1
53045308
SELECT * FROM ( SELECT 1 UNION SELECT 1 UNION SELECT 1 ) a;
53055309
1
53065310
1

mysql-test/r/subselect_no_opts.result

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5134,8 +5134,9 @@ SELECT a FROM t1 WHERE a = 2
51345134
a
51355135
1
51365136
2
5137-
SELECT * FROM ((SELECT 1 a) UNION SELECT 1 a);
5138-
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')' at line 1
5137+
SELECT * FROM ((SELECT 1 a) UNION SELECT 1 a) q;
5138+
a
5139+
1
51395140
SELECT * FROM (SELECT 1 a UNION (SELECT 1 a)) alias;
51405141
a
51415142
1
@@ -5177,7 +5178,7 @@ a 1
51775178
1 1
51785179
2 1
51795180
SELECT * FROM t1 JOIN ((SELECT 1 UNION SELECT 1)) ON 1;
5180-
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')) ON 1' at line 1
5181+
ERROR 42000: Every derived table must have its own alias
51815182
SELECT * FROM t1 JOIN (t1 t1a UNION SELECT 1) ON 1;
51825183
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ') ON 1' at line 1
51835184
SELECT * FROM t1 JOIN ((t1 t1a UNION SELECT 1)) ON 1;
@@ -5296,7 +5297,10 @@ SELECT ((SELECT 1 UNION SELECT 1 UNION SELECT 1));
52965297
SELECT * FROM ( SELECT 1 UNION ( SELECT 1 UNION SELECT 1 ) );
52975298
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UNION SELECT 1 ) )' at line 1
52985299
SELECT * FROM ( ( SELECT 1 UNION SELECT 1 ) UNION SELECT 1 );
5299-
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ') UNION SELECT 1 )' at line 1
5300+
ERROR 42000: Every derived table must have its own alias
5301+
SELECT * FROM ( ( SELECT 1 UNION SELECT 1 ) UNION SELECT 1 ) a;
5302+
1
5303+
1
53005304
SELECT * FROM ( SELECT 1 UNION SELECT 1 UNION SELECT 1 ) a;
53015305
1
53025306
1

mysql-test/r/subselect_no_scache.result

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5144,8 +5144,9 @@ SELECT a FROM t1 WHERE a = 2
51445144
a
51455145
1
51465146
2
5147-
SELECT * FROM ((SELECT 1 a) UNION SELECT 1 a);
5148-
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')' at line 1
5147+
SELECT * FROM ((SELECT 1 a) UNION SELECT 1 a) q;
5148+
a
5149+
1
51495150
SELECT * FROM (SELECT 1 a UNION (SELECT 1 a)) alias;
51505151
a
51515152
1
@@ -5187,7 +5188,7 @@ a 1
51875188
1 1
51885189
2 1
51895190
SELECT * FROM t1 JOIN ((SELECT 1 UNION SELECT 1)) ON 1;
5190-
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')) ON 1' at line 1
5191+
ERROR 42000: Every derived table must have its own alias
51915192
SELECT * FROM t1 JOIN (t1 t1a UNION SELECT 1) ON 1;
51925193
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ') ON 1' at line 1
51935194
SELECT * FROM t1 JOIN ((t1 t1a UNION SELECT 1)) ON 1;
@@ -5306,7 +5307,10 @@ SELECT ((SELECT 1 UNION SELECT 1 UNION SELECT 1));
53065307
SELECT * FROM ( SELECT 1 UNION ( SELECT 1 UNION SELECT 1 ) );
53075308
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UNION SELECT 1 ) )' at line 1
53085309
SELECT * FROM ( ( SELECT 1 UNION SELECT 1 ) UNION SELECT 1 );
5309-
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ') UNION SELECT 1 )' at line 1
5310+
ERROR 42000: Every derived table must have its own alias
5311+
SELECT * FROM ( ( SELECT 1 UNION SELECT 1 ) UNION SELECT 1 ) a;
5312+
1
5313+
1
53105314
SELECT * FROM ( SELECT 1 UNION SELECT 1 UNION SELECT 1 ) a;
53115315
1
53125316
1

0 commit comments

Comments
 (0)