Skip to content

Commit da3fc33

Browse files
committed
cleanup: union.test
1 parent d08f2ab commit da3fc33

File tree

2 files changed

+20
-25
lines changed

2 files changed

+20
-25
lines changed

mysql-test/main/union.result

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
drop table if exists t1,t2,t3,t4,t5,t6;
21
CREATE TABLE t1 (a int not null, b char (10) not null);
32
insert into t1 values(1,'a'),(2,'b'),(3,'c'),(3,'c');
43
CREATE TABLE t2 (a int not null, b char (10) not null);

mysql-test/main/union.test

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
# Test of unions
33
#
44

5-
--disable_warnings
6-
drop table if exists t1,t2,t3,t4,t5,t6;
7-
--enable_warnings
8-
95
CREATE TABLE t1 (a int not null, b char (10) not null);
106
insert into t1 values(1,'a'),(2,'b'),(3,'c'),(3,'c');
117
CREATE TABLE t2 (a int not null, b char (10) not null);
@@ -23,7 +19,7 @@ select 't1',b,count(*) from t1 group by b UNION select 't2',b,count(*) from t2 g
2319
(select a,b from t1 limit 2) union all (select a,b from t2 order by a) limit 4;
2420
(select a,b from t1 limit 2) union all (select a,b from t2 order by a limit 1);
2521
(select a,b from t1 limit 2) union all (select a,b from t2 order by a limit 1) order by b desc;
26-
--error 1250
22+
--error ER_TABLENAME_NOT_ALLOWED_HERE
2723
(select a,b from t1 limit 2) union all (select a,b from t2 order by a limit 1) order by t1.b;
2824
explain extended (select a,b from t1 limit 2) union all (select a,b from t2 order by a limit 1) order by b desc;
2925
--disable_view_protocol
@@ -42,13 +38,13 @@ select found_rows();
4238

4339
explain select a,b from t1 union all select a,b from t2;
4440

45-
--error 1054
41+
--error ER_BAD_FIELD_ERROR
4642
explain select xx from t1 union select 1;
47-
--error 1222
43+
--error ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT
4844
explain select a,b from t1 union select 1;
49-
--error 1222
45+
--error ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT
5046
explain select 1 union select a,b from t1 union select 1;
51-
--error 1222
47+
--error ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT
5248
explain select a,b from t1 union select 1 limit 0;
5349

5450
--error ER_PARSE_ERROR
@@ -60,19 +56,19 @@ select a,b from t1 order by a union select a,b from t2;
6056
--error ER_PARSE_ERROR
6157
insert into t3 select a from t1 order by a union select a from t2;
6258

63-
--error 1222
59+
--error ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT
6460
create table t3 select a,b from t1 union select a from t2;
6561

66-
--error 1222
62+
--error ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT
6763
select a,b from t1 union select a from t2;
6864

69-
--error 1222
65+
--error ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT
7066
select * from t1 union select a from t2;
7167

72-
--error 1222
68+
--error ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT
7369
select a from t1 union select * from t2;
7470

75-
--error 1234
71+
--error ER_CANT_USE_OPTION_HERE
7672
select * from t1 union select SQL_BUFFER_RESULT * from t2;
7773

7874
# Test CREATE, INSERT and REPLACE
@@ -86,13 +82,13 @@ drop table t1,t2,t3;
8682
#
8783
# Test some unions without tables
8884
#
89-
--error 1096
85+
--error ER_NO_TABLES_USED
9086
select * union select 1;
9187
select 1 as a,(select a union select a);
92-
--error 1054
88+
--error ER_BAD_FIELD_ERROR
9389
(select 1) union (select 2) order by 0;
9490
SELECT @a:=1 UNION SELECT @a:=@a+1;
95-
--error 1054
91+
--error ER_BAD_FIELD_ERROR
9692
(SELECT 1) UNION (SELECT 2) ORDER BY (SELECT a);
9793
(SELECT 1,3) UNION (SELECT 2,1) ORDER BY (SELECT 2);
9894

@@ -294,7 +290,7 @@ SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a desc LIMIT 1;
294290
(SELECT * FROM t1 ORDER by a) UNION ALL (SELECT * FROM t2 ORDER BY a) ORDER BY A desc LIMIT 4;
295291

296292
# Wrong usage
297-
--error 1234
293+
--error ER_CANT_USE_OPTION_HERE
298294
(SELECT * FROM t1) UNION all (SELECT SQL_CALC_FOUND_ROWS * FROM t2) LIMIT 1;
299295

300296
create temporary table t1 select a from t1 union select a from t2;
@@ -477,7 +473,7 @@ create table t1 select 1 union select -1;
477473
select * from t1;
478474
show create table t1;
479475
drop table t1;
480-
-- error 1267
476+
-- error ER_CANT_AGGREGATE_2COLLATIONS
481477
create table t1 select _latin1"test" union select _latin2"testt" ;
482478
create table t1 select _latin2"test" union select _latin2"testt" ;
483479
show create table t1;
@@ -585,7 +581,7 @@ set sql_select_limit=default;
585581
#
586582
CREATE TABLE t1 (i int(11) default NULL,c char(1) default NULL,KEY i (i));
587583
CREATE TABLE t2 (i int(11) default NULL,c char(1) default NULL,KEY i (i));
588-
--error 1054
584+
--error ER_BAD_FIELD_ERROR
589585
explain (select * from t1) union (select * from t2) order by not_existing_column;
590586
drop table t1, t2;
591587

@@ -687,7 +683,7 @@ drop table t1;
687683
create table t2 (
688684
a char character set latin1 collate latin1_swedish_ci,
689685
b char character set latin1 collate latin1_german1_ci);
690-
--error 1271
686+
--error ER_CANT_AGGREGATE_NCOLLATIONS
691687
create table t1 as
692688
(select a from t2) union
693689
(select b from t2);
@@ -984,19 +980,19 @@ CREATE TABLE t1 (a int);
984980
INSERT INTO t1 VALUES (3),(1),(2),(4),(1);
985981

986982
SELECT a FROM (SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY a) AS test;
987-
--error 1054
983+
--error ER_BAD_FIELD_ERROR
988984
SELECT a FROM (SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY c) AS test;
989985

990986
DROP TABLE t1;
991987

992988
#
993989
# Bug#23345: Wrongly allowed INTO in a non-last select of a UNION.
994990
#
995-
--error 1221
991+
--error ER_WRONG_USAGE
996992
(select 1 into @var) union (select 1);
997993
(select 1) union (select 1 into @var);
998994
select @var;
999-
--error 1172
995+
--error ER_TOO_MANY_ROWS
1000996
(select 2) union (select 1 into @var);
1001997

1002998
#

0 commit comments

Comments
 (0)