~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to tests/t/union.test

  • Committer: Bazaar Package Importer
  • Author(s): Monty Taylor
  • Date: 2010-10-02 14:17:48 UTC
  • mfrom: (1.1.1 upstream)
  • mto: (2.1.17 sid)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20101002141748-m6vbfbfjhrw1153e
Tags: 2010.09.1802-1
* New upstream release.
* Removed pid-file argument hack.
* Updated GPL-2 address to be new address.
* Directly copy in drizzledump.1 since debian doesn't have sphinx 1.0 yet.
* Link to jquery from libjs-jquery. Add it as a depend.
* Add drizzled.8 symlink to the install files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
(select a,b from t1 limit 2)  union all (select a,b from t2 order by a) limit 4;
24
24
(select a,b from t1 limit 2)  union all (select a,b from t2 order by a limit 1);
25
25
(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
 
26
--error ER_TABLENAME_NOT_ALLOWED_HERE
27
27
(select a,b from t1 limit 2)  union all (select a,b from t2 order by a limit 1) order by t1.b;
28
28
--replace_column 9 #
29
29
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;
41
41
 
42
42
--error  1054
43
43
explain select xx from t1 union select 1;
44
 
--error 1222
 
44
--error ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT
45
45
explain select a,b from t1 union select 1;
46
 
--error 1222
 
46
--error ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT
47
47
explain select 1 union select a,b from t1 union select 1;
48
 
--error 1222
 
48
--error ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT
49
49
explain select a,b from t1 union select 1 limit 0;
50
50
 
51
 
--error 1221
 
51
--error ER_WRONG_USAGE
52
52
select a,b from t1 into outfile 'skr' union select a,b from t2;
53
53
 
54
 
--error 1221
 
54
--error ER_WRONG_USAGE
55
55
select a,b from t1 order by a union select a,b from t2;
56
56
 
57
 
--error 1221
 
57
--error ER_WRONG_USAGE
58
58
insert into t3 select a from t1 order by a union select a from t2;
59
59
 
60
 
--error 1222
 
60
--error ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT
61
61
create table t3 select a,b from t1 union select a from t2;
62
62
 
63
 
--error 1222
 
63
--error ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT
64
64
select a,b from t1 union select a from t2;
65
65
 
66
 
--error 1222
 
66
--error ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT
67
67
select * from t1 union select a from t2;
68
68
 
69
 
--error 1222
 
69
--error ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT
70
70
select a from t1 union select * from t2;
71
71
 
72
 
--error 1234
 
72
--error ER_CANT_USE_OPTION_HERE
73
73
select * from t1 union select SQL_BUFFER_RESULT * from t2;
74
74
 
75
75
# Test CREATE, INSERT and REPLACE
83
83
#
84
84
# Test some unions without tables
85
85
#
86
 
--error 1096
 
86
--error ER_NO_TABLES_USED
87
87
select * union select 1;
88
88
select 1 as a,(select a union select a);
89
 
--error 1054
 
89
--error ER_BAD_FIELD_ERROR
90
90
(select 1) union (select 2) order by 0;
91
91
SELECT @a:=1 UNION SELECT @a:=@a+1;
92
 
--error 1054
 
92
--error ER_BAD_FIELD_ERROR
93
93
(SELECT 1) UNION (SELECT 2) ORDER BY (SELECT a);
94
94
(SELECT 1,3) UNION (SELECT 2,1) ORDER BY (SELECT 2);
95
95
 
219
219
(SELECT SQL_CALC_FOUND_ROWS * FROM t1) UNION all (SELECT * FROM t2 LIMIT 1);
220
220
select found_rows();
221
221
# This used to work in 4.0 but not anymore in 4.1
222
 
--error 1064
 
222
--error ER_PARSE_ERROR
223
223
(SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 1) UNION SELECT * FROM t2 LIMIT 1;
224
224
#select found_rows();
225
225
 
250
250
(SELECT * FROM t1 ORDER by a) UNION ALL (SELECT * FROM t2 ORDER BY a) ORDER BY A desc LIMIT 4;
251
251
 
252
252
# Wrong usage
253
 
--error 1234
 
253
--error ER_CANT_USE_OPTION_HERE
254
254
(SELECT * FROM t1) UNION all (SELECT SQL_CALC_FOUND_ROWS * FROM t2) LIMIT 1;
255
255
 
256
256
create temporary table t1 select a from t1 union select a from t2;
257
257
drop temporary table t1;
258
 
--error 1093
 
258
--error ER_UPDATE_TABLE_USED
259
259
create table t1 select a from t1 union select a from t2;
260
 
--error 1054
 
260
--error ER_BAD_FIELD_ERROR
261
261
select a from t1 union select a from t2 order by t2.a;
262
262
drop table t1,t2;
263
263
 
457
457
insert into t1 select * from t2;
458
458
insert into t2 select * from t1;
459
459
set local tmp_table_size=1024;
460
 
select count(*) from (select * from t1 union all select * from t2 order by 1) b;
 
460
select SQL_BIG_RESULT count(*) from (select SQL_BIG_RESULT * from t1 union all select * from t2 order by 1) b;
461
461
select count(*) from t1;
462
462
select count(*) from t2;
463
463
drop table t1,t2;
548
548
#
549
549
CREATE TABLE t1 (i int default NULL,c char(1) default NULL,KEY i (i));
550
550
CREATE TABLE t2 (i int default NULL,c char(1) default NULL,KEY i (i));
551
 
--error 1054
 
551
--error ER_BAD_FIELD_ERROR
552
552
explain (select * from t1) union (select * from t2) order by not_existing_column;
553
553
drop table t1, t2;
554
554
 
602
602
create table t3 (a ENUM('Yes', 'No') NOT NULL);
603
603
create table t4 (a ENUM('aaa', 'bbb') NOT NULL);
604
604
insert into t3 values (1);
605
 
--error 1691 # Bad enum
 
605
--error ER_INVALID_ENUM_VALUE # Bad enum
606
606
insert into t4 values (3);
607
607
select "1" as a union select a from t1;
608
608
select a as a from t1 union select "1";
653
653
drop table t1;
654
654
 
655
655
# Drizzle doesn't support specifying character set, it is all UTF8
656
 
--error 1064
 
656
--error ER_PARSE_ERROR
657
657
create table t2 (
658
658
a char character set utf8 collate utf8_swedish_ci,
659
659
b char character set utf8 collate utf8_spanish_ci);
661
661
create table t2 (
662
662
a char collate utf8_swedish_ci,
663
663
b char collate utf8_spanish_ci);
664
 
--error 1271
 
664
--error ER_CANT_AGGREGATE_NCOLLATIONS
665
665
create table t1 as
666
666
(select a from t2) union
667
667
(select b from t2);
668
668
 
669
 
--error 1166
 
669
--error ER_WRONG_COLUMN_NAME
670
670
create table t1 as
671
671
(select a collate utf8_swedish_ci from t2) union
672
672
(select b from t2);
746
746
# Bug#15949 union + illegal mix of collations (IMPLICIT + COERCIBLE)
747
747
#
748
748
select concat('a', 'b' collate utf8_bin);
749
 
create table t1 (foo varchar(100)) collate utf8_bin;
 
749
create table t1 (foo varchar(100)) collate=utf8_bin;
750
750
insert into t1 (foo) values ("foo");
751
 
--error 1146
 
751
--error ER_NO_SUCH_TABLE
752
752
select foo from t1 union select 'bar' as foo from dual;
753
753
select foo from t1 union select 'bar' as foo;
754
754
drop table t1;
956
956
INSERT INTO t1 VALUES (3),(1),(2),(4),(1);
957
957
 
958
958
SELECT a FROM (SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY a) AS test;
959
 
--error 1054 
 
959
--error ER_BAD_FIELD_ERROR 
960
960
SELECT a FROM (SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY c) AS test;
961
961
 
962
962
DROP TABLE t1;
964
964
#
965
965
# Bug#23345: Wrongly allowed INTO in a non-last select of a UNION.
966
966
#
967
 
--error 1221
 
967
--error ER_WRONG_USAGE
968
968
(select 1 into @var) union (select 1);
969
969
(select 1) union (select 1 into @var);
970
970
select @var;
971
 
--error 1172
 
971
--error ER_TOO_MANY_ROWS
972
972
(select 2) union (select 1 into @var);
973
973
 
974
974
#