mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
MDEV-10109 Disallow syntactically INSERT .. SELECT .. {ORDER BY ..| LIMIT ..} .. UNION ..
This commit is contained in:
@ -886,3 +886,14 @@ INSERT INTO t1 VALUES (1),(2),(3);
|
||||
SELECT * FROM (SELECT * FROM t1 LIMIT 1 LIMIT 2) 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 'LIMIT 2) t1' at line 1
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# MDEV-10109 Disallow syntactically INSERT .. SELECT .. {ORDER BY ..| LIMIT ..} .. UNION ..
|
||||
#
|
||||
INSERT INTO t1 SELECT 1 ORDER BY 1 UNION SELECT 2;
|
||||
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 2' at line 1
|
||||
INSERT INTO t1 SELECT 1 LIMIT 1 UNION SELECT 2;
|
||||
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 2' at line 1
|
||||
CREATE TABLE t1 AS SELECT 1 ORDER BY 1 UNION SELECT 2;
|
||||
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 2' at line 1
|
||||
CREATE TABLE t1 AS SELECT 1 LIMIT 1 UNION SELECT 2;
|
||||
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 2' at line 1
|
||||
|
@ -128,7 +128,7 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
|
||||
select a,b from t1 order by a union select a,b from t2;
|
||||
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 a,b from t2' at line 1
|
||||
insert into t3 select a from t1 order by a union select a from t2;
|
||||
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 a from t2' at line 1
|
||||
create table t3 select a,b from t1 union select a from t2;
|
||||
ERROR 21000: The used SELECT statements have a different number of columns
|
||||
select a,b from t1 union select a from t2;
|
||||
|
@ -1030,3 +1030,16 @@ INSERT INTO t1 VALUES (1),(2),(3);
|
||||
--error ER_PARSE_ERROR
|
||||
SELECT * FROM (SELECT * FROM t1 LIMIT 1 LIMIT 2) t1;
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-10109 Disallow syntactically INSERT .. SELECT .. {ORDER BY ..| LIMIT ..} .. UNION ..
|
||||
--echo #
|
||||
|
||||
--error ER_PARSE_ERROR
|
||||
INSERT INTO t1 SELECT 1 ORDER BY 1 UNION SELECT 2;
|
||||
--error ER_PARSE_ERROR
|
||||
INSERT INTO t1 SELECT 1 LIMIT 1 UNION SELECT 2;
|
||||
--error ER_PARSE_ERROR
|
||||
CREATE TABLE t1 AS SELECT 1 ORDER BY 1 UNION SELECT 2;
|
||||
--error ER_PARSE_ERROR
|
||||
CREATE TABLE t1 AS SELECT 1 LIMIT 1 UNION SELECT 2;
|
||||
|
@ -56,7 +56,7 @@ select a,b from t1 into outfile 'skr' union select a,b from t2;
|
||||
--error ER_PARSE_ERROR
|
||||
select a,b from t1 order by a union select a,b from t2;
|
||||
|
||||
--error 1221
|
||||
--error ER_PARSE_ERROR
|
||||
insert into t3 select a from t1 order by a union select a from t2;
|
||||
|
||||
--error 1222
|
||||
|
@ -4944,7 +4944,8 @@ create_body:
|
||||
conflict that prevents the rule above from parsing a syntax like
|
||||
CREATE TABLE t1 (SELECT 1);
|
||||
*/
|
||||
| '(' create_select ')' { Select->set_braces(1);} union_opt {}
|
||||
| '(' create_select_query_specification ')'
|
||||
{ Select->set_braces(1);} union_opt {}
|
||||
| create_like
|
||||
{
|
||||
|
||||
@ -4965,12 +4966,18 @@ create_like:
|
||||
|
||||
opt_create_select:
|
||||
/* empty */ {}
|
||||
| opt_duplicate opt_as create_select
|
||||
| opt_duplicate opt_as create_select_query_expression_body
|
||||
;
|
||||
|
||||
create_select_query_expression_body:
|
||||
SELECT_SYM create_select_part2 opt_table_expression
|
||||
create_select_part4
|
||||
{ Select->set_braces(0);}
|
||||
union_clause {}
|
||||
| opt_duplicate opt_as '(' create_select ')'
|
||||
{ Select->set_braces(1);}
|
||||
union_opt {}
|
||||
union_clause
|
||||
| SELECT_SYM create_select_part2 create_select_part3_union_not_ready
|
||||
create_select_part4
|
||||
| '(' create_select_query_specification ')'
|
||||
{ Select->set_braces(1);} union_opt {}
|
||||
;
|
||||
|
||||
opt_create_partitioning:
|
||||
@ -5679,8 +5686,11 @@ opt_part_option:
|
||||
End of partition parser part
|
||||
*/
|
||||
|
||||
create_select:
|
||||
SELECT_SYM
|
||||
create_select_query_specification:
|
||||
SELECT_SYM create_select_part2 create_select_part3 create_select_part4
|
||||
;
|
||||
|
||||
create_select_part2:
|
||||
{
|
||||
LEX *lex=Lex;
|
||||
if (lex->sql_command == SQLCOM_INSERT)
|
||||
@ -5699,18 +5709,19 @@ create_select:
|
||||
{
|
||||
Select->parsing_place= NO_MATTER;
|
||||
}
|
||||
/*
|
||||
TODO:
|
||||
The following sequence repeats a few times:
|
||||
;
|
||||
|
||||
create_select_part3:
|
||||
opt_table_expression
|
||||
opt_order_clause
|
||||
opt_limit_clause
|
||||
opt_select_lock_type
|
||||
Perhaps they can be grouped into a dedicated rule.
|
||||
*/
|
||||
opt_table_expression
|
||||
opt_order_clause
|
||||
opt_limit_clause
|
||||
| create_select_part3_union_not_ready
|
||||
;
|
||||
|
||||
create_select_part3_union_not_ready:
|
||||
table_expression order_or_limit
|
||||
| order_or_limit
|
||||
;
|
||||
|
||||
create_select_part4:
|
||||
opt_select_lock_type
|
||||
{
|
||||
/*
|
||||
@ -12536,12 +12547,7 @@ fields:
|
||||
insert_values:
|
||||
VALUES values_list {}
|
||||
| VALUE_SYM values_list {}
|
||||
| create_select
|
||||
{ Select->set_braces(0);}
|
||||
union_clause {}
|
||||
| '(' create_select ')'
|
||||
{ Select->set_braces(1);}
|
||||
union_opt {}
|
||||
| create_select_query_expression_body {}
|
||||
;
|
||||
|
||||
values_list:
|
||||
|
Reference in New Issue
Block a user