~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
drop table if exists t1,t2,t3,t4,t5,t6;
2
CREATE TABLE t1 (a int not null, b char (10) not null);
3
insert into t1 values(1,'a'),(2,'b'),(3,'c'),(3,'c');
4
CREATE TABLE t2 (a int not null, b char (10) not null);
5
insert into t2 values (3,'c'),(4,'d'),(5,'f'),(6,'e');
6
select a,b from t1 union distinct select a,b from t2;
7
a	b
8
1	a
9
2	b
10
3	c
11
4	d
12
5	f
13
6	e
14
select a,b from t1 union all select a,b from t2;
15
a	b
16
1	a
17
2	b
18
3	c
19
3	c
20
3	c
21
4	d
22
5	f
23
6	e
24
select a,b from t1 union all select a,b from t2 order by b;
25
a	b
26
1	a
27
2	b
28
3	c
29
3	c
30
3	c
31
4	d
32
6	e
33
5	f
34
select a,b from t1 union all select a,b from t2 union select 7,'g';
35
a	b
36
1	a
37
2	b
38
3	c
39
4	d
40
5	f
41
6	e
42
7	g
43
select 0,'#' union select a,b from t1 union all select a,b from t2 union select 7,'gg';
44
0	#
45
0	#
46
1	a
47
2	b
48
3	c
49
4	d
50
5	f
51
6	e
52
7	gg
53
select a,b from t1 union select a,b from t1;
54
a	b
55
1	a
56
2	b
57
3	c
58
select 't1',b,count(*) from t1 group by b UNION select 't2',b,count(*) from t2 group by b;
59
t1	b	count(*)
60
t1	a	1
61
t1	b	1
62
t1	c	2
63
t2	c	1
64
t2	d	1
65
t2	e	1
66
t2	f	1
67
(select a,b from t1 limit 2)  union all (select a,b from t2 order by a) limit 4;
68
a	b
69
1	a
70
2	b
71
3	c
72
4	d
73
(select a,b from t1 limit 2)  union all (select a,b from t2 order by a limit 1);
74
a	b
75
1	a
76
2	b
77
3	c
78
(select a,b from t1 limit 2)  union all (select a,b from t2 order by a limit 1) order by b desc;
79
a	b
80
3	c
81
2	b
82
1	a
83
(select a,b from t1 limit 2)  union all (select a,b from t2 order by a limit 1) order by t1.b;
84
ERROR 42000: Table 't1' from one of the SELECTs cannot be used in global ORDER clause
85
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;
86
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1063.9.44 by Stewart Smith
union.test for MyISAM as temp only.
87
1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	#	100.00	
88
2	UNION	t2	ALL	NULL	NULL	NULL	NULL	#	100.00	Using filesort
89
NULL	UNION RESULT	<union1,2>	ALL	NULL	NULL	NULL	NULL	#	NULL	Using filesort
1 by brian
clean slate
90
Warnings:
91
Note	1003	(select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` limit 2) union all (select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`a` limit 1) order by `b` desc
92
(select sql_calc_found_rows  a,b from t1 limit 2)  union all (select a,b from t2 order by a) limit 2;
93
a	b
94
1	a
95
2	b
96
select found_rows();
97
found_rows()
98
6
99
select sql_calc_found_rows  a,b from t1  union all select a,b from t2 limit 2;
100
a	b
101
1	a
102
2	b
103
select found_rows();
104
found_rows()
105
8
106
explain select a,b from t1 union all select a,b from t2;
107
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1063.9.44 by Stewart Smith
union.test for MyISAM as temp only.
108
1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	#	
109
2	UNION	t2	ALL	NULL	NULL	NULL	NULL	#	
110
NULL	UNION RESULT	<union1,2>	ALL	NULL	NULL	NULL	NULL	#	
1 by brian
clean slate
111
explain select xx from t1 union select 1;
112
ERROR 42S22: Unknown column 'xx' in 'field list'
113
explain select a,b from t1 union select 1;
114
ERROR 21000: The used SELECT statements have a different number of columns
115
explain select 1 union select a,b from t1 union select 1;
116
ERROR 21000: The used SELECT statements have a different number of columns
117
explain select a,b from t1 union select 1 limit 0;
118
ERROR 21000: The used SELECT statements have a different number of columns
119
select a,b from t1 into outfile 'skr' union select a,b from t2;
120
ERROR HY000: Incorrect usage of UNION and INTO
121
select a,b from t1 order by a union select a,b from t2;
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
122
ERROR HY000: Incorrect usage of UNION and order_st BY
1 by brian
clean slate
123
insert into t3 select a from t1 order by a union select a from t2;
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
124
ERROR HY000: Incorrect usage of UNION and order_st BY
1 by brian
clean slate
125
create table t3 select a,b from t1 union select a from t2;
126
ERROR 21000: The used SELECT statements have a different number of columns
127
select a,b from t1 union select a from t2;
128
ERROR 21000: The used SELECT statements have a different number of columns
129
select * from t1 union select a from t2;
130
ERROR 21000: The used SELECT statements have a different number of columns
131
select a from t1 union select * from t2;
132
ERROR 21000: The used SELECT statements have a different number of columns
133
select * from t1 union select SQL_BUFFER_RESULT * from t2;
722.2.33 by Monty Taylor
Fixed a wanton lack of null termination.
134
ERROR 42000: Incorrect usage/placement of 'SQL_BUFFER_RESULT'
1 by brian
clean slate
135
create table t3 select a,b from t1 union all select a,b from t2;
136
insert into t3 select a,b from t1 union all select a,b from t2;
137
replace into t3 select a,b as c from t1 union all select a,b from t2;
138
drop table t1,t2,t3;
139
select * union select 1;
140
ERROR HY000: No tables used
141
select 1 as a,(select a union select a);
142
a	(select a union select a)
143
1	1
144
(select 1) union (select 2) order by 0;
145
ERROR 42S22: Unknown column '0' in 'order clause'
146
SELECT @a:=1 UNION SELECT @a:=@a+1;
147
@a:=1
148
1
149
2
150
(SELECT 1) UNION (SELECT 2) ORDER BY (SELECT a);
151
ERROR 42S22: Unknown column 'a' in 'field list'
152
(SELECT 1,3) UNION (SELECT 2,1) ORDER BY (SELECT 2);
153
1	3
154
1	3
155
2	1
156
CREATE TABLE t1 (
157
`pseudo` char(35) NOT NULL default '',
158
`pseudo1` char(35) NOT NULL default '',
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
159
`same` int NOT NULL default '1',
1 by brian
clean slate
160
PRIMARY KEY  (`pseudo1`),
161
KEY `pseudo` (`pseudo`)
1063.9.44 by Stewart Smith
union.test for MyISAM as temp only.
162
);
1 by brian
clean slate
163
INSERT INTO t1 (pseudo,pseudo1,same) VALUES ('joce', 'testtt', 1),('joce', 'tsestset', 1),('dekad', 'joce', 1);
164
SELECT pseudo FROM t1 WHERE pseudo1='joce' UNION SELECT pseudo FROM t1 WHERE pseudo='joce';
165
pseudo
166
dekad
167
joce
168
SELECT pseudo1 FROM t1 WHERE pseudo1='joce' UNION SELECT pseudo1 FROM t1 WHERE pseudo='joce';
169
pseudo1
170
joce
171
testtt
172
tsestset
173
SELECT * FROM t1 WHERE pseudo1='joce' UNION SELECT * FROM t1 WHERE pseudo='joce' order by pseudo desc,pseudo1 desc;
174
pseudo	pseudo1	same
175
joce	tsestset	1
176
joce	testtt	1
177
dekad	joce	1
178
SELECT pseudo1 FROM t1 WHERE pseudo='joce' UNION SELECT pseudo FROM t1 WHERE pseudo1='joce';
179
pseudo1
180
testtt
181
tsestset
182
dekad
183
SELECT pseudo1 FROM t1 WHERE pseudo='joce' UNION ALL SELECT pseudo FROM t1 WHERE pseudo1='joce';
184
pseudo1
185
testtt
186
tsestset
187
dekad
188
SELECT pseudo1 FROM t1 WHERE pseudo='joce' UNION SELECT 1;
189
pseudo1
190
testtt
191
tsestset
192
1
193
drop table t1;
194
create table t1 (a int);
195
create table t2 (a int);
196
insert into t1 values (1),(2),(3),(4),(5);
197
insert into t2 values (11),(12),(13),(14),(15);
198
(select * from t1 limit 2) union (select * from t2 limit 3) limit 4;
199
a
200
1
201
2
202
11
203
12
204
(select * from t1 limit 2) union (select * from t2 limit 3);
205
a
206
1
207
2
208
11
209
12
210
13
211
(select * from t1 limit 2) union (select * from t2 limit 20,3);
212
a
213
1
214
2
215
set SQL_SELECT_LIMIT=2;
216
(select * from t1 limit 1) union (select * from t2 limit 3);
217
a
218
1
219
11
220
set SQL_SELECT_LIMIT=DEFAULT;
221
drop table t1,t2;
222
CREATE TABLE t1 (
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
223
cid int NOT NULL default '0',
224
cv varchar(190) NOT NULL default '',
1 by brian
clean slate
225
PRIMARY KEY  (cid),
226
UNIQUE KEY cv (cv)
227
) ;
228
INSERT INTO t1 VALUES (8,'dummy');
229
CREATE TABLE t2 (
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
230
cid int NOT NULL auto_increment,
1 by brian
clean slate
231
cap varchar(255) NOT NULL default '',
232
PRIMARY KEY  (cid),
233
KEY cap (cap)
234
) ;
235
CREATE TABLE t3 (
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
236
gid int NOT NULL auto_increment,
1 by brian
clean slate
237
gn varchar(255) NOT NULL default '',
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
238
must int default NULL,
1 by brian
clean slate
239
PRIMARY KEY  (gid),
240
KEY gn (gn)
241
) ;
242
INSERT INTO t3 VALUES (1,'V1',NULL);
243
CREATE TABLE t4 (
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
244
uid bigint NOT NULL default '0',
245
gid bigint default NULL,
246
rid bigint default NULL,
247
cid bigint default NULL,
1 by brian
clean slate
248
UNIQUE KEY m (uid,gid,rid,cid),
249
KEY uid (uid),
250
KEY rid (rid),
251
KEY cid (cid),
252
KEY container (gid,rid,cid)
253
) ;
254
INSERT INTO t4 VALUES (1,1,NULL,NULL);
255
CREATE TABLE t5 (
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
256
rid bigint NOT NULL auto_increment,
1 by brian
clean slate
257
rl varchar(255) NOT NULL default '',
258
PRIMARY KEY  (rid),
259
KEY rl (rl)
260
) ;
261
CREATE TABLE t6 (
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
262
uid bigint NOT NULL auto_increment,
263
un varchar(190) NOT NULL default '',
264
uc int NOT NULL default '0',
1 by brian
clean slate
265
PRIMARY KEY  (uid),
266
UNIQUE KEY nc (un,uc),
267
KEY un (un)
268
) ;
269
INSERT INTO t6 VALUES (1,'test',8);
270
SELECT t4.uid, t5.rl, t3.gn as g1, t4.cid, t4.gid as gg FROM t3, t6, t1, t4 left join t5 on t5.rid = t4.rid left join t2 on t2.cid = t4.cid WHERE t3.gid=t4.gid AND t6.uid = t4.uid AND t6.uc  = t1.cid AND t1.cv = "dummy" AND t6.un = "test";
271
uid	rl	g1	cid	gg
272
1	NULL	V1	NULL	1
273
SELECT t4.uid, t5.rl, t3.gn as g1, t4.cid, t4.gid as gg FROM t3, t6, t1, t4 left join t5 on t5.rid = t4.rid left join t2 on t2.cid = t4.cid WHERE t3.gid=t4.gid AND t6.uid = t4.uid AND t3.must IS NOT NULL AND t6.uc  = t1.cid AND t1.cv = "dummy" AND t6.un = "test";
274
uid	rl	g1	cid	gg
275
(SELECT t4.uid, t5.rl, t3.gn as g1, t4.cid, t4.gid as gg FROM t3, t6, t1, t4 left join t5 on t5.rid = t4.rid left join t2 on t2.cid = t4.cid WHERE t3.gid=t4.gid AND t6.uid = t4.uid AND t3.must IS NOT NULL AND t6.uc  = t1.cid AND t1.cv = "dummy" AND t6.un = "test") UNION (SELECT t4.uid, t5.rl, t3.gn as g1, t4.cid, t4.gid as gg FROM t3, t6, t1, t4 left join t5 on t5.rid = t4.rid left join t2 on t2.cid = t4.cid WHERE t3.gid=t4.gid AND t6.uid = t4.uid AND t6.uc  = t1.cid AND t1.cv = "dummy" AND t6.un = "test");
276
uid	rl	g1	cid	gg
277
1	NULL	V1	NULL	1
278
drop table t1,t2,t3,t4,t5,t6;
279
CREATE TABLE t1 (a int not null, b char (10) not null);
280
insert into t1 values(1,'a'),(2,'b'),(3,'c'),(3,'c');
281
CREATE TABLE t2 (a int not null, b char (10) not null);
282
insert into t2 values (3,'c'),(4,'d'),(5,'f'),(6,'e');
283
create table t3 select a,b from t1 union select a,b from t2;
284
create table t4 (select a,b from t1) union (select a,b from t2) limit 2;
285
insert into  t4 select a,b from t1 union select a,b from t2;
286
insert into  t3 (select a,b from t1) union (select a,b from t2) limit 2;
287
select * from t3;
288
a	b
289
1	a
290
2	b
291
3	c
292
4	d
293
5	f
294
6	e
295
1	a
296
2	b
297
select * from t4;
298
a	b
299
1	a
300
2	b
301
1	a
302
2	b
303
3	c
304
4	d
305
5	f
306
6	e
307
drop table t1,t2,t3,t4;
308
create table t1 (a int);
309
insert into t1 values (1),(2),(3);
310
create table t2 (a int);
311
insert into t2 values (3),(4),(5);
312
(SELECT SQL_CALC_FOUND_ROWS * FROM t1) UNION all (SELECT * FROM t2) LIMIT 1;
313
a
314
1
315
select found_rows();
316
found_rows()
317
6
318
(SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 1) UNION all (SELECT * FROM t2) LIMIT 2;
319
a
320
1
321
3
322
select found_rows();
323
found_rows()
324
4
325
(SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 1) UNION all (SELECT * FROM t2);
326
a
327
1
328
3
329
4
330
5
331
select found_rows();
332
found_rows()
333
4
334
(SELECT SQL_CALC_FOUND_ROWS * FROM t1) UNION all (SELECT * FROM t2 LIMIT 1);
335
a
336
1
337
2
338
3
339
3
340
select found_rows();
341
found_rows()
342
4
343
(SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 1) UNION SELECT * FROM t2 LIMIT 1;
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
344
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your Drizzle server version for the right syntax to use near '' at line 1
1 by brian
clean slate
345
SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 1 UNION all SELECT * FROM t2 LIMIT 2;
346
a
347
1
348
3
349
select found_rows();
350
found_rows()
351
6
352
SELECT SQL_CALC_FOUND_ROWS * FROM t1 UNION all SELECT * FROM t2 LIMIT 2;
353
a
354
1
355
2
356
select found_rows();
357
found_rows()
358
6
359
SELECT SQL_CALC_FOUND_ROWS * FROM t1 UNION SELECT * FROM t2 LIMIT 2;
360
a
361
1
362
2
363
select found_rows();
364
found_rows()
365
6
366
SELECT SQL_CALC_FOUND_ROWS * FROM t1 UNION SELECT * FROM t2 LIMIT 100;
367
a
368
1
369
2
370
3
371
4
372
5
373
select found_rows();
374
found_rows()
375
6
376
SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 100 UNION SELECT * FROM t2;
377
a
378
1
379
2
380
3
381
4
382
5
383
select found_rows();
384
found_rows()
385
5
386
SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 1 UNION SELECT * FROM t2;
387
a
388
1
389
3
390
4
391
5
392
select found_rows();
393
found_rows()
394
6
395
SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 1 UNION SELECT * FROM t2 LIMIT 2;
396
a
397
1
398
3
399
select found_rows();
400
found_rows()
401
6
402
SELECT SQL_CALC_FOUND_ROWS * FROM t1 UNION SELECT * FROM t2 LIMIT 2,2;
403
a
404
3
405
4
406
select found_rows();
407
found_rows()
408
6
409
SELECT SQL_CALC_FOUND_ROWS * FROM t1 limit 2,2 UNION SELECT * FROM t2;
410
a
411
3
412
4
413
5
414
select found_rows();
415
found_rows()
416
5
417
SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a desc LIMIT 1;
418
a
419
5
420
(SELECT * FROM t1 ORDER by a) UNION ALL (SELECT * FROM t2 ORDER BY a) ORDER BY A desc LIMIT 4;
421
a
422
5
423
4
424
3
425
3
426
(SELECT * FROM t1) UNION all (SELECT SQL_CALC_FOUND_ROWS * FROM t2) LIMIT 1;
427
ERROR 42000: Incorrect usage/placement of 'SQL_CALC_FOUND_ROWS'
428
create temporary table t1 select a from t1 union select a from t2;
429
drop temporary table t1;
430
create table t1 select a from t1 union select a from t2;
431
ERROR HY000: You can't specify target table 't1' for update in FROM clause
432
select a from t1 union select a from t2 order by t2.a;
433
ERROR 42S22: Unknown column 't2.a' in 'order clause'
434
drop table t1,t2;
435
select length(version()) > 1 as `*` UNION select 2;
436
*
437
1
438
2
439
create table t1 (a int);
440
insert into t1 values (0), (3), (1), (2);
441
explain (select * from t1) union (select * from t1) order by a;
442
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
443
1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	4	
444
2	UNION	t1	ALL	NULL	NULL	NULL	NULL	4	
445
NULL	UNION RESULT	<union1,2>	ALL	NULL	NULL	NULL	NULL	NULL	Using filesort
446
drop table t1;
1063.9.44 by Stewart Smith
union.test for MyISAM as temp only.
447
CREATE TEMPORARY TABLE t1 (  id int default '0') ENGINE=MyISAM;
1 by brian
clean slate
448
INSERT INTO t1 (id) VALUES("1");
1063.9.44 by Stewart Smith
union.test for MyISAM as temp only.
449
CREATE TEMPORARY TABLE t2 ( id int default '0',  id_master int default '0',  text1 varchar(5) default NULL,  text2 varchar(5) default NULL) ENGINE=MyISAM;
1 by brian
clean slate
450
INSERT INTO t2 (id, id_master, text1, text2) VALUES("1", "1",
451
"foo1", "bar1");
452
INSERT INTO t2 (id, id_master, text1, text2) VALUES("2", "1",
453
"foo2", "bar2");
454
INSERT INTO t2 (id, id_master, text1, text2) VALUES("3", "1", NULL,
455
"bar3");
456
INSERT INTO t2 (id, id_master, text1, text2) VALUES("4", "1",
457
"foo4", "bar4");
458
SELECT 1 AS id_master, 1 AS id, NULL AS text1, 'ABCDE' AS text2 UNION SELECT id_master, t2.id, text1, text2 FROM t1 LEFT JOIN t2 ON t1.id = t2.id_master;
459
id_master	id	text1	text2
460
1	1	NULL	ABCDE
461
1	1	foo1	bar1
462
1	2	foo2	bar2
463
1	3	NULL	bar3
464
1	4	foo4	bar4
465
SELECT 1 AS id_master, 1 AS id, 'ABCDE' AS text1, 'ABCDE' AS text2 UNION SELECT id_master, t2.id, text1, text2 FROM t1 LEFT JOIN t2 ON t1.id = t2.id_master;
466
id_master	id	text1	text2
467
1	1	ABCDE	ABCDE
468
1	1	foo1	bar1
469
1	2	foo2	bar2
470
1	3	NULL	bar3
471
1	4	foo4	bar4
472
drop table if exists t1,t2;
473
create table t1 (a int not null primary key auto_increment, b int, key(b));
474
create table t2 (a int not null primary key auto_increment, b int);
475
insert into t1 (b) values (1),(2),(2),(3);
476
insert into t2 (b) values (10),(11),(12),(13);
477
explain extended (select * from t1 where a=1) union (select * from t2 where a=1);
478
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
479
1	PRIMARY	t1	const	PRIMARY	PRIMARY	4	const	1	100.00	
480
2	UNION	t2	const	PRIMARY	PRIMARY	4	const	1	100.00	
481
NULL	UNION RESULT	<union1,2>	ALL	NULL	NULL	NULL	NULL	NULL	NULL	
482
Warnings:
483
Note	1003	(select '1' AS `a`,'1' AS `b` from `test`.`t1` where ('1' = 1)) union (select '1' AS `a`,'10' AS `b` from `test`.`t2` where ('1' = 1))
484
(select * from t1 where a=5) union (select * from t2 where a=1);
485
a	b
486
1	10
487
(select * from t1 where a=5 and a=6) union (select * from t2 where a=1);
488
a	b
489
1	10
490
(select t1.a,t1.b from t1,t2 where t1.a=5) union (select * from t2 where a=1);
491
a	b
492
1	10
493
(select * from t1 where a=1) union (select t1.a,t2.a from t1,t2 where t1.a=t2.a);
494
a	b
495
1	1
496
2	2
497
3	3
498
4	4
499
explain (select * from t1 where a=1 and b=10) union (select straight_join t1.a,t2.a from t1,t2 where t1.a=t2.a);
500
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
501
1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
502
2	UNION	t1	index	PRIMARY	PRIMARY	4	NULL	4	Using index
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
503
2	UNION	t2	eq_ref	PRIMARY	PRIMARY	4	test.t1.a	1	Using index
1 by brian
clean slate
504
NULL	UNION RESULT	<union1,2>	ALL	NULL	NULL	NULL	NULL	NULL	
505
explain (select * from t1 where a=1) union (select * from t1 where b=1);
506
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
507
1	PRIMARY	t1	const	PRIMARY	PRIMARY	4	const	1	
1685.7.6 by Patrick Crews
Updated test results with changes due to optimizer bug fix. EXPLAIN output now includes 'Using where' for several queries that didn't previously have this output
508
2	UNION	t1	ref	b	b	5	const	1	Using where; Using index
1 by brian
clean slate
509
NULL	UNION RESULT	<union1,2>	ALL	NULL	NULL	NULL	NULL	NULL	
510
drop table t1,t2;
511
create table t1 (   id int not null auto_increment, primary key (id)   ,user_name text );
512
create table t2 (    id int not null auto_increment, primary key (id)   ,group_name text );
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
513
create table t3 (    id int not null auto_increment, primary key (id)   ,user_id int   ,index user_idx (user_id)   ,foreign key (user_id) references t1(id)   ,group_id int   ,index group_idx (group_id)   ,foreign key (group_id) references t2(id) );
1 by brian
clean slate
514
insert into t1 (user_name) values ('Tester');
515
insert into t2 (group_name) values ('Group A');
516
insert into t2 (group_name) values ('Group B');
517
insert into t3 (user_id, group_id) values (1,1);
2141.4.2 by Andrew Hutchings
Implicit joins of the form "SELECT * FROM t1, t2" without WHERE or ON now error.
518
select 1 'is_in_group', a.user_name, c.group_name, b.id from t1 a, t3 b, t2 c where a.id = b.user_id and b.group_id = c.id UNION  select 0 'is_in_group', a.user_name, c.group_name, null from t1 a CROSS JOIN t2 c;
1 by brian
clean slate
519
is_in_group	user_name	group_name	id
520
1	Tester	Group A	1
521
0	Tester	Group A	NULL
522
0	Tester	Group B	NULL
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
523
drop table t3, t1, t2;
524
create table t1 (mat_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, matintnum CHAR(6) NOT NULL, test INT NULL);
525
create table t2 (mat_id INT NOT NULL, pla_id INT NOT NULL);
1 by brian
clean slate
526
insert into t1 values (NULL, 'a', 1), (NULL, 'b', 2), (NULL, 'c', 3), (NULL, 'd', 4), (NULL, 'e', 5), (NULL, 'f', 6), (NULL, 'g', 7), (NULL, 'h', 8), (NULL, 'i', 9);
527
insert into t2 values (1, 100), (1, 101), (1, 102), (2, 100), (2, 103), (2, 104), (3, 101), (3, 102), (3, 105);
528
SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id union SELECT 0, 0;
529
pla_id	matintnum
530
100	a
531
101	a
532
102	a
533
103	b
534
104	b
535
105	c
536
0	0
537
drop table t1, t2;
538
create table t1 SELECT "a" as a UNION select "aa" as a;
539
select * from t1;
540
a
541
a
2155.6.1 by Brian Aker
Fix for union.
542
aa
1 by brian
clean slate
543
show create table t1;
544
Table	Create Table
545
t1	CREATE TABLE `t1` (
2155.6.1 by Brian Aker
Fix for union.
546
  `a` VARCHAR(2) COLLATE utf8_general_ci NOT NULL DEFAULT ''
1638.10.83 by Stewart Smith
fix some more tests for explicit COLLATE in CREATE TABLE
547
) ENGINE=DEFAULT COLLATE = utf8_general_ci
1 by brian
clean slate
548
drop table t1;
549
create table t1 SELECT 12 as a UNION select "aa" as a;
550
select * from t1;
551
a
552
12
553
aa
554
show create table t1;
555
Table	Create Table
556
t1	CREATE TABLE `t1` (
2155.6.1 by Brian Aker
Fix for union.
557
  `a` VARBINARY(8) NOT NULL DEFAULT ''
1638.10.83 by Stewart Smith
fix some more tests for explicit COLLATE in CREATE TABLE
558
) ENGINE=DEFAULT COLLATE = utf8_general_ci
1 by brian
clean slate
559
drop table t1;
560
create table t1 SELECT 12 as a UNION select 12.2 as a;
561
select * from t1;
562
a
563
12.0
564
12.2
565
show create table t1;
566
Table	Create Table
567
t1	CREATE TABLE `t1` (
1743.5.2 by LinuxJedi
Alter many test cases for the new SHOW CREATE TABLE output
568
  `a` DECIMAL(3,1) NOT NULL DEFAULT '0.0'
1638.10.83 by Stewart Smith
fix some more tests for explicit COLLATE in CREATE TABLE
569
) ENGINE=DEFAULT COLLATE = utf8_general_ci
1 by brian
clean slate
570
drop table t1;
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
571
create table t2 (it1 int, it2 int not null, i int not null, ib int, f float, d double, da date, dt datetime, sc char(10), sv varchar(10), b blob, tx text);
873.1.2 by Jay Pipes
Fixed Field_datetime to never accept any bad datetimes as a string. This broke
572
insert into t2 values (NULL, 1, 3, 4, 1.5, 2.5, '1972-10-22', '1972-10-22 11:50:00', 'testc', 'testv', 'tetetetetest', 'teeeeeeeeeeeest');
1 by brian
clean slate
573
create table t1 SELECT it2 from t2 UNION select it1 from t2;
574
select * from t1;
575
it2
576
1
577
NULL
578
show create table t1;
579
Table	Create Table
580
t1	CREATE TABLE `t1` (
1743.5.2 by LinuxJedi
Alter many test cases for the new SHOW CREATE TABLE output
581
  `it2` INT DEFAULT NULL
1638.10.83 by Stewart Smith
fix some more tests for explicit COLLATE in CREATE TABLE
582
) ENGINE=DEFAULT COLLATE = utf8_general_ci
1 by brian
clean slate
583
drop table t1;
584
create table t1 SELECT it2 from t2 UNION select i from t2;
585
select * from t1;
586
it2
587
1
588
3
589
show create table t1;
590
Table	Create Table
591
t1	CREATE TABLE `t1` (
1743.5.2 by LinuxJedi
Alter many test cases for the new SHOW CREATE TABLE output
592
  `it2` INT NOT NULL DEFAULT '0'
1638.10.83 by Stewart Smith
fix some more tests for explicit COLLATE in CREATE TABLE
593
) ENGINE=DEFAULT COLLATE = utf8_general_ci
1 by brian
clean slate
594
drop table t1;
595
create table t1 SELECT i from t2 UNION select f from t2;
596
select * from t1;
597
i
598
3
599
1.5
600
show create table t1;
601
Table	Create Table
602
t1	CREATE TABLE `t1` (
1743.5.2 by LinuxJedi
Alter many test cases for the new SHOW CREATE TABLE output
603
  `i` DOUBLE DEFAULT NULL
1638.10.83 by Stewart Smith
fix some more tests for explicit COLLATE in CREATE TABLE
604
) ENGINE=DEFAULT COLLATE = utf8_general_ci
1 by brian
clean slate
605
drop table t1;
606
create table t1 SELECT f from t2 UNION select d from t2;
607
select * from t1;
608
f
609
1.5
610
2.5
611
show create table t1;
612
Table	Create Table
613
t1	CREATE TABLE `t1` (
1743.5.2 by LinuxJedi
Alter many test cases for the new SHOW CREATE TABLE output
614
  `f` DOUBLE DEFAULT NULL
1638.10.83 by Stewart Smith
fix some more tests for explicit COLLATE in CREATE TABLE
615
) ENGINE=DEFAULT COLLATE = utf8_general_ci
1 by brian
clean slate
616
drop table t1;
617
create table t1 SELECT ib from t2 UNION select f from t2;
618
select * from t1;
619
ib
620
4
621
1.5
622
show create table t1;
623
Table	Create Table
624
t1	CREATE TABLE `t1` (
1743.5.2 by LinuxJedi
Alter many test cases for the new SHOW CREATE TABLE output
625
  `ib` DOUBLE DEFAULT NULL
1638.10.83 by Stewart Smith
fix some more tests for explicit COLLATE in CREATE TABLE
626
) ENGINE=DEFAULT COLLATE = utf8_general_ci
1 by brian
clean slate
627
drop table t1;
628
create table t1 SELECT ib from t2 UNION select d from t2;
629
select * from t1;
630
ib
631
4
632
2.5
633
show create table t1;
634
Table	Create Table
635
t1	CREATE TABLE `t1` (
1743.5.2 by LinuxJedi
Alter many test cases for the new SHOW CREATE TABLE output
636
  `ib` DOUBLE DEFAULT NULL
1638.10.83 by Stewart Smith
fix some more tests for explicit COLLATE in CREATE TABLE
637
) ENGINE=DEFAULT COLLATE = utf8_general_ci
1 by brian
clean slate
638
drop table t1;
639
create table t1 SELECT f from t2 UNION select da from t2;
640
select * from t1;
641
f
642
1.5
643
1972-10-22
644
show create table t1;
645
Table	Create Table
646
t1	CREATE TABLE `t1` (
1743.5.2 by LinuxJedi
Alter many test cases for the new SHOW CREATE TABLE output
647
  `f` VARBINARY(22) DEFAULT NULL
1638.10.83 by Stewart Smith
fix some more tests for explicit COLLATE in CREATE TABLE
648
) ENGINE=DEFAULT COLLATE = utf8_general_ci
1 by brian
clean slate
649
drop table t1;
650
create table t1 SELECT da from t2 UNION select dt from t2;
651
select * from t1;
652
da
653
1972-10-22 00:00:00
654
1972-10-22 11:50:00
655
show create table t1;
656
Table	Create Table
657
t1	CREATE TABLE `t1` (
1743.5.2 by LinuxJedi
Alter many test cases for the new SHOW CREATE TABLE output
658
  `da` DATETIME DEFAULT NULL
1638.10.83 by Stewart Smith
fix some more tests for explicit COLLATE in CREATE TABLE
659
) ENGINE=DEFAULT COLLATE = utf8_general_ci
1 by brian
clean slate
660
drop table t1;
661
create table t1 SELECT dt from t2 UNION select trim(sc) from t2;
662
select trim(dt) from t1;
663
trim(dt)
664
1972-10-22 11:50:00
665
testc
666
show create table t1;
667
Table	Create Table
668
t1	CREATE TABLE `t1` (
2155.6.1 by Brian Aker
Fix for union.
669
  `dt` VARBINARY(40) DEFAULT NULL
1638.10.83 by Stewart Smith
fix some more tests for explicit COLLATE in CREATE TABLE
670
) ENGINE=DEFAULT COLLATE = utf8_general_ci
1 by brian
clean slate
671
drop table t1;
672
create table t1 SELECT dt from t2 UNION select sv from t2;
673
select * from t1;
674
dt
675
1972-10-22 11:50:00
676
testv
677
show create table t1;
678
Table	Create Table
679
t1	CREATE TABLE `t1` (
1743.5.2 by LinuxJedi
Alter many test cases for the new SHOW CREATE TABLE output
680
  `dt` VARBINARY(40) DEFAULT NULL
1638.10.83 by Stewart Smith
fix some more tests for explicit COLLATE in CREATE TABLE
681
) ENGINE=DEFAULT COLLATE = utf8_general_ci
1 by brian
clean slate
682
drop table t1;
683
create table t1 SELECT sc from t2 UNION select sv from t2;
684
select * from t1;
685
sc
686
testc
687
testv
688
show create table t1;
689
Table	Create Table
690
t1	CREATE TABLE `t1` (
1743.5.2 by LinuxJedi
Alter many test cases for the new SHOW CREATE TABLE output
691
  `sc` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL
1638.10.83 by Stewart Smith
fix some more tests for explicit COLLATE in CREATE TABLE
692
) ENGINE=DEFAULT COLLATE = utf8_general_ci
1 by brian
clean slate
693
drop table t1;
694
create table t1 SELECT dt from t2 UNION select b from t2;
695
select * from t1;
696
dt
697
1972-10-22 11:50:00
698
tetetetetest
699
show create table t1;
700
Table	Create Table
701
t1	CREATE TABLE `t1` (
1743.5.2 by LinuxJedi
Alter many test cases for the new SHOW CREATE TABLE output
702
  `dt` BLOB
1638.10.83 by Stewart Smith
fix some more tests for explicit COLLATE in CREATE TABLE
703
) ENGINE=DEFAULT COLLATE = utf8_general_ci
1 by brian
clean slate
704
drop table t1;
705
create table t1 SELECT sv from t2 UNION select b from t2;
706
select * from t1;
707
sv
708
testv
709
tetetetetest
710
show create table t1;
711
Table	Create Table
712
t1	CREATE TABLE `t1` (
1743.5.2 by LinuxJedi
Alter many test cases for the new SHOW CREATE TABLE output
713
  `sv` BLOB
1638.10.83 by Stewart Smith
fix some more tests for explicit COLLATE in CREATE TABLE
714
) ENGINE=DEFAULT COLLATE = utf8_general_ci
1 by brian
clean slate
715
drop table t1;
716
create table t1 SELECT i from t2 UNION select d from t2 UNION select b from t2;
717
select * from t1;
718
i
719
3
720
2.5
721
tetetetetest
722
show create table t1;
723
Table	Create Table
724
t1	CREATE TABLE `t1` (
1743.5.2 by LinuxJedi
Alter many test cases for the new SHOW CREATE TABLE output
725
  `i` BLOB
1638.10.83 by Stewart Smith
fix some more tests for explicit COLLATE in CREATE TABLE
726
) ENGINE=DEFAULT COLLATE = utf8_general_ci
1 by brian
clean slate
727
drop table t1;
728
create table t1 SELECT sv from t2 UNION select tx from t2;
729
select * from t1;
730
sv
731
testv
732
teeeeeeeeeeeest
733
show create table t1;
734
Table	Create Table
735
t1	CREATE TABLE `t1` (
1743.5.2 by LinuxJedi
Alter many test cases for the new SHOW CREATE TABLE output
736
  `sv` TEXT COLLATE utf8_general_ci
1638.10.83 by Stewart Smith
fix some more tests for explicit COLLATE in CREATE TABLE
737
) ENGINE=DEFAULT COLLATE = utf8_general_ci
1 by brian
clean slate
738
drop table t1;
739
create table t1 SELECT b from t2 UNION select tx from t2;
740
select * from t1;
741
b
742
tetetetetest
743
teeeeeeeeeeeest
744
show create table t1;
745
Table	Create Table
746
t1	CREATE TABLE `t1` (
1743.5.2 by LinuxJedi
Alter many test cases for the new SHOW CREATE TABLE output
747
  `b` BLOB
1638.10.83 by Stewart Smith
fix some more tests for explicit COLLATE in CREATE TABLE
748
) ENGINE=DEFAULT COLLATE = utf8_general_ci
1 by brian
clean slate
749
drop table t1,t2;
750
create table t1 select 1 union select -1;
751
select * from t1;
752
1
753
1
754
-1
755
show create table t1;
756
Table	Create Table
757
t1	CREATE TABLE `t1` (
1743.5.2 by LinuxJedi
Alter many test cases for the new SHOW CREATE TABLE output
758
  `1` BIGINT NOT NULL DEFAULT '0'
1638.10.83 by Stewart Smith
fix some more tests for explicit COLLATE in CREATE TABLE
759
) ENGINE=DEFAULT COLLATE = utf8_general_ci
1 by brian
clean slate
760
drop table t1;
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
761
create table t1 select _latin1"test" union select _latin1"testt" ;
762
ERROR 42S22: Unknown column '_latin1' in 'field list'
763
create table t1 select _utf8"test" union select _utf8"testt" ;
779.3.10 by Monty Taylor
Turned on -Wshadow.
764
ERROR 42S22: Unknown column '_utf8' in 'field list'
765
create table t1 select "test" union select "testt" ;
1 by brian
clean slate
766
show create table t1;
767
Table	Create Table
768
t1	CREATE TABLE `t1` (
2155.6.1 by Brian Aker
Fix for union.
769
  `test` VARCHAR(5) COLLATE utf8_general_ci NOT NULL DEFAULT ''
1638.10.83 by Stewart Smith
fix some more tests for explicit COLLATE in CREATE TABLE
770
) ENGINE=DEFAULT COLLATE = utf8_general_ci
1 by brian
clean slate
771
drop table t1;
772
create table t1 (s char(200));
773
insert into t1 values (repeat("1",200));
774
create table t2 select * from t1;
775
insert into t2 select * from t1;
776
insert into t1 select * from t2;
777
insert into t2 select * from t1;
778
insert into t1 select * from t2;
779
insert into t2 select * from t1;
780
set local tmp_table_size=1024;
1487.1.1 by Brian Aker
There is room for improvement around this. We should be using rows as well
781
select SQL_BIG_RESULT count(*) from (select SQL_BIG_RESULT * from t1 union all select * from t2 order by 1) b;
1 by brian
clean slate
782
count(*)
783
21
784
select count(*) from t1;
785
count(*)
786
8
787
select count(*) from t2;
788
count(*)
789
13
790
drop table t1,t2;
791
set local tmp_table_size=default;
792
create table t1 (a int, index (a), b int);
793
insert t1 values (1,1),(2,2),(3,3),(4,4),(5,5);
794
insert t1 select a+1, a+b from t1;
795
insert t1 select a+1, a+b from t1;
796
insert t1 select a+1, a+b from t1;
797
insert t1 select a+1, a+b from t1;
798
insert t1 select a+1, a+b from t1;
799
FLUSH STATUS;
800
show status like 'Slow_queries';
801
Variable_name	Value
1273.16.1 by Brian Aker
More removal of show code.
802
Slow_queries	#
1 by brian
clean slate
803
select count(*) from t1 where a=7;
804
count(*)
805
26
806
show status like 'Slow_queries';
807
Variable_name	Value
1273.16.1 by Brian Aker
More removal of show code.
808
Slow_queries	#
1 by brian
clean slate
809
select count(*) from t1 where b=13;
810
count(*)
811
10
812
show status like 'Slow_queries';
813
Variable_name	Value
1273.16.1 by Brian Aker
More removal of show code.
814
Slow_queries	#
1 by brian
clean slate
815
select count(*) from t1 where b=13 union select count(*) from t1 where a=7;
816
count(*)
817
10
818
26
819
show status like 'Slow_queries';
820
Variable_name	Value
1273.16.1 by Brian Aker
More removal of show code.
821
Slow_queries	#
1 by brian
clean slate
822
select count(*) from t1 where a=7 union select count(*) from t1 where b=13;
823
count(*)
824
26
825
10
826
show status like 'Slow_queries';
827
Variable_name	Value
1273.16.1 by Brian Aker
More removal of show code.
828
Slow_queries	#
1 by brian
clean slate
829
flush status;
830
select a from t1 where b not in (1,2,3) union select a from t1 where b not in (4,5,6);
831
a
832
4
833
5
834
3
835
6
836
7
837
8
838
9
839
10
840
1
841
2
842
show status like 'Slow_queries';
843
Variable_name	Value
1273.16.1 by Brian Aker
More removal of show code.
844
Slow_queries	#
1 by brian
clean slate
845
drop table t1;
1063.9.44 by Stewart Smith
union.test for MyISAM as temp only.
846
create table t1 (   RID int not null default '0',   IID int not null default '0',    nada varchar(50)  not null,NAME varchar(50) not null,PHONE varchar(50) not null);
1 by brian
clean slate
847
insert into t1 ( RID,IID,nada,NAME,PHONE) values (1, 1, 'main', 'a', '111'), (2, 1, 'main', 'b', '222'), (3, 1, 'main', 'c', '333'), (4, 1, 'main', 'd', '444'), (5, 1, 'main', 'e', '555'), (6, 2, 'main', 'c', '333'), (7, 2, 'main', 'd', '454'), (8, 2, 'main', 'e', '555'), (9, 2, 'main', 'f', '666'), (10, 2, 'main', 'g', '777');
848
select A.NAME, A.PHONE, B.NAME, B.PHONE from t1 A left join t1 B on A.NAME = B.NAME and B.IID = 2 where A.IID = 1 and (A.PHONE <> B.PHONE or B.NAME is null) union select A.NAME, A.PHONE, B.NAME, B.PHONE from t1 B left join t1 A on B.NAME = A.NAME and A.IID = 1 where B.IID = 2 and (A.PHONE <> B.PHONE or A.NAME is null);
849
NAME	PHONE	NAME	PHONE
850
a	111	NULL	NULL
851
b	222	NULL	NULL
852
d	444	d	454
853
NULL	NULL	f	666
854
NULL	NULL	g	777
855
drop  table t1;
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
856
create table t1 (col1 int, col2 int);
1 by brian
clean slate
857
insert into t1 values (1,2),(3,4),(5,6),(7,8),(9,10);
858
select col1 n from t1 union select col2 n from t1 order by n;
859
n
860
1
861
2
862
3
863
4
864
5
865
6
866
7
867
8
868
9
869
10
870
alter table t1 add index myindex (col2);
871
select col1 n from t1 union select col2 n from t1 order by n;
872
n
873
1
874
2
875
3
876
4
877
5
878
6
879
7
880
8
881
9
882
10
883
drop  table t1;
884
create table t1 (i int);
885
insert into t1 values (1);
886
select * from t1 UNION select * from t1;
887
i
888
1
889
select * from t1 UNION ALL select * from t1;
890
i
891
1
892
1
893
select * from t1 UNION select * from t1 UNION ALL select * from t1;
894
i
895
1
896
1
897
drop table t1;
898
select 1 as a union all select 1 union all select 2 union select 1 union all select 2;
899
a
900
1
901
2
902
2
903
set sql_select_limit=1;
904
select 1 union select 2;
905
1
906
1
907
(select 1) union (select 2);
908
1
909
1
910
(select 1) union (select 2) union (select 3) limit 2;
911
1
912
1
913
2
914
set sql_select_limit=default;
915
create table t1 (a int);
916
insert into t1 values (100), (1);
917
create table t2 (a int);
918
insert into t2 values (100);
919
select a from t1 union select a from t2 order by a;
920
a
921
1
922
100
923
SET SQL_SELECT_LIMIT=1;
924
select a from t1 union select a from t2 order by a;
925
a
926
1
927
drop table t1, t2;
928
set sql_select_limit=default;
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
929
CREATE TABLE t1 (i int default NULL,c char(1) default NULL,KEY i (i));
930
CREATE TABLE t2 (i int default NULL,c char(1) default NULL,KEY i (i));
1 by brian
clean slate
931
explain (select * from t1) union (select * from t2) order by not_existing_column;
932
ERROR 42S22: Unknown column 'not_existing_column' in 'order clause'
933
drop table t1, t2;
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
934
CREATE TABLE t1 (uid int);
1 by brian
clean slate
935
INSERT INTO t1 SELECT 150;
936
SELECT 'a' UNION SELECT uid FROM t1;
937
a
938
a
939
150
940
drop table t1;
873.1.2 by Jay Pipes
Fixed Field_datetime to never accept any bad datetimes as a string. This broke
941
CREATE TABLE t1 ( ID1 int NOT NULL DEFAULT '0' , ID2 datetime, DATA1 varchar(10) , DATA2 double(5,4) , DATA3 datetime , PRIMARY KEY (ID1,ID2));
907.1.7 by Jay Pipes
Merged in remove-timezone work
942
CREATE TABLE t2 ( ID int NOT NULL DEFAULT '0' , DATA1 timestamp NULL, PRIMARY KEY (ID));
1 by brian
clean slate
943
(SELECT * FROM t1 AS PARTITIONED, t2 AS
944
PARTITIONED_B WHERE PARTITIONED_B.ID=PARTITIONED.ID1) UNION
945
(SELECT * FROM t1 AS PARTITIONED, t2 AS
946
PARTITIONED_B WHERE PARTITIONED_B.ID=PARTITIONED.ID1) UNION
947
(SELECT * FROM t1 AS PARTITIONED, t2 AS
948
PARTITIONED_B WHERE PARTITIONED_B.ID=PARTITIONED.ID1) UNION
949
(SELECT * FROM t1 AS PARTITIONED, t2 AS
950
PARTITIONED_B WHERE PARTITIONED_B.ID=PARTITIONED.ID1) UNION
951
(SELECT * FROM t1 AS PARTITIONED, t2 AS
952
PARTITIONED_B WHERE PARTITIONED_B.ID=PARTITIONED.ID1) UNION
953
(SELECT * FROM t1 AS PARTITIONED, t2 AS
954
PARTITIONED_B WHERE PARTITIONED_B.ID=PARTITIONED.ID1) UNION
955
(SELECT * FROM t1 AS PARTITIONED, t2 AS
956
PARTITIONED_B WHERE PARTITIONED_B.ID=PARTITIONED.ID1) UNION
957
(SELECT * FROM t1 AS PARTITIONED, t2 AS
958
PARTITIONED_B WHERE PARTITIONED_B.ID=PARTITIONED.ID1) UNION
959
(SELECT * FROM t1 AS PARTITIONED, t2 AS
960
PARTITIONED_B WHERE PARTITIONED_B.ID=PARTITIONED.ID1) UNION
961
(SELECT * FROM t1 AS PARTITIONED, t2 AS
962
PARTITIONED_B WHERE PARTITIONED_B.ID=PARTITIONED.ID1) UNION
963
(SELECT * FROM t1 AS PARTITIONED, t2 AS
964
PARTITIONED_B WHERE PARTITIONED_B.ID=PARTITIONED.ID1) UNION
965
(SELECT * FROM t1 AS PARTITIONED, t2 AS
966
PARTITIONED_B WHERE PARTITIONED_B.ID=PARTITIONED.ID1);
967
ID1	ID2	DATA1	DATA2	DATA3	ID	DATA1
968
drop table t1,t2;
969
create table t1 (a ENUM('Yes', 'No') NOT NULL);
970
create table t2 (a ENUM('aaa', 'bbb') NOT NULL);
971
insert into t1 values ('No');
972
insert into t2 values ('bbb');
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
973
create table t3 (a ENUM('Yes', 'No') NOT NULL);
974
create table t4 (a ENUM('aaa', 'bbb') NOT NULL);
1 by brian
clean slate
975
insert into t3 values (1);
976
insert into t4 values (3);
934.4.1 by Jay Pipes
Fixes ENUM field type to throw an error on bad data input. 0 is now not
977
ERROR HY000: Received an invalid enum value '3'.
1 by brian
clean slate
978
select "1" as a union select a from t1;
979
a
980
1
981
No
982
select a as a from t1 union select "1";
983
a
984
No
985
1
986
select a as a from t2 union select a from t1;
987
a
988
bbb
989
No
990
select "1" as a union select a from t3;
991
a
992
1
993
Yes
994
select a as a from t3 union select "1";
995
a
996
Yes
997
1
998
select a as a from t4 union select a from t3;
999
a
1000
Yes
1001
select a as a from t1 union select a from t4;
1002
a
1003
No
1004
drop table t1,t2,t3,t4;
1005
create table t1 as
779.3.10 by Monty Taylor
Turned on -Wshadow.
1006
(select 'test') union
1007
(select 'TEST') union
1008
(select 'TeST');
1 by brian
clean slate
1009
show create table t1;
1010
Table	Create Table
1011
t1	CREATE TABLE `t1` (
1743.5.2 by LinuxJedi
Alter many test cases for the new SHOW CREATE TABLE output
1012
  `test` VARCHAR(4) COLLATE utf8_general_ci NOT NULL DEFAULT ''
1638.10.83 by Stewart Smith
fix some more tests for explicit COLLATE in CREATE TABLE
1013
) ENGINE=DEFAULT COLLATE = utf8_general_ci
1 by brian
clean slate
1014
select count(*) from t1;
1015
count(*)
1016
1
1017
drop table t1;
1018
create table t1 as
779.3.10 by Monty Taylor
Turned on -Wshadow.
1019
(select 'test' collate utf8_bin) union
1020
(select 'TEST') union
1021
(select 'TeST');
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
1022
show create table t1;
1023
Table	Create Table
1024
t1	CREATE TABLE `t1` (
1743.5.2 by LinuxJedi
Alter many test cases for the new SHOW CREATE TABLE output
1025
  `'test' collate utf8_bin` VARCHAR(4) COLLATE utf8_bin DEFAULT NULL
1638.10.83 by Stewart Smith
fix some more tests for explicit COLLATE in CREATE TABLE
1026
) ENGINE=DEFAULT COLLATE = utf8_general_ci
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
1027
select count(*) from t1;
1028
count(*)
1029
3
1030
drop table t1;
1031
create table t1 as
779.3.10 by Monty Taylor
Turned on -Wshadow.
1032
(select 'test') union
1033
(select 'TEST' collate utf8_bin) union
1034
(select 'TeST');
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
1035
show create table t1;
1036
Table	Create Table
1037
t1	CREATE TABLE `t1` (
1743.5.2 by LinuxJedi
Alter many test cases for the new SHOW CREATE TABLE output
1038
  `test` VARCHAR(4) COLLATE utf8_bin DEFAULT NULL
1638.10.83 by Stewart Smith
fix some more tests for explicit COLLATE in CREATE TABLE
1039
) ENGINE=DEFAULT COLLATE = utf8_general_ci
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
1040
select count(*) from t1;
1041
count(*)
1042
3
1043
drop table t1;
1044
create table t1 as
779.3.10 by Monty Taylor
Turned on -Wshadow.
1045
(select 'test') union
1046
(select 'TEST') union
1047
(select 'TeST' collate utf8_bin);
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
1048
show create table t1;
1049
Table	Create Table
1050
t1	CREATE TABLE `t1` (
1743.5.2 by LinuxJedi
Alter many test cases for the new SHOW CREATE TABLE output
1051
  `test` VARCHAR(4) COLLATE utf8_bin DEFAULT NULL
1638.10.83 by Stewart Smith
fix some more tests for explicit COLLATE in CREATE TABLE
1052
) ENGINE=DEFAULT COLLATE = utf8_general_ci
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
1053
select count(*) from t1;
1054
count(*)
1055
3
1056
drop table t1;
1057
create table t2 (
1058
a char character set utf8 collate utf8_swedish_ci,
1059
b char character set utf8 collate utf8_spanish_ci);
1060
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your Drizzle server version for the right syntax to use near 'character set utf8 collate utf8_swedish_ci,
1061
b char character set utf8 collate ut' at line 2
1062
create table t2 (
1063
a char collate utf8_swedish_ci,
1064
b char collate utf8_spanish_ci);
1 by brian
clean slate
1065
create table t1 as
1066
(select a from t2) union
1067
(select b from t2);
1068
ERROR HY000: Illegal mix of collations for operation 'UNION'
1069
create table t1 as
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
1070
(select a collate utf8_swedish_ci from t2) union
1 by brian
clean slate
1071
(select b from t2);
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
1072
ERROR 42000: Incorrect column name 'a collate utf8_swedish_ci '
1 by brian
clean slate
1073
create table t1 as
1074
(select a from t2) union
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
1075
(select b collate utf8_swedish_ci from t2);
1 by brian
clean slate
1076
show create table t1;
1077
Table	Create Table
1078
t1	CREATE TABLE `t1` (
1743.5.2 by LinuxJedi
Alter many test cases for the new SHOW CREATE TABLE output
1079
  `a` VARCHAR(1) COLLATE utf8_swedish_ci DEFAULT NULL
1638.10.83 by Stewart Smith
fix some more tests for explicit COLLATE in CREATE TABLE
1080
) ENGINE=DEFAULT COLLATE = utf8_general_ci
1 by brian
clean slate
1081
drop table t1;
1082
create table t1 as
1083
(select a from t2) union
1084
(select b from t2) union
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
1085
(select 'c' collate utf8_spanish_ci from t2);
1 by brian
clean slate
1086
show create table t1;
1087
Table	Create Table
1088
t1	CREATE TABLE `t1` (
1743.5.2 by LinuxJedi
Alter many test cases for the new SHOW CREATE TABLE output
1089
  `a` VARCHAR(1) COLLATE utf8_spanish_ci DEFAULT NULL
1638.10.83 by Stewart Smith
fix some more tests for explicit COLLATE in CREATE TABLE
1090
) ENGINE=DEFAULT COLLATE = utf8_general_ci
1 by brian
clean slate
1091
drop table t1;
1092
drop table t2;
1093
create table t1(a1 int, f1 char(10));
1094
create table t2
1095
select f2,a1 from (select a1, CAST('2004-12-31' AS DATE) f2 from t1) a
1096
union
1097
select f2,a1 from (select a1, CAST('2004-12-31' AS DATE) f2 from t1) a
1098
order by f2, a1;
1099
show columns from t2;
1309.2.4 by Brian Aker
New version of show columns code.
1100
Field	Type	Null	Default	Default_is_NULL	On_Update
1660 by Brian Aker
MErge in change to do YES/NO like standard requires.
1101
f2	DATE	YES		YES	
1102
a1	INTEGER	YES		YES	
1 by brian
clean slate
1103
drop table t1, t2;
1104
create table t1 (f1 int);
1105
create table t2 (f1 int, f2 int ,f3 date);
1106
create table t3 (f1 int, f2 char(10));
1107
create table t4
1108
(
1109
select t2.f3 as sdate
1110
from t1
1111
left outer join t2 on (t1.f1 = t2.f1)
1112
inner join t3 on (t2.f2 = t3.f1)
1113
order by t1.f1, t3.f1, t2.f3
1114
)
1115
union
1116
(
1117
select cast('2004-12-31' as date) as sdate
1118
from t1
1119
left outer join t2 on (t1.f1 = t2.f1)
1120
inner join t3 on (t2.f2 = t3.f1)
1121
group by t1.f1
1122
order by t1.f1, t3.f1, t2.f3
1123
)
1124
order by sdate;
1125
show columns from t4;
1309.2.4 by Brian Aker
New version of show columns code.
1126
Field	Type	Null	Default	Default_is_NULL	On_Update
1660 by Brian Aker
MErge in change to do YES/NO like standard requires.
1127
sdate	DATE	YES		YES	
1 by brian
clean slate
1128
drop table t1, t2, t3, t4;
1129
create table t1 (a int not null, b char (10) not null);
1130
insert into t1 values(1,'a'),(2,'b'),(3,'c'),(3,'c');
1131
select * from ((select * from t1 limit 1)) a;
1132
a	b
1133
1	a
1134
select * from ((select * from t1 limit 1) union (select * from t1 limit 1)) a;
1135
a	b
1136
1	a
1137
select * from ((select * from t1 limit 1) union (select * from t1 limit 1) union (select * from t1 limit 1)) a;
1138
a	b
1139
1	a
1140
select * from ((((select * from t1))) union (select * from t1) union (select * from t1)) a;
1141
a	b
1142
1	a
1143
2	b
1144
3	c
1145
select * from ((select * from t1) union (((select * from t1))) union (select * from t1)) a;
1146
a	b
1147
1	a
1148
2	b
1149
3	c
1150
drop table t1;
1151
set @val:=6;
1152
select concat('value is: ', @val) union select 'some text';
1153
concat('value is: ', @val)
1154
value is: 6
1155
some text
779.3.10 by Monty Taylor
Turned on -Wshadow.
1156
select concat('a', 'b' collate utf8_bin);
1157
concat('a', 'b' collate utf8_bin)
1 by brian
clean slate
1158
ab
1245.3.4 by Stewart Smith
make the equals of KEY=VALUE required for CREATE TABLE options
1159
create table t1 (foo varchar(100)) collate=utf8_bin;
1 by brian
clean slate
1160
insert into t1 (foo) values ("foo");
1161
select foo from t1 union select 'bar' as foo from dual;
2140.1.3 by Brian Aker
Merge in error message fix for just one type of error for unknown table.
1162
ERROR 42S02: Unknown table 'test.dual'
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
1163
select foo from t1 union select 'bar' as foo;
1 by brian
clean slate
1164
foo
1165
foo
1166
bar
1167
drop table t1;
1168
create table t1 (f1 decimal(60,25), f2 decimal(60,25));
1169
insert into t1 values (0.0,0.0);
1170
select f1 from t1 union all select f2 from t1;
1171
f1
1172
0.0000000000000000000000000
1173
0.0000000000000000000000000
1174
select 'XXXXXXXXXXXXXXXXXXXX' as description, f1 from t1
1175
union all
1176
select 'YYYYYYYYYYYYYYYYYYYY' as description, f2 from t1;
1177
description	f1
1178
XXXXXXXXXXXXXXXXXXXX	0.0000000000000000000000000
1179
YYYYYYYYYYYYYYYYYYYY	0.0000000000000000000000000
1180
drop table t1;
1181
create table t1 (f1 decimal(60,24), f2 decimal(60,24));
1182
insert into t1 values (0.0,0.0);
1183
select f1 from t1 union all select f2 from t1;
1184
f1
1185
0.000000000000000000000000
1186
0.000000000000000000000000
1187
select 'XXXXXXXXXXXXXXXXXXXX' as description, f1 from t1
1188
union all
1189
select 'YYYYYYYYYYYYYYYYYYYY' as description, f2 from t1;
1190
description	f1
1191
XXXXXXXXXXXXXXXXXXXX	0.000000000000000000000000
1192
YYYYYYYYYYYYYYYYYYYY	0.000000000000000000000000
1193
drop table t1;
1194
create table t1 (a varchar(5));
1195
create table t2 select * from t1 union select 'abcdefghijkl';
1196
show create table t2;
1197
Table	Create Table
1198
t2	CREATE TABLE `t2` (
2155.6.1 by Brian Aker
Fix for union.
1199
  `a` VARCHAR(12) COLLATE utf8_general_ci DEFAULT NULL
1638.10.83 by Stewart Smith
fix some more tests for explicit COLLATE in CREATE TABLE
1200
) ENGINE=DEFAULT COLLATE = utf8_general_ci
1273.13.32 by Brian Aker
Big ole patch. This covers moving information_schema to old_* table names
1201
select row_format from data_dictionary.TABLES where table_schema="test" and table_name="t2";
1 by brian
clean slate
1202
row_format
1273.13.32 by Brian Aker
Big ole patch. This covers moving information_schema to old_* table names
1203
DEFAULT
1 by brian
clean slate
1204
show create table t2;
1205
Table	Create Table
1206
t2	CREATE TABLE `t2` (
2155.6.1 by Brian Aker
Fix for union.
1207
  `a` VARCHAR(12) COLLATE utf8_general_ci DEFAULT NULL
1638.10.83 by Stewart Smith
fix some more tests for explicit COLLATE in CREATE TABLE
1208
) ENGINE=DEFAULT COLLATE = utf8_general_ci
1 by brian
clean slate
1209
drop table t1,t2;
1210
CREATE TABLE t1 (a mediumtext);
1211
CREATE TABLE t2 (b varchar(20));
1212
INSERT INTO t1 VALUES ('a'),('b');
1213
SELECT left(a,100000000) FROM t1 UNION  SELECT b FROM t2;
1214
left(a,100000000)
1215
a
1216
b
1217
create table t3 SELECT left(a,100000000) FROM t1 UNION  SELECT b FROM t2;
1218
show create table t3;
1219
Table	Create Table
1220
t3	CREATE TABLE `t3` (
1743.5.2 by LinuxJedi
Alter many test cases for the new SHOW CREATE TABLE output
1221
  `left(a,100000000)` TEXT COLLATE utf8_general_ci
1638.10.83 by Stewart Smith
fix some more tests for explicit COLLATE in CREATE TABLE
1222
) ENGINE=DEFAULT COLLATE = utf8_general_ci
1 by brian
clean slate
1223
drop tables t1,t2,t3;
1224
CREATE TABLE t1 (a longtext);
1225
CREATE TABLE t2 (b varchar(20));
1226
INSERT INTO t1 VALUES ('a'),('b');
1227
SELECT left(a,100000000) FROM t1 UNION  SELECT b FROM t2;
1228
left(a,100000000)
1229
a
1230
b
1231
create table t3 SELECT left(a,100000000) FROM t1 UNION  SELECT b FROM t2;
1232
show create table t3;
1233
Table	Create Table
1234
t3	CREATE TABLE `t3` (
1743.5.2 by LinuxJedi
Alter many test cases for the new SHOW CREATE TABLE output
1235
  `left(a,100000000)` TEXT COLLATE utf8_general_ci
1638.10.83 by Stewart Smith
fix some more tests for explicit COLLATE in CREATE TABLE
1236
) ENGINE=DEFAULT COLLATE = utf8_general_ci
1 by brian
clean slate
1237
drop tables t1,t2,t3;
1238
SELECT @tmp_max:= @@max_allowed_packet;
1239
@tmp_max:= @@max_allowed_packet
1877.1.4 by Andrew Hutchings
Fix test cases for the new default max_packet_size
1240
67108864
1 by brian
clean slate
1241
SET max_allowed_packet=25000000;
1242
CREATE TABLE t1 (a mediumtext);
1243
CREATE TABLE t2 (b varchar(20));
1244
INSERT INTO t1 VALUES ('a');
1245
CREATE TABLE t3 SELECT REPEAT(a,20000000) AS a FROM t1 UNION SELECT b FROM t2;
1246
SHOW CREATE TABLE t3;
1247
Table	Create Table
1248
t3	CREATE TABLE `t3` (
1743.5.2 by LinuxJedi
Alter many test cases for the new SHOW CREATE TABLE output
1249
  `a` TEXT COLLATE utf8_general_ci
1638.10.83 by Stewart Smith
fix some more tests for explicit COLLATE in CREATE TABLE
1250
) ENGINE=DEFAULT COLLATE = utf8_general_ci
1 by brian
clean slate
1251
DROP TABLES t1,t3;
1252
CREATE TABLE t1 (a tinytext);
1253
INSERT INTO t1 VALUES ('a');
1254
CREATE TABLE t3 SELECT REPEAT(a,2) AS a FROM t1 UNION SELECT b FROM t2;
1255
SHOW CREATE TABLE t3;
1256
Table	Create Table
1257
t3	CREATE TABLE `t3` (
1743.5.2 by LinuxJedi
Alter many test cases for the new SHOW CREATE TABLE output
1258
  `a` TEXT COLLATE utf8_general_ci
1638.10.83 by Stewart Smith
fix some more tests for explicit COLLATE in CREATE TABLE
1259
) ENGINE=DEFAULT COLLATE = utf8_general_ci
1 by brian
clean slate
1260
DROP TABLES t1,t3;
1261
CREATE TABLE t1 (a mediumtext);
1262
INSERT INTO t1 VALUES ('a');
1263
CREATE TABLE t3 SELECT REPEAT(a,2) AS a FROM t1 UNION SELECT b FROM t2;
1264
SHOW CREATE TABLE t3;
1265
Table	Create Table
1266
t3	CREATE TABLE `t3` (
1743.5.2 by LinuxJedi
Alter many test cases for the new SHOW CREATE TABLE output
1267
  `a` TEXT COLLATE utf8_general_ci
1638.10.83 by Stewart Smith
fix some more tests for explicit COLLATE in CREATE TABLE
1268
) ENGINE=DEFAULT COLLATE = utf8_general_ci
1 by brian
clean slate
1269
DROP TABLES t1,t3;
1270
CREATE TABLE t1 (a tinyblob);
1271
INSERT INTO t1 VALUES ('a');
1272
CREATE TABLE t3 SELECT REPEAT(a,2) AS a FROM t1 UNION SELECT b FROM t2;
1273
SHOW CREATE TABLE t3;
1274
Table	Create Table
1275
t3	CREATE TABLE `t3` (
1743.5.2 by LinuxJedi
Alter many test cases for the new SHOW CREATE TABLE output
1276
  `a` BLOB
1638.10.83 by Stewart Smith
fix some more tests for explicit COLLATE in CREATE TABLE
1277
) ENGINE=DEFAULT COLLATE = utf8_general_ci
1 by brian
clean slate
1278
DROP TABLES t1,t2,t3;
1279
SET max_allowed_packet:= @tmp_max;
1280
create table t1 ( id int not null auto_increment, primary key (id), col1 int);
1281
insert into t1 (col1) values (2),(3),(4),(5),(6);
1282
select 99 union all select id from t1 order by 1;
1283
99
1284
1
1285
2
1286
3
1287
4
1288
5
1289
99
1290
select id from t1 union all select 99 order by 1;
1291
id
1292
1
1293
2
1294
3
1295
4
1296
5
1297
99
1298
drop table t1;
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
1299
create table t1(f1 char(1), f2 char(5), f3 blob, f4 blob, f5 timestamp, f6 varchar(1) collate utf8_general_ci, f7 text);
1 by brian
clean slate
1300
create table t2 as select *, f6 as f8 from t1 union select *, f7 from t1;
1301
show create table t2;
1302
Table	Create Table
1303
t2	CREATE TABLE `t2` (
1743.5.2 by LinuxJedi
Alter many test cases for the new SHOW CREATE TABLE output
1304
  `f1` VARCHAR(1) COLLATE utf8_general_ci DEFAULT NULL,
1305
  `f2` VARCHAR(5) COLLATE utf8_general_ci DEFAULT NULL,
1306
  `f3` BLOB,
1307
  `f4` BLOB,
1308
  `f5` TIMESTAMP NULL DEFAULT NULL,
1309
  `f6` VARCHAR(1) COLLATE utf8_general_ci DEFAULT NULL,
1310
  `f7` TEXT COLLATE utf8_general_ci,
1311
  `f8` TEXT COLLATE utf8_general_ci
1638.10.83 by Stewart Smith
fix some more tests for explicit COLLATE in CREATE TABLE
1312
) ENGINE=DEFAULT COLLATE = utf8_general_ci
1 by brian
clean slate
1313
drop table t1, t2;
1314
(select avg(1)) union (select avg(1)) union (select avg(1)) union
1315
(select avg(1)) union (select avg(1)) union (select avg(1)) union
1316
(select avg(1)) union (select avg(1)) union (select avg(1)) union
1317
(select avg(1)) union (select avg(1)) union (select avg(1)) union
1318
(select avg(1)) union (select avg(1)) union (select avg(1)) union
1319
(select avg(1)) union (select avg(1)) union (select avg(1)) union
1320
(select avg(1)) union (select avg(1)) union (select avg(1)) union
1321
(select avg(1)) union (select avg(1)) union (select avg(1)) union
1322
(select avg(1)) union (select avg(1)) union (select avg(1)) union
1323
(select avg(1)) union (select avg(1)) union (select avg(1)) union
1324
(select avg(1)) union (select avg(1)) union (select avg(1)) union
1325
(select avg(1)) union (select avg(1)) union (select avg(1)) union
1326
(select avg(1)) union (select avg(1)) union (select avg(1)) union
1327
(select avg(1)) union (select avg(1)) union (select avg(1)) union
1328
(select avg(1)) union (select avg(1)) union (select avg(1)) union
1329
(select avg(1)) union (select avg(1)) union (select avg(1)) union
1330
(select avg(1)) union (select avg(1)) union (select avg(1)) union
1331
(select avg(1)) union (select avg(1)) union (select avg(1)) union
1332
(select avg(1)) union (select avg(1)) union (select avg(1)) union
1333
(select avg(1)) union (select avg(1)) union (select avg(1)) union
1334
(select avg(1)) union (select avg(1)) union (select avg(1)) union
1335
(select avg(1)) union (select avg(1)) union (select avg(1)) union
1336
(select avg(1)) union (select avg(1)) union (select avg(1)) union
1337
(select avg(1)) union (select avg(1)) union (select avg(1)) union
1338
(select avg(1)) union (select avg(1)) union (select avg(1)) union
1339
(select avg(1)) union (select avg(1)) union (select avg(1)) union
1340
(select avg(1)) union (select avg(1)) union (select avg(1)) union
1341
(select avg(1)) union (select avg(1)) union (select avg(1)) union
1342
(select avg(1)) union (select avg(1)) union (select avg(1)) union
1343
(select avg(1)) union (select avg(1)) union (select avg(1)) union
1344
(select avg(1)) union (select avg(1)) union (select avg(1)) union
1345
(select avg(1)) union (select avg(1)) union (select avg(1)) union
1346
(select avg(1)) union (select avg(1)) union (select avg(1)) union
1347
(select avg(1)) union (select avg(1)) union (select avg(1)) union
1348
(select avg(1)) union (select avg(1)) union (select avg(1)) union
1349
(select avg(1)) union (select avg(1)) union (select avg(1)) union
1350
(select avg(1)) union (select avg(1)) union (select avg(1)) union
1351
(select avg(1)) union (select avg(1)) union (select avg(1)) union
1352
(select avg(1)) union (select avg(1)) union (select avg(1)) union
1353
(select avg(1)) union (select avg(1)) union (select avg(1)) union
1354
(select avg(1)) union (select avg(1)) union (select avg(1)) union
1355
(select avg(1)) union (select avg(1)) union (select avg(1)) union
1356
(select avg(1)) union (select avg(1)) union (select avg(1));
1357
avg(1)
1358
1.0000
779.3.10 by Monty Taylor
Turned on -Wshadow.
1359
select '12' union select '12345';
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
1360
12
1361
12
2155.6.1 by Brian Aker
Fix for union.
1362
12345
1 by brian
clean slate
1363
CREATE TABLE t1 (a int);
1364
INSERT INTO t1 VALUES (3),(1),(2),(4),(1);
1365
SELECT a FROM (SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY a) AS test;
1366
a
1367
1
1368
2
1369
3
1370
4
1371
SELECT a FROM (SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY c) AS test;
1372
ERROR 42S22: Unknown column 'c' in 'order clause'
1373
DROP TABLE t1;
1374
(select 1 into @var) union (select 1);
1375
ERROR HY000: Incorrect usage of UNION and INTO
1376
(select 1) union (select 1 into @var);
1377
select @var;
1378
@var
1379
1
1380
(select 2) union (select 1 into @var);
1381
ERROR 42000: Result consisted of more than one row
1382
CREATE TABLE t1 (a int);
1383
INSERT INTO t1 VALUES (10), (20);
1384
CREATE TABLE t2 (b int);
1385
INSERT INTO t2 VALUES (10), (50), (50);
1386
SELECT a,1 FROM t1 
1387
UNION
1388
SELECT b, COUNT(*) FROM t2 GROUP BY b WITH ROLLUP
1389
ORDER BY a;
1390
a	1
1391
NULL	3
1392
10	1
1393
20	1
1394
50	2
1395
SELECT a,1 FROM t1 
1396
UNION
1397
SELECT b, COUNT(*) FROM t2 GROUP BY b WITH ROLLUP
1398
ORDER BY a DESC;
1399
a	1
1400
50	2
1401
20	1
1402
10	1
1403
NULL	3
1404
SELECT a,1 FROM t1 
1405
UNION
1406
SELECT b, COUNT(*) FROM t2 GROUP BY b WITH ROLLUP
1407
ORDER BY a ASC LIMIT 3;
1408
a	1
1409
NULL	3
1410
10	1
1411
20	1
1412
SELECT a,1 FROM t1 
1413
UNION ALL 
1414
SELECT b, COUNT(*) FROM t2 GROUP BY b WITH ROLLUP
1415
ORDER BY a DESC;
1416
a	1
1417
50	2
1418
20	1
1419
10	1
1420
10	1
1421
NULL	3
1422
SELECT a,1 FROM t1
1423
UNION 
1424
(SELECT b, COUNT(*) FROM t2 GROUP BY b WITH ROLLUP ORDER BY a);
1425
ERROR HY000: Incorrect usage of CUBE/ROLLUP and ORDER BY
1426
SELECT a,1 FROM t1
1427
UNION ALL
1428
SELECT b, COUNT(*) FROM t2 GROUP BY b WITH ROLLUP ORDER BY a
1429
UNION
1430
SELECT 1,1;
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
1431
ERROR HY000: Incorrect usage of UNION and order_st BY
1 by brian
clean slate
1432
DROP TABLE t1,t2;
1433
CREATE TABLE t1 (a INT);
1434
INSERT INTO t1 VALUES (1), (2), (3);
1435
CREATE TABLE t2 SELECT * FROM (SELECT NULL) a UNION SELECT a FROM t1;
1436
DESC t2;
1309.4.3 by Brian Aker
Refactor DESC to use new table.
1437
Field	Type	Null	Default	Default_is_NULL	On_Update
1660 by Brian Aker
MErge in change to do YES/NO like standard requires.
1438
NULL	INTEGER	YES		YES	
1 by brian
clean slate
1439
CREATE TABLE t3 SELECT a FROM t1 UNION SELECT * FROM (SELECT NULL) a;
1440
DESC t3;
1309.4.3 by Brian Aker
Refactor DESC to use new table.
1441
Field	Type	Null	Default	Default_is_NULL	On_Update
1660 by Brian Aker
MErge in change to do YES/NO like standard requires.
1442
a	INTEGER	YES		YES	
1 by brian
clean slate
1443
CREATE TABLE t4 SELECT NULL;
1444
DESC t4;
1309.4.3 by Brian Aker
Refactor DESC to use new table.
1445
Field	Type	Null	Default	Default_is_NULL	On_Update
1753.2.2 by Andrew Hutchings
Fix test cases
1446
NULL	VARBINARY	YES		YES	
1 by brian
clean slate
1447
CREATE TABLE t5 SELECT NULL UNION SELECT NULL;
1448
DESC t5;
1309.4.3 by Brian Aker
Refactor DESC to use new table.
1449
Field	Type	Null	Default	Default_is_NULL	On_Update
1753.2.2 by Andrew Hutchings
Fix test cases
1450
NULL	VARBINARY	YES		YES	
1 by brian
clean slate
1451
CREATE TABLE t6 
1452
SELECT * FROM (SELECT * FROM (SELECT NULL)a) b UNION SELECT a FROM t1;
1453
DESC t6;
1309.4.3 by Brian Aker
Refactor DESC to use new table.
1454
Field	Type	Null	Default	Default_is_NULL	On_Update
1660 by Brian Aker
MErge in change to do YES/NO like standard requires.
1455
NULL	INTEGER	YES		YES	
1 by brian
clean slate
1456
DROP TABLE t1, t2, t3, t4, t5, t6;
1457
End of 5.0 tests