Commit a0db19be authored by Alexander Barkov's avatar Alexander Barkov

MDEV-10779 Failing assertion lex->proc_list.elements == 0 or syntax error on...

MDEV-10779 Failing assertion lex->proc_list.elements == 0 or syntax error on PROCEDURE ANALYSE in UNION

Reverting a part of the patch for "MDEV-8909union parser cleanup",
as a parenthesized SELECT with PROCEDURE followed by UNION is not
disallowed by the grammar (only a non-parenthesized SELECT with PROCEDURE
followed by a UNION is disallowed grammatically).
parent 54b81ac5
......@@ -1239,3 +1239,44 @@ a
20
1
DROP TABLE t1;
#
# MDEV-10779 Failing assertion lex->proc_list.elements == 0 or syntax error on PROCEDURE ANALYSE in UNION
#
CREATE TABLE t1 (i INT);
(SELECT * FROM t1 PROCEDURE ANALYSE(10, 10))
UNION
(SELECT * FROM t1 PROCEDURE ANALYSE(10, 10));
ERROR HY000: Incorrect usage of UNION and SELECT ... PROCEDURE ANALYSE()
(SELECT * FROM t1 PROCEDURE ANALYSE(10, 10))
UNION
SELECT * FROM t1 PROCEDURE ANALYSE(10, 10);
ERROR HY000: Incorrect usage of UNION and SELECT ... PROCEDURE ANALYSE()
(SELECT * FROM t1 PROCEDURE ANALYSE(10, 10))
UNION
(SELECT 1);
ERROR HY000: Incorrect usage of UNION and SELECT ... PROCEDURE ANALYSE()
(SELECT * FROM t1 PROCEDURE ANALYSE(10, 10))
UNION
SELECT 1;
ERROR HY000: Incorrect usage of UNION and SELECT ... PROCEDURE ANALYSE()
SELECT * FROM t1 PROCEDURE ANALYSE(10, 10)
UNION
(SELECT * FROM t1 PROCEDURE ANALYSE(10, 10));
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 * FROM t1 PROCEDURE ANALYSE(10, 10))' at line 2
SELECT * FROM t1 PROCEDURE ANALYSE(10, 10)
UNION
SELECT * FROM t1 PROCEDURE ANALYSE(10, 10);
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 * FROM t1 PROCEDURE ANALYSE(10, 10)' at line 2
SELECT * FROM t1 PROCEDURE ANALYSE(10, 10)
UNION
(SELECT 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)' at line 2
SELECT * FROM t1 PROCEDURE ANALYSE(10, 10)
UNION
SELECT 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' at line 2
DROP TABLE t1;
......@@ -1263,3 +1263,51 @@ SELECT a FROM t1 GROUP BY a WITH ROLLUP UNION SELECT 1 ORDER BY a LIMIT 1;
SELECT 1 AS a UNION (SELECT a FROM t1 GROUP BY a WITH ROLLUP LIMIT 2);
(SELECT a FROM t1 GROUP BY a WITH ROLLUP LIMIT 2) UNION SELECT 1;
DROP TABLE t1;
--echo #
--echo # MDEV-10779 Failing assertion lex->proc_list.elements == 0 or syntax error on PROCEDURE ANALYSE in UNION
--echo #
CREATE TABLE t1 (i INT);
--error ER_WRONG_USAGE
(SELECT * FROM t1 PROCEDURE ANALYSE(10, 10))
UNION
(SELECT * FROM t1 PROCEDURE ANALYSE(10, 10));
--error ER_WRONG_USAGE
(SELECT * FROM t1 PROCEDURE ANALYSE(10, 10))
UNION
SELECT * FROM t1 PROCEDURE ANALYSE(10, 10);
--error ER_WRONG_USAGE
(SELECT * FROM t1 PROCEDURE ANALYSE(10, 10))
UNION
(SELECT 1);
--error ER_WRONG_USAGE
(SELECT * FROM t1 PROCEDURE ANALYSE(10, 10))
UNION
SELECT 1;
--error ER_PARSE_ERROR
SELECT * FROM t1 PROCEDURE ANALYSE(10, 10)
UNION
(SELECT * FROM t1 PROCEDURE ANALYSE(10, 10));
--error ER_PARSE_ERROR
SELECT * FROM t1 PROCEDURE ANALYSE(10, 10)
UNION
SELECT * FROM t1 PROCEDURE ANALYSE(10, 10);
--error ER_PARSE_ERROR
SELECT * FROM t1 PROCEDURE ANALYSE(10, 10)
UNION
(SELECT 1);
--error ER_PARSE_ERROR
SELECT * FROM t1 PROCEDURE ANALYSE(10, 10)
UNION
SELECT 1;
DROP TABLE t1;
......@@ -7485,8 +7485,22 @@ mysql_new_select(LEX *lex, bool move_down)
DBUG_RETURN(TRUE);
}
// SELECT 1 FROM t1 PROCEDURE ANALYSE() UNION ... -- not possible
DBUG_ASSERT(lex->proc_list.elements == 0);
/*
This type of query is not possible in the grammar:
SELECT 1 FROM t1 PROCEDURE ANALYSE() UNION ... ;
But this type of query is still possible:
(SELECT 1 FROM t1 PROCEDURE ANALYSE()) UNION ... ;
and it's not easy to disallow this grammatically,
because there can be any parenthesis nest level:
(((SELECT 1 FROM t1 PROCEDURE ANALYSE()))) UNION ... ;
*/
if (lex->proc_list.elements!=0)
{
my_error(ER_WRONG_USAGE, MYF(0), "UNION",
"SELECT ... PROCEDURE ANALYSE()");
DBUG_RETURN(TRUE);
}
// SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1 -- not possible
DBUG_ASSERT(!lex->current_select->order_list.first ||
lex->current_select->braces);
......
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