Commit a999acf2 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-10095 Fix derived tables to return a syntax error instead of "Illegal...

MDEV-10095 Fix derived tables to return a syntax error instead of "Illegal usage of UNION and LIMIT"
parent 349da1d6
...@@ -1476,7 +1476,7 @@ DROP TABLE t1,t2,t3,t4,t5; ...@@ -1476,7 +1476,7 @@ DROP TABLE t1,t2,t3,t4,t5;
# MDEV-4752: Segfault during parsing of illegal query # MDEV-4752: Segfault during parsing of illegal query
# #
SELECT * FROM t5 JOIN (t1 JOIN t2 UNION SELECT * FROM t3 JOIN t4); SELECT * FROM t5 JOIN (t1 JOIN t2 UNION SELECT * FROM t3 JOIN t4);
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 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 'SELECT * FROM t3 JOIN t4)' at line 1
# #
# MDEV-4959: join of const table with NULL fields # MDEV-4959: join of const table with NULL fields
# #
......
...@@ -822,19 +822,19 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp ...@@ -822,19 +822,19 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
SELECT (SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1); SELECT (SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1);
ERROR HY000: Incorrect usage of UNION and ORDER BY ERROR HY000: Incorrect usage of UNION and ORDER BY
SELECT 1 FROM (SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1) a; SELECT 1 FROM (SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1) a;
ERROR HY000: Incorrect usage of UNION and ORDER BY 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 FROM t1) a' at line 1
SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1; SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1;
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 FROM t1' at line 1 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 FROM t1' at line 1
SELECT (SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1); SELECT (SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1);
ERROR HY000: Incorrect usage of UNION and LIMIT ERROR HY000: Incorrect usage of UNION and LIMIT
SELECT 1 FROM (SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1) a; SELECT 1 FROM (SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1) a;
ERROR HY000: Incorrect usage of UNION and LIMIT 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 FROM t1) a' at line 1
SELECT 1 FROM t1 ORDER BY 1 LIMIT 1 UNION SELECT 1 FROM t1; SELECT 1 FROM t1 ORDER BY 1 LIMIT 1 UNION SELECT 1 FROM t1;
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 FROM t1' at line 1 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 FROM t1' at line 1
SELECT (SELECT 1 FROM t1 ORDER BY 1 LIMIT 1 UNION SELECT 1 FROM t1); SELECT (SELECT 1 FROM t1 ORDER BY 1 LIMIT 1 UNION SELECT 1 FROM t1);
ERROR HY000: Incorrect usage of UNION and ORDER BY ERROR HY000: Incorrect usage of UNION and ORDER BY
SELECT 1 FROM (SELECT 1 FROM t1 ORDER BY 1 LIMIT 1 UNION SELECT 1 FROM t1) a; SELECT 1 FROM (SELECT 1 FROM t1 ORDER BY 1 LIMIT 1 UNION SELECT 1 FROM t1) a;
ERROR HY000: Incorrect usage of UNION and ORDER BY 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 FROM t1) a' at line 1
SELECT 1 FROM t1 LIMIT 1 ORDER BY 1 UNION SELECT 1 FROM t1; SELECT 1 FROM t1 LIMIT 1 ORDER BY 1 UNION SELECT 1 FROM t1;
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 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
SELECT (SELECT 1 FROM t1 LIMIT 1 ORDER BY 1 UNION SELECT 1 FROM t1); SELECT (SELECT 1 FROM t1 LIMIT 1 ORDER BY 1 UNION SELECT 1 FROM t1);
...@@ -846,25 +846,25 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp ...@@ -846,25 +846,25 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
SELECT (SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1 ORDER BY 1); SELECT (SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1 ORDER BY 1);
ERROR HY000: Incorrect usage of UNION and ORDER BY ERROR HY000: Incorrect usage of UNION and ORDER BY
SELECT 1 FROM (SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1 ORDER BY 1) a; SELECT 1 FROM (SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1 ORDER BY 1) a;
ERROR HY000: Incorrect usage of UNION and ORDER BY 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 FROM t1 ORDER BY 1) a' at line 1
SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1 LIMIT 1; SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1 LIMIT 1;
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 FROM t1 LIMIT 1' at line 1 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 FROM t1 LIMIT 1' at line 1
SELECT (SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1 LIMIT 1); SELECT (SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1 LIMIT 1);
ERROR HY000: Incorrect usage of UNION and LIMIT ERROR HY000: Incorrect usage of UNION and LIMIT
SELECT 1 FROM (SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1 LIMIT 1) a; SELECT 1 FROM (SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1 LIMIT 1) a;
ERROR HY000: Incorrect usage of UNION and LIMIT 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 FROM t1 LIMIT 1) a' at line 1
SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1 ORDER BY 1; SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1 ORDER BY 1;
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 FROM t1 ORDER BY 1' at line 1 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 FROM t1 ORDER BY 1' at line 1
SELECT (SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1 ORDER BY 1); SELECT (SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1 ORDER BY 1);
ERROR HY000: Incorrect usage of UNION and LIMIT ERROR HY000: Incorrect usage of UNION and LIMIT
SELECT 1 FROM (SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1 ORDER BY 1) a; SELECT 1 FROM (SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1 ORDER BY 1) a;
ERROR HY000: Incorrect usage of UNION and LIMIT 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 FROM t1 ORDER BY 1) a' at line 1
SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1 LIMIT 1; SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1 LIMIT 1;
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 FROM t1 LIMIT 1' at line 1 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 FROM t1 LIMIT 1' at line 1
SELECT (SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1 LIMIT 1); SELECT (SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1 LIMIT 1);
ERROR HY000: Incorrect usage of UNION and ORDER BY ERROR HY000: Incorrect usage of UNION and ORDER BY
SELECT 1 FROM (SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1 LIMIT 1) a; SELECT 1 FROM (SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1 LIMIT 1) a;
ERROR HY000: Incorrect usage of UNION and ORDER BY 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 FROM t1 LIMIT 1) a' at line 1
DROP TABLE t1; DROP TABLE t1;
# #
# MDEV-8380: Subquery parse error # MDEV-8380: Subquery parse error
......
...@@ -5188,9 +5188,9 @@ a 1 ...@@ -5188,9 +5188,9 @@ a 1
SELECT * FROM t1 JOIN ((SELECT 1 UNION SELECT 1)) ON 1; SELECT * FROM t1 JOIN ((SELECT 1 UNION SELECT 1)) ON 1;
ERROR 42000: Every derived table must have its own alias ERROR 42000: Every derived table must have its own alias
SELECT * FROM t1 JOIN (t1 t1a UNION SELECT 1) ON 1; SELECT * FROM t1 JOIN (t1 t1a UNION SELECT 1) ON 1;
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 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 'SELECT 1) ON 1' at line 1
SELECT * FROM t1 JOIN ((t1 t1a UNION SELECT 1)) ON 1; SELECT * FROM t1 JOIN ((t1 t1a UNION SELECT 1)) ON 1;
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 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 'SELECT 1)) ON 1' at line 1
SELECT * FROM t1 JOIN (t1 t1a) t1a ON 1; SELECT * FROM t1 JOIN (t1 t1a) t1a ON 1;
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 't1a ON 1' at line 1 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 't1a ON 1' at line 1
SELECT * FROM t1 JOIN ((t1 t1a)) t1a ON 1; SELECT * FROM t1 JOIN ((t1 t1a)) t1a ON 1;
......
...@@ -5190,9 +5190,9 @@ a 1 ...@@ -5190,9 +5190,9 @@ a 1
SELECT * FROM t1 JOIN ((SELECT 1 UNION SELECT 1)) ON 1; SELECT * FROM t1 JOIN ((SELECT 1 UNION SELECT 1)) ON 1;
ERROR 42000: Every derived table must have its own alias ERROR 42000: Every derived table must have its own alias
SELECT * FROM t1 JOIN (t1 t1a UNION SELECT 1) ON 1; SELECT * FROM t1 JOIN (t1 t1a UNION SELECT 1) ON 1;
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 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 'SELECT 1) ON 1' at line 1
SELECT * FROM t1 JOIN ((t1 t1a UNION SELECT 1)) ON 1; SELECT * FROM t1 JOIN ((t1 t1a UNION SELECT 1)) ON 1;
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 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 'SELECT 1)) ON 1' at line 1
SELECT * FROM t1 JOIN (t1 t1a) t1a ON 1; SELECT * FROM t1 JOIN (t1 t1a) t1a ON 1;
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 't1a ON 1' at line 1 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 't1a ON 1' at line 1
SELECT * FROM t1 JOIN ((t1 t1a)) t1a ON 1; SELECT * FROM t1 JOIN ((t1 t1a)) t1a ON 1;
......
...@@ -5188,9 +5188,9 @@ a 1 ...@@ -5188,9 +5188,9 @@ a 1
SELECT * FROM t1 JOIN ((SELECT 1 UNION SELECT 1)) ON 1; SELECT * FROM t1 JOIN ((SELECT 1 UNION SELECT 1)) ON 1;
ERROR 42000: Every derived table must have its own alias ERROR 42000: Every derived table must have its own alias
SELECT * FROM t1 JOIN (t1 t1a UNION SELECT 1) ON 1; SELECT * FROM t1 JOIN (t1 t1a UNION SELECT 1) ON 1;
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 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 'SELECT 1) ON 1' at line 1
SELECT * FROM t1 JOIN ((t1 t1a UNION SELECT 1)) ON 1; SELECT * FROM t1 JOIN ((t1 t1a UNION SELECT 1)) ON 1;
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 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 'SELECT 1)) ON 1' at line 1
SELECT * FROM t1 JOIN (t1 t1a) t1a ON 1; SELECT * FROM t1 JOIN (t1 t1a) t1a ON 1;
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 't1a ON 1' at line 1 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 't1a ON 1' at line 1
SELECT * FROM t1 JOIN ((t1 t1a)) t1a ON 1; SELECT * FROM t1 JOIN ((t1 t1a)) t1a ON 1;
......
...@@ -5184,9 +5184,9 @@ a 1 ...@@ -5184,9 +5184,9 @@ a 1
SELECT * FROM t1 JOIN ((SELECT 1 UNION SELECT 1)) ON 1; SELECT * FROM t1 JOIN ((SELECT 1 UNION SELECT 1)) ON 1;
ERROR 42000: Every derived table must have its own alias ERROR 42000: Every derived table must have its own alias
SELECT * FROM t1 JOIN (t1 t1a UNION SELECT 1) ON 1; SELECT * FROM t1 JOIN (t1 t1a UNION SELECT 1) ON 1;
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 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 'SELECT 1) ON 1' at line 1
SELECT * FROM t1 JOIN ((t1 t1a UNION SELECT 1)) ON 1; SELECT * FROM t1 JOIN ((t1 t1a UNION SELECT 1)) ON 1;
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 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 'SELECT 1)) ON 1' at line 1
SELECT * FROM t1 JOIN (t1 t1a) t1a ON 1; SELECT * FROM t1 JOIN (t1 t1a) t1a ON 1;
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 't1a ON 1' at line 1 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 't1a ON 1' at line 1
SELECT * FROM t1 JOIN ((t1 t1a)) t1a ON 1; SELECT * FROM t1 JOIN ((t1 t1a)) t1a ON 1;
......
...@@ -5194,9 +5194,9 @@ a 1 ...@@ -5194,9 +5194,9 @@ a 1
SELECT * FROM t1 JOIN ((SELECT 1 UNION SELECT 1)) ON 1; SELECT * FROM t1 JOIN ((SELECT 1 UNION SELECT 1)) ON 1;
ERROR 42000: Every derived table must have its own alias ERROR 42000: Every derived table must have its own alias
SELECT * FROM t1 JOIN (t1 t1a UNION SELECT 1) ON 1; SELECT * FROM t1 JOIN (t1 t1a UNION SELECT 1) ON 1;
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 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 'SELECT 1) ON 1' at line 1
SELECT * FROM t1 JOIN ((t1 t1a UNION SELECT 1)) ON 1; SELECT * FROM t1 JOIN ((t1 t1a UNION SELECT 1)) ON 1;
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 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 'SELECT 1)) ON 1' at line 1
SELECT * FROM t1 JOIN (t1 t1a) t1a ON 1; SELECT * FROM t1 JOIN (t1 t1a) t1a ON 1;
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 't1a ON 1' at line 1 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 't1a ON 1' at line 1
SELECT * FROM t1 JOIN ((t1 t1a)) t1a ON 1; SELECT * FROM t1 JOIN ((t1 t1a)) t1a ON 1;
......
...@@ -5184,9 +5184,9 @@ a 1 ...@@ -5184,9 +5184,9 @@ a 1
SELECT * FROM t1 JOIN ((SELECT 1 UNION SELECT 1)) ON 1; SELECT * FROM t1 JOIN ((SELECT 1 UNION SELECT 1)) ON 1;
ERROR 42000: Every derived table must have its own alias ERROR 42000: Every derived table must have its own alias
SELECT * FROM t1 JOIN (t1 t1a UNION SELECT 1) ON 1; SELECT * FROM t1 JOIN (t1 t1a UNION SELECT 1) ON 1;
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 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 'SELECT 1) ON 1' at line 1
SELECT * FROM t1 JOIN ((t1 t1a UNION SELECT 1)) ON 1; SELECT * FROM t1 JOIN ((t1 t1a UNION SELECT 1)) ON 1;
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 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 'SELECT 1)) ON 1' at line 1
SELECT * FROM t1 JOIN (t1 t1a) t1a ON 1; SELECT * FROM t1 JOIN (t1 t1a) t1a ON 1;
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 't1a ON 1' at line 1 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 't1a ON 1' at line 1
SELECT * FROM t1 JOIN ((t1 t1a)) t1a ON 1; SELECT * FROM t1 JOIN ((t1 t1a)) t1a ON 1;
......
...@@ -951,7 +951,7 @@ let $q=SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1; ...@@ -951,7 +951,7 @@ let $q=SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1;
eval $q; eval $q;
--error ER_WRONG_USAGE --error ER_WRONG_USAGE
eval SELECT ($q); eval SELECT ($q);
--error ER_WRONG_USAGE --error ER_PARSE_ERROR
eval SELECT 1 FROM ($q) a; eval SELECT 1 FROM ($q) a;
let $q=SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1; let $q=SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1;
...@@ -959,7 +959,7 @@ let $q=SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1; ...@@ -959,7 +959,7 @@ let $q=SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1;
eval $q; eval $q;
--error ER_WRONG_USAGE --error ER_WRONG_USAGE
eval SELECT ($q); eval SELECT ($q);
--error ER_WRONG_USAGE --error ER_PARSE_ERROR
eval SELECT 1 FROM ($q) a; eval SELECT 1 FROM ($q) a;
let $q=SELECT 1 FROM t1 ORDER BY 1 LIMIT 1 UNION SELECT 1 FROM t1; let $q=SELECT 1 FROM t1 ORDER BY 1 LIMIT 1 UNION SELECT 1 FROM t1;
...@@ -967,7 +967,7 @@ let $q=SELECT 1 FROM t1 ORDER BY 1 LIMIT 1 UNION SELECT 1 FROM t1; ...@@ -967,7 +967,7 @@ let $q=SELECT 1 FROM t1 ORDER BY 1 LIMIT 1 UNION SELECT 1 FROM t1;
eval $q; eval $q;
--error ER_WRONG_USAGE --error ER_WRONG_USAGE
eval SELECT ($q); eval SELECT ($q);
--error ER_WRONG_USAGE --error ER_PARSE_ERROR
eval SELECT 1 FROM ($q) a; eval SELECT 1 FROM ($q) a;
let $q=SELECT 1 FROM t1 LIMIT 1 ORDER BY 1 UNION SELECT 1 FROM t1; let $q=SELECT 1 FROM t1 LIMIT 1 ORDER BY 1 UNION SELECT 1 FROM t1;
...@@ -983,7 +983,7 @@ let $q=SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1 ORDER BY 1; ...@@ -983,7 +983,7 @@ let $q=SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1 ORDER BY 1;
eval $q; eval $q;
--error ER_WRONG_USAGE --error ER_WRONG_USAGE
eval SELECT ($q); eval SELECT ($q);
--error ER_WRONG_USAGE --error ER_PARSE_ERROR
eval SELECT 1 FROM ($q) a; eval SELECT 1 FROM ($q) a;
let $q=SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1 LIMIT 1; let $q=SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1 LIMIT 1;
...@@ -991,7 +991,7 @@ let $q=SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1 LIMIT 1; ...@@ -991,7 +991,7 @@ let $q=SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1 LIMIT 1;
eval $q; eval $q;
--error ER_WRONG_USAGE --error ER_WRONG_USAGE
eval SELECT ($q); eval SELECT ($q);
--error ER_WRONG_USAGE --error ER_PARSE_ERROR
eval SELECT 1 FROM ($q) a; eval SELECT 1 FROM ($q) a;
let $q=SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1 ORDER BY 1; let $q=SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1 ORDER BY 1;
...@@ -999,7 +999,7 @@ let $q=SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1 ORDER BY 1; ...@@ -999,7 +999,7 @@ let $q=SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1 ORDER BY 1;
eval $q; eval $q;
--error ER_WRONG_USAGE --error ER_WRONG_USAGE
eval SELECT ($q); eval SELECT ($q);
--error ER_WRONG_USAGE --error ER_PARSE_ERROR
eval SELECT 1 FROM ($q) a; eval SELECT 1 FROM ($q) a;
let $q=SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1 LIMIT 1; let $q=SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1 LIMIT 1;
...@@ -1007,7 +1007,7 @@ let $q=SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1 LIMIT 1; ...@@ -1007,7 +1007,7 @@ let $q=SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1 LIMIT 1;
eval $q; eval $q;
--error ER_WRONG_USAGE --error ER_WRONG_USAGE
eval SELECT ($q); eval SELECT ($q);
--error ER_WRONG_USAGE --error ER_PARSE_ERROR
eval SELECT 1 FROM ($q) a; eval SELECT 1 FROM ($q) a;
DROP TABLE t1; DROP TABLE t1;
......
...@@ -1882,6 +1882,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); ...@@ -1882,6 +1882,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
table_primary_ident table_primary_derived table_primary_ident table_primary_derived
select_derived derived_table_list select_derived derived_table_list
select_derived_union select_derived_union
derived_query_specification
%type <date_time_type> date_time_type; %type <date_time_type> date_time_type;
%type <interval> interval %type <interval> interval
...@@ -11113,34 +11114,39 @@ table_primary_derived: ...@@ -11113,34 +11114,39 @@ table_primary_derived:
subqueries have their own union rules. subqueries have their own union rules.
*/ */
select_derived_union: select_derived_union:
select_derived opt_union_order_or_limit select_derived
| select_derived union_order_or_limit
{ {
if ($1 && $2) if ($1)
{ {
my_parse_error(thd, ER_SYNTAX_ERROR); my_parse_error(thd, ER_SYNTAX_ERROR);
MYSQL_YYABORT; MYSQL_YYABORT;
} }
} }
| derived_query_specification | select_derived union_head_non_top
opt_order_clause
opt_limit_clause
opt_select_lock_type
{ $$= NULL; }
| select_derived_union union_head_non_top query_term
{ {
/* if ($1)
Remove from the name resolution context stack the context of the
last select in the union.
*/
Lex->pop_context();
if ($1 != NULL)
{ {
my_parse_error(thd, ER_SYNTAX_ERROR); my_parse_error(thd, ER_SYNTAX_ERROR);
MYSQL_YYABORT; MYSQL_YYABORT;
} }
} }
; union_list_derived_part2
| derived_query_specification opt_select_lock_type
| derived_query_specification order_or_limit opt_select_lock_type
| derived_query_specification opt_select_lock_type union_list_derived
;
union_list_derived_part2:
query_term_union_not_ready { Lex->pop_context(); }
| query_term_union_ready { Lex->pop_context(); }
| query_term_union_ready { Lex->pop_context(); } union_list_derived
;
union_list_derived:
union_head_non_top union_list_derived_part2
;
/* The equivalent of select_init2 for nested queries. */ /* The equivalent of select_init2 for nested queries. */
select_init2_derived: select_init2_derived:
...@@ -11206,6 +11212,7 @@ derived_query_specification: ...@@ -11206,6 +11212,7 @@ derived_query_specification:
MYSQL_YYABORT; MYSQL_YYABORT;
} }
} }
$$= NULL;
} }
; ;
...@@ -16398,12 +16405,18 @@ query_specification: ...@@ -16398,12 +16405,18 @@ query_specification:
; ;
query_term: query_term:
query_specification query_term_union_ready
opt_order_clause | query_term_union_not_ready
opt_limit_clause ;
opt_select_lock_type
query_term_union_not_ready:
query_specification order_or_limit opt_select_lock_type
| '(' select_paren_derived ')' union_order_or_limit
;
query_term_union_ready:
query_specification opt_select_lock_type
| '(' select_paren_derived ')' | '(' select_paren_derived ')'
opt_union_order_or_limit
; ;
query_expression_body: query_expression_body:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment