revision-id: 5e485d29338567fa9c4e8bdf95141afb2a6ab3dc (mariadb-10.3.5-123-g5e485d29338) parent(s): b46a833e61c36a34aa13d71c460385ad72d7cd0f author: Oleksandr Byelkin committer: Oleksandr Byelkin timestamp: 2018-04-11 09:07:04 +0200 message: Added tests of bugs connected to bracets --- mysql-test/main/brackets.result | 70 +++++++++++++++++++++++++++++++++++++++++ mysql-test/main/brackets.test | 43 +++++++++++++++++++++++++ 2 files changed, 113 insertions(+) diff --git a/mysql-test/main/brackets.result b/mysql-test/main/brackets.result index 55e3ce441e0..a943dafecf7 100644 --- a/mysql-test/main/brackets.result +++ b/mysql-test/main/brackets.result @@ -112,3 +112,73 @@ NULL UNION RESULT <union2,7> ALL NULL NULL NULL NULL NULL NULL NULL UNION RESULT <union1,8> ALL NULL NULL NULL NULL NULL NULL Warnings: Note 1003 /* select#1/0 Filter Select: select `1` AS `1` */ select 1 AS `1` union /* select#8/0 */ select `__8`.`1` AS `1` from (/* select#2/1 Filter Select: select `1` AS `1` */ select 1 AS `1` union /* select#7/1 */ select `__7`.`1` AS `1` from (/* select#3/2 Filter Select: select `1` AS `1` */ select 1 AS `1` union /* select#6/2 */ select `__6`.`1` AS `1` from (/* select#4/3 Filter Select: select `1` AS `1` */ select 1 AS `1` union /* select#5/3 */ select 1 AS `1`) `__6`) `__7`) `__8` +# +# MDEV-6341: INSERT ... SELECT UNION with parenthesis +# +create table t1 (a int, b int); +insert into t1 (select 1,1 union select 2,2); +select * from t1 order by 1; +a b +1 1 +2 2 +delete from t1; +insert into t1 select 1,1 union select 2,2; +select * from t1 order by 1; +a b +1 1 +2 2 +drop table t1; +CREATE OR REPLACE TABLE t1 AS SELECT 1 AS a UNION SELECT 2; +select * from t1 order by 1; +a +1 +2 +drop table t1; +CREATE OR REPLACE TABLE t1 AS (SELECT 1 AS a UNION SELECT 2); +select * from t1 order by 1; +a +1 +2 +drop table t1; +CREATE OR REPLACE VIEW v1 AS (SELECT 1 AS a); +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS (select 1 AS `a`) latin1 latin1_swedish_ci +drop view v1; +CREATE OR REPLACE VIEW v1 AS SELECT 1 AS a UNION SELECT 2; +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select 1 AS `a` union select 2 AS `2` latin1 latin1_swedish_ci +drop view v1; +CREATE OR REPLACE VIEW v1 AS (SELECT 1 AS a UNION SELECT 2); +show create view v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select 1 AS `a` union select 2 AS `2` latin1 latin1_swedish_ci +drop view v1; +# +# MDEV-10028: Syntax error on ((SELECT ...) UNION (SELECT ...)) +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (10); +INSERT INTO t1 VALUES (20); +INSERT INTO t1 VALUES (30); +((SELECT a FROM t1) UNION (SELECT a FROM t1)); +a +10 +20 +30 +(SELECT * FROM t1 UNION SELECT * FROM t1); +a +10 +20 +30 +((SELECT a FROM t1) LIMIT 1); +a +10 +SELECT * FROM (SELECT 1 UNION (SELECT 2 UNION SELECT 3)) t1; +1 +1 +2 +3 +DROP TABLE t1; +# End of 10.4 tests diff --git a/mysql-test/main/brackets.test b/mysql-test/main/brackets.test index 3a4534dcf94..d3477f501a1 100644 --- a/mysql-test/main/brackets.test +++ b/mysql-test/main/brackets.test @@ -24,3 +24,46 @@ explain extended select 1 union ( select 1 union (select 1 union (select 1 union select 1))); explain extended all select 1 union ( select 1 union (select 1 union (select 1 union select 1))); + +--echo # +--echo # MDEV-6341: INSERT ... SELECT UNION with parenthesis +--echo # +create table t1 (a int, b int); +insert into t1 (select 1,1 union select 2,2); +select * from t1 order by 1; +delete from t1; +insert into t1 select 1,1 union select 2,2; +select * from t1 order by 1; +drop table t1; +CREATE OR REPLACE TABLE t1 AS SELECT 1 AS a UNION SELECT 2; +select * from t1 order by 1; +drop table t1; +CREATE OR REPLACE TABLE t1 AS (SELECT 1 AS a UNION SELECT 2); +select * from t1 order by 1; +drop table t1; +CREATE OR REPLACE VIEW v1 AS (SELECT 1 AS a); +show create view v1; +drop view v1; +CREATE OR REPLACE VIEW v1 AS SELECT 1 AS a UNION SELECT 2; +show create view v1; +drop view v1; +CREATE OR REPLACE VIEW v1 AS (SELECT 1 AS a UNION SELECT 2); +show create view v1; +drop view v1; + + +--echo # +--echo # MDEV-10028: Syntax error on ((SELECT ...) UNION (SELECT ...)) +--echo # +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (10); +INSERT INTO t1 VALUES (20); +INSERT INTO t1 VALUES (30); + +((SELECT a FROM t1) UNION (SELECT a FROM t1)); +(SELECT * FROM t1 UNION SELECT * FROM t1); +((SELECT a FROM t1) LIMIT 1); +SELECT * FROM (SELECT 1 UNION (SELECT 2 UNION SELECT 3)) t1; +DROP TABLE t1; + +--echo # End of 10.4 tests