summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.org>2016-05-24 18:05:38 +0400
committerAlexander Barkov <bar@mariadb.org>2016-05-24 18:05:38 +0400
commitc80c3f6759e456b88211f8e207648ee5d3964dac (patch)
tree371a553ff4b77722df92536ea6da4a6f71d09f28 /mysql-test
parentea9a393a868dda808bd0c7a3f03b28208eb6570f (diff)
downloadmariadb-git-c80c3f6759e456b88211f8e207648ee5d3964dac.tar.gz
MDEV-10109 Disallow syntactically INSERT .. SELECT .. {ORDER BY ..| LIMIT ..} .. UNION ..
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/r/parser.result11
-rw-r--r--mysql-test/r/union.result2
-rw-r--r--mysql-test/t/parser.test13
-rw-r--r--mysql-test/t/union.test2
4 files changed, 26 insertions, 2 deletions
diff --git a/mysql-test/r/parser.result b/mysql-test/r/parser.result
index f0cfde65b57..efb9ff07565 100644
--- a/mysql-test/r/parser.result
+++ b/mysql-test/r/parser.result
@@ -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
diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result
index 6a52bc023e1..74eb3e069df 100644
--- a/mysql-test/r/union.result
+++ b/mysql-test/r/union.result
@@ -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;
diff --git a/mysql-test/t/parser.test b/mysql-test/t/parser.test
index aae6b2c34be..0450e3c6fb0 100644
--- a/mysql-test/t/parser.test
+++ b/mysql-test/t/parser.test
@@ -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;
diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test
index d7c67444015..151512515b9 100644
--- a/mysql-test/t/union.test
+++ b/mysql-test/t/union.test
@@ -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