~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
87
1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	4	100.00	
88
2	UNION	t2	ALL	NULL	NULL	NULL	NULL	4	100.00	Using filesort
89
NULL	UNION RESULT	<union1,2>	ALL	NULL	NULL	NULL	NULL	NULL	NULL	Using filesort
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
108
1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	4	
109
2	UNION	t2	ALL	NULL	NULL	NULL	NULL	4	
110
NULL	UNION RESULT	<union1,2>	ALL	NULL	NULL	NULL	NULL	NULL	
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`)
162
) ENGINE=MyISAM;
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
) ;
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
235
Warnings:
236
Warning	1071	Specified key was too long; max key length is 767 bytes
1 by brian
clean slate
237
CREATE TABLE t3 (
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
238
gid int NOT NULL auto_increment,
1 by brian
clean slate
239
gn varchar(255) NOT NULL default '',
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
240
must int default NULL,
1 by brian
clean slate
241
PRIMARY KEY  (gid),
242
KEY gn (gn)
243
) ;
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
244
Warnings:
245
Warning	1071	Specified key was too long; max key length is 767 bytes
1 by brian
clean slate
246
INSERT INTO t3 VALUES (1,'V1',NULL);
247
CREATE TABLE t4 (
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
248
uid bigint NOT NULL default '0',
249
gid bigint default NULL,
250
rid bigint default NULL,
251
cid bigint default NULL,
1 by brian
clean slate
252
UNIQUE KEY m (uid,gid,rid,cid),
253
KEY uid (uid),
254
KEY rid (rid),
255
KEY cid (cid),
256
KEY container (gid,rid,cid)
257
) ;
258
INSERT INTO t4 VALUES (1,1,NULL,NULL);
259
CREATE TABLE t5 (
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
260
rid bigint NOT NULL auto_increment,
1 by brian
clean slate
261
rl varchar(255) NOT NULL default '',
262
PRIMARY KEY  (rid),
263
KEY rl (rl)
264
) ;
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
265
Warnings:
266
Warning	1071	Specified key was too long; max key length is 767 bytes
1 by brian
clean slate
267
CREATE TABLE t6 (
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
268
uid bigint NOT NULL auto_increment,
269
un varchar(190) NOT NULL default '',
270
uc int NOT NULL default '0',
1 by brian
clean slate
271
PRIMARY KEY  (uid),
272
UNIQUE KEY nc (un,uc),
273
KEY un (un)
274
) ;
275
INSERT INTO t6 VALUES (1,'test',8);
276
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";
277
uid	rl	g1	cid	gg
278
1	NULL	V1	NULL	1
279
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";
280
uid	rl	g1	cid	gg
281
(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");
282
uid	rl	g1	cid	gg
283
1	NULL	V1	NULL	1
284
drop table t1,t2,t3,t4,t5,t6;
285
CREATE TABLE t1 (a int not null, b char (10) not null);
286
insert into t1 values(1,'a'),(2,'b'),(3,'c'),(3,'c');
287
CREATE TABLE t2 (a int not null, b char (10) not null);
288
insert into t2 values (3,'c'),(4,'d'),(5,'f'),(6,'e');
289
create table t3 select a,b from t1 union select a,b from t2;
290
create table t4 (select a,b from t1) union (select a,b from t2) limit 2;
291
insert into  t4 select a,b from t1 union select a,b from t2;
292
insert into  t3 (select a,b from t1) union (select a,b from t2) limit 2;
293
select * from t3;
294
a	b
295
1	a
296
2	b
297
3	c
298
4	d
299
5	f
300
6	e
301
1	a
302
2	b
303
select * from t4;
304
a	b
305
1	a
306
2	b
307
1	a
308
2	b
309
3	c
310
4	d
311
5	f
312
6	e
313
drop table t1,t2,t3,t4;
314
create table t1 (a int);
315
insert into t1 values (1),(2),(3);
316
create table t2 (a int);
317
insert into t2 values (3),(4),(5);
318
(SELECT SQL_CALC_FOUND_ROWS * FROM t1) UNION all (SELECT * FROM t2) LIMIT 1;
319
a
320
1
321
select found_rows();
322
found_rows()
323
6
324
(SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 1) UNION all (SELECT * FROM t2) LIMIT 2;
325
a
326
1
327
3
328
select found_rows();
329
found_rows()
330
4
331
(SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 1) UNION all (SELECT * FROM t2);
332
a
333
1
334
3
335
4
336
5
337
select found_rows();
338
found_rows()
339
4
340
(SELECT SQL_CALC_FOUND_ROWS * FROM t1) UNION all (SELECT * FROM t2 LIMIT 1);
341
a
342
1
343
2
344
3
345
3
346
select found_rows();
347
found_rows()
348
4
349
(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
350
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
351
SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 1 UNION all SELECT * FROM t2 LIMIT 2;
352
a
353
1
354
3
355
select found_rows();
356
found_rows()
357
6
358
SELECT SQL_CALC_FOUND_ROWS * FROM t1 UNION all SELECT * FROM t2 LIMIT 2;
359
a
360
1
361
2
362
select found_rows();
363
found_rows()
364
6
365
SELECT SQL_CALC_FOUND_ROWS * FROM t1 UNION SELECT * FROM t2 LIMIT 2;
366
a
367
1
368
2
369
select found_rows();
370
found_rows()
371
6
372
SELECT SQL_CALC_FOUND_ROWS * FROM t1 UNION SELECT * FROM t2 LIMIT 100;
373
a
374
1
375
2
376
3
377
4
378
5
379
select found_rows();
380
found_rows()
381
6
382
SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 100 UNION SELECT * FROM t2;
383
a
384
1
385
2
386
3
387
4
388
5
389
select found_rows();
390
found_rows()
391
5
392
SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 1 UNION SELECT * FROM t2;
393
a
394
1
395
3
396
4
397
5
398
select found_rows();
399
found_rows()
400
6
401
SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 1 UNION SELECT * FROM t2 LIMIT 2;
402
a
403
1
404
3
405
select found_rows();
406
found_rows()
407
6
408
SELECT SQL_CALC_FOUND_ROWS * FROM t1 UNION SELECT * FROM t2 LIMIT 2,2;
409
a
410
3
411
4
412
select found_rows();
413
found_rows()
414
6
415
SELECT SQL_CALC_FOUND_ROWS * FROM t1 limit 2,2 UNION SELECT * FROM t2;
416
a
417
3
418
4
419
5
420
select found_rows();
421
found_rows()
422
5
423
SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a desc LIMIT 1;
424
a
425
5
426
(SELECT * FROM t1 ORDER by a) UNION ALL (SELECT * FROM t2 ORDER BY a) ORDER BY A desc LIMIT 4;
427
a
428
5
429
4
430
3
431
3
432
(SELECT * FROM t1) UNION all (SELECT SQL_CALC_FOUND_ROWS * FROM t2) LIMIT 1;
433
ERROR 42000: Incorrect usage/placement of 'SQL_CALC_FOUND_ROWS'
434
create temporary table t1 select a from t1 union select a from t2;
435
drop temporary table t1;
436
create table t1 select a from t1 union select a from t2;
437
ERROR HY000: You can't specify target table 't1' for update in FROM clause
438
select a from t1 union select a from t2 order by t2.a;
439
ERROR 42S22: Unknown column 't2.a' in 'order clause'
440
drop table t1,t2;
441
select length(version()) > 1 as `*` UNION select 2;
442
*
443
1
444
2
445
create table t1 (a int);
446
insert into t1 values (0), (3), (1), (2);
447
explain (select * from t1) union (select * from t1) order by a;
448
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
449
1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	4	
450
2	UNION	t1	ALL	NULL	NULL	NULL	NULL	4	
451
NULL	UNION RESULT	<union1,2>	ALL	NULL	NULL	NULL	NULL	NULL	Using filesort
452
drop table t1;
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
453
CREATE TABLE t1 (  id int default '0') ENGINE=MyISAM;
1 by brian
clean slate
454
INSERT INTO t1 (id) VALUES("1");
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
455
CREATE 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
456
INSERT INTO t2 (id, id_master, text1, text2) VALUES("1", "1",
457
"foo1", "bar1");
458
INSERT INTO t2 (id, id_master, text1, text2) VALUES("2", "1",
459
"foo2", "bar2");
460
INSERT INTO t2 (id, id_master, text1, text2) VALUES("3", "1", NULL,
461
"bar3");
462
INSERT INTO t2 (id, id_master, text1, text2) VALUES("4", "1",
463
"foo4", "bar4");
464
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;
465
id_master	id	text1	text2
466
1	1	NULL	ABCDE
467
1	1	foo1	bar1
468
1	2	foo2	bar2
469
1	3	NULL	bar3
470
1	4	foo4	bar4
471
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;
472
id_master	id	text1	text2
473
1	1	ABCDE	ABCDE
474
1	1	foo1	bar1
475
1	2	foo2	bar2
476
1	3	NULL	bar3
477
1	4	foo4	bar4
478
drop table if exists t1,t2;
479
create table t1 (a int not null primary key auto_increment, b int, key(b));
480
create table t2 (a int not null primary key auto_increment, b int);
481
insert into t1 (b) values (1),(2),(2),(3);
482
insert into t2 (b) values (10),(11),(12),(13);
483
explain extended (select * from t1 where a=1) union (select * from t2 where a=1);
484
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
485
1	PRIMARY	t1	const	PRIMARY	PRIMARY	4	const	1	100.00	
486
2	UNION	t2	const	PRIMARY	PRIMARY	4	const	1	100.00	
487
NULL	UNION RESULT	<union1,2>	ALL	NULL	NULL	NULL	NULL	NULL	NULL	
488
Warnings:
489
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))
490
(select * from t1 where a=5) union (select * from t2 where a=1);
491
a	b
492
1	10
493
(select * from t1 where a=5 and a=6) union (select * from t2 where a=1);
494
a	b
495
1	10
496
(select t1.a,t1.b from t1,t2 where t1.a=5) union (select * from t2 where a=1);
497
a	b
498
1	10
499
(select * from t1 where a=1) union (select t1.a,t2.a from t1,t2 where t1.a=t2.a);
500
a	b
501
1	1
502
2	2
503
3	3
504
4	4
505
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);
506
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
507
1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
508
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
509
2	UNION	t2	eq_ref	PRIMARY	PRIMARY	4	test.t1.a	1	Using index
1 by brian
clean slate
510
NULL	UNION RESULT	<union1,2>	ALL	NULL	NULL	NULL	NULL	NULL	
511
explain (select * from t1 where a=1) union (select * from t1 where b=1);
512
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
513
1	PRIMARY	t1	const	PRIMARY	PRIMARY	4	const	1	
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
514
2	UNION	t1	ref	b	b	5	const	1	Using index
1 by brian
clean slate
515
NULL	UNION RESULT	<union1,2>	ALL	NULL	NULL	NULL	NULL	NULL	
516
drop table t1,t2;
517
create table t1 (   id int not null auto_increment, primary key (id)   ,user_name text );
518
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
519
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
520
insert into t1 (user_name) values ('Tester');
521
insert into t2 (group_name) values ('Group A');
522
insert into t2 (group_name) values ('Group B');
523
insert into t3 (user_id, group_id) values (1,1);
524
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, t2 c;
525
is_in_group	user_name	group_name	id
526
1	Tester	Group A	1
527
0	Tester	Group A	NULL
528
0	Tester	Group B	NULL
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
529
drop table t3, t1, t2;
530
create table t1 (mat_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, matintnum CHAR(6) NOT NULL, test INT NULL);
531
create table t2 (mat_id INT NOT NULL, pla_id INT NOT NULL);
1 by brian
clean slate
532
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);
533
insert into t2 values (1, 100), (1, 101), (1, 102), (2, 100), (2, 103), (2, 104), (3, 101), (3, 102), (3, 105);
534
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;
535
pla_id	matintnum
536
100	a
537
101	a
538
102	a
539
103	b
540
104	b
541
105	c
542
0	0
543
drop table t1, t2;
544
create table t1 SELECT "a" as a UNION select "aa" as a;
545
select * from t1;
546
a
547
a
548
show create table t1;
549
Table	Create Table
550
t1	CREATE TABLE `t1` (
873.2.35 by Monty Taylor
Update tests based on how Toru's latest patch changes create table statements.
551
  `a` varchar(1) NOT NULL DEFAULT ''
942.3.1 by Vladimir Kolesnikov
test generalizations
552
) ENGINE=DEFAULT
1 by brian
clean slate
553
drop table t1;
554
create table t1 SELECT 12 as a UNION select "aa" as a;
555
select * from t1;
556
a
557
12
558
aa
559
show create table t1;
560
Table	Create Table
561
t1	CREATE TABLE `t1` (
873.2.35 by Monty Taylor
Update tests based on how Toru's latest patch changes create table statements.
562
  `a` varbinary(4) NOT NULL DEFAULT ''
942.3.1 by Vladimir Kolesnikov
test generalizations
563
) ENGINE=DEFAULT
1 by brian
clean slate
564
drop table t1;
565
create table t1 SELECT 12 as a UNION select 12.2 as a;
566
select * from t1;
567
a
568
12.0
569
12.2
570
show create table t1;
571
Table	Create Table
572
t1	CREATE TABLE `t1` (
873.2.35 by Monty Taylor
Update tests based on how Toru's latest patch changes create table statements.
573
  `a` decimal(3,1) NOT NULL DEFAULT '0.0'
942.3.1 by Vladimir Kolesnikov
test generalizations
574
) ENGINE=DEFAULT
1 by brian
clean slate
575
drop table t1;
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
576
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
577
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
578
create table t1 SELECT it2 from t2 UNION select it1 from t2;
579
select * from t1;
580
it2
581
1
582
NULL
583
show create table t1;
584
Table	Create Table
585
t1	CREATE TABLE `t1` (
873.2.35 by Monty Taylor
Update tests based on how Toru's latest patch changes create table statements.
586
  `it2` int DEFAULT NULL
942.3.1 by Vladimir Kolesnikov
test generalizations
587
) ENGINE=DEFAULT
1 by brian
clean slate
588
drop table t1;
589
create table t1 SELECT it2 from t2 UNION select i from t2;
590
select * from t1;
591
it2
592
1
593
3
594
show create table t1;
595
Table	Create Table
596
t1	CREATE TABLE `t1` (
873.2.35 by Monty Taylor
Update tests based on how Toru's latest patch changes create table statements.
597
  `it2` int NOT NULL DEFAULT '0'
942.3.1 by Vladimir Kolesnikov
test generalizations
598
) ENGINE=DEFAULT
1 by brian
clean slate
599
drop table t1;
600
create table t1 SELECT i from t2 UNION select f from t2;
601
select * from t1;
602
i
603
3
604
1.5
605
show create table t1;
606
Table	Create Table
607
t1	CREATE TABLE `t1` (
873.2.35 by Monty Taylor
Update tests based on how Toru's latest patch changes create table statements.
608
  `i` double DEFAULT NULL
942.3.1 by Vladimir Kolesnikov
test generalizations
609
) ENGINE=DEFAULT
1 by brian
clean slate
610
drop table t1;
611
create table t1 SELECT f from t2 UNION select d from t2;
612
select * from t1;
613
f
614
1.5
615
2.5
616
show create table t1;
617
Table	Create Table
618
t1	CREATE TABLE `t1` (
873.2.35 by Monty Taylor
Update tests based on how Toru's latest patch changes create table statements.
619
  `f` double DEFAULT NULL
942.3.1 by Vladimir Kolesnikov
test generalizations
620
) ENGINE=DEFAULT
1 by brian
clean slate
621
drop table t1;
622
create table t1 SELECT ib from t2 UNION select f from t2;
623
select * from t1;
624
ib
625
4
626
1.5
627
show create table t1;
628
Table	Create Table
629
t1	CREATE TABLE `t1` (
873.2.35 by Monty Taylor
Update tests based on how Toru's latest patch changes create table statements.
630
  `ib` double DEFAULT NULL
942.3.1 by Vladimir Kolesnikov
test generalizations
631
) ENGINE=DEFAULT
1 by brian
clean slate
632
drop table t1;
633
create table t1 SELECT ib from t2 UNION select d from t2;
634
select * from t1;
635
ib
636
4
637
2.5
638
show create table t1;
639
Table	Create Table
640
t1	CREATE TABLE `t1` (
873.2.35 by Monty Taylor
Update tests based on how Toru's latest patch changes create table statements.
641
  `ib` double DEFAULT NULL
942.3.1 by Vladimir Kolesnikov
test generalizations
642
) ENGINE=DEFAULT
1 by brian
clean slate
643
drop table t1;
644
create table t1 SELECT f from t2 UNION select da from t2;
645
select * from t1;
646
f
647
1.5
648
1972-10-22
649
show create table t1;
650
Table	Create Table
651
t1	CREATE TABLE `t1` (
873.2.35 by Monty Taylor
Update tests based on how Toru's latest patch changes create table statements.
652
  `f` varbinary(22) DEFAULT NULL
942.3.1 by Vladimir Kolesnikov
test generalizations
653
) ENGINE=DEFAULT
1 by brian
clean slate
654
drop table t1;
655
create table t1 SELECT da from t2 UNION select dt from t2;
656
select * from t1;
657
da
658
1972-10-22 00:00:00
659
1972-10-22 11:50:00
660
show create table t1;
661
Table	Create Table
662
t1	CREATE TABLE `t1` (
873.2.35 by Monty Taylor
Update tests based on how Toru's latest patch changes create table statements.
663
  `da` datetime DEFAULT NULL
942.3.1 by Vladimir Kolesnikov
test generalizations
664
) ENGINE=DEFAULT
1 by brian
clean slate
665
drop table t1;
666
create table t1 SELECT dt from t2 UNION select trim(sc) from t2;
667
select trim(dt) from t1;
668
trim(dt)
669
1972-10-22 11:50:00
670
testc
671
show create table t1;
672
Table	Create Table
673
t1	CREATE TABLE `t1` (
873.2.35 by Monty Taylor
Update tests based on how Toru's latest patch changes create table statements.
674
  `dt` varbinary(19) DEFAULT NULL
942.3.1 by Vladimir Kolesnikov
test generalizations
675
) ENGINE=DEFAULT
1 by brian
clean slate
676
drop table t1;
677
create table t1 SELECT dt from t2 UNION select sv from t2;
678
select * from t1;
679
dt
680
1972-10-22 11:50:00
681
testv
682
show create table t1;
683
Table	Create Table
684
t1	CREATE TABLE `t1` (
873.2.35 by Monty Taylor
Update tests based on how Toru's latest patch changes create table statements.
685
  `dt` varbinary(40) DEFAULT NULL
942.3.1 by Vladimir Kolesnikov
test generalizations
686
) ENGINE=DEFAULT
1 by brian
clean slate
687
drop table t1;
688
create table t1 SELECT sc from t2 UNION select sv from t2;
689
select * from t1;
690
sc
691
testc
692
testv
693
show create table t1;
694
Table	Create Table
695
t1	CREATE TABLE `t1` (
873.2.35 by Monty Taylor
Update tests based on how Toru's latest patch changes create table statements.
696
  `sc` varchar(10) DEFAULT NULL
942.3.1 by Vladimir Kolesnikov
test generalizations
697
) ENGINE=DEFAULT
1 by brian
clean slate
698
drop table t1;
699
create table t1 SELECT dt from t2 UNION select b from t2;
700
select * from t1;
701
dt
702
1972-10-22 11:50:00
703
tetetetetest
704
show create table t1;
705
Table	Create Table
706
t1	CREATE TABLE `t1` (
707
  `dt` blob
942.3.1 by Vladimir Kolesnikov
test generalizations
708
) ENGINE=DEFAULT
1 by brian
clean slate
709
drop table t1;
710
create table t1 SELECT sv from t2 UNION select b from t2;
711
select * from t1;
712
sv
713
testv
714
tetetetetest
715
show create table t1;
716
Table	Create Table
717
t1	CREATE TABLE `t1` (
718
  `sv` blob
942.3.1 by Vladimir Kolesnikov
test generalizations
719
) ENGINE=DEFAULT
1 by brian
clean slate
720
drop table t1;
721
create table t1 SELECT i from t2 UNION select d from t2 UNION select b from t2;
722
select * from t1;
723
i
724
3
725
2.5
726
tetetetetest
727
show create table t1;
728
Table	Create Table
729
t1	CREATE TABLE `t1` (
730
  `i` blob
942.3.1 by Vladimir Kolesnikov
test generalizations
731
) ENGINE=DEFAULT
1 by brian
clean slate
732
drop table t1;
733
create table t1 SELECT sv from t2 UNION select tx from t2;
734
select * from t1;
735
sv
736
testv
737
teeeeeeeeeeeest
738
show create table t1;
739
Table	Create Table
740
t1	CREATE TABLE `t1` (
741
  `sv` text
942.3.1 by Vladimir Kolesnikov
test generalizations
742
) ENGINE=DEFAULT
1 by brian
clean slate
743
drop table t1;
744
create table t1 SELECT b from t2 UNION select tx from t2;
745
select * from t1;
746
b
747
tetetetetest
748
teeeeeeeeeeeest
749
show create table t1;
750
Table	Create Table
751
t1	CREATE TABLE `t1` (
752
  `b` blob
942.3.1 by Vladimir Kolesnikov
test generalizations
753
) ENGINE=DEFAULT
1 by brian
clean slate
754
drop table t1,t2;
755
create table t1 select 1 union select -1;
756
select * from t1;
757
1
758
1
759
-1
760
show create table t1;
761
Table	Create Table
762
t1	CREATE TABLE `t1` (
873.2.35 by Monty Taylor
Update tests based on how Toru's latest patch changes create table statements.
763
  `1` bigint NOT NULL DEFAULT '0'
942.3.1 by Vladimir Kolesnikov
test generalizations
764
) ENGINE=DEFAULT
1 by brian
clean slate
765
drop table t1;
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
766
create table t1 select _latin1"test" union select _latin1"testt" ;
767
ERROR 42S22: Unknown column '_latin1' in 'field list'
768
create table t1 select _utf8"test" union select _utf8"testt" ;
779.3.10 by Monty Taylor
Turned on -Wshadow.
769
ERROR 42S22: Unknown column '_utf8' in 'field list'
770
create table t1 select "test" union select "testt" ;
1 by brian
clean slate
771
show create table t1;
772
Table	Create Table
773
t1	CREATE TABLE `t1` (
873.2.35 by Monty Taylor
Update tests based on how Toru's latest patch changes create table statements.
774
  `test` varchar(4) NOT NULL DEFAULT ''
942.3.1 by Vladimir Kolesnikov
test generalizations
775
) ENGINE=DEFAULT
1 by brian
clean slate
776
drop table t1;
777
create table t1 (s char(200));
778
insert into t1 values (repeat("1",200));
779
create table t2 select * from t1;
780
insert into t2 select * from t1;
781
insert into t1 select * from t2;
782
insert into t2 select * from t1;
783
insert into t1 select * from t2;
784
insert into t2 select * from t1;
785
set local tmp_table_size=1024;
786
select count(*) from (select * from t1 union all select * from t2 order by 1) b;
787
count(*)
788
21
789
select count(*) from t1;
790
count(*)
791
8
792
select count(*) from t2;
793
count(*)
794
13
795
drop table t1,t2;
796
set local tmp_table_size=default;
797
create table t1 (a int, index (a), b int);
798
insert t1 values (1,1),(2,2),(3,3),(4,4),(5,5);
799
insert t1 select a+1, a+b from t1;
800
insert t1 select a+1, a+b from t1;
801
insert t1 select a+1, a+b from t1;
802
insert t1 select a+1, a+b from t1;
803
insert t1 select a+1, a+b from t1;
804
FLUSH STATUS;
805
show status like 'Slow_queries';
806
Variable_name	Value
807
Slow_queries	0
808
select count(*) from t1 where a=7;
809
count(*)
810
26
811
show status like 'Slow_queries';
812
Variable_name	Value
813
Slow_queries	0
814
select count(*) from t1 where b=13;
815
count(*)
816
10
817
show status like 'Slow_queries';
818
Variable_name	Value
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
819
Slow_queries	0
1 by brian
clean slate
820
select count(*) from t1 where b=13 union select count(*) from t1 where a=7;
821
count(*)
822
10
823
26
824
show status like 'Slow_queries';
825
Variable_name	Value
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
826
Slow_queries	0
1 by brian
clean slate
827
select count(*) from t1 where a=7 union select count(*) from t1 where b=13;
828
count(*)
829
26
830
10
831
show status like 'Slow_queries';
832
Variable_name	Value
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
833
Slow_queries	0
1 by brian
clean slate
834
flush status;
835
select a from t1 where b not in (1,2,3) union select a from t1 where b not in (4,5,6);
836
a
837
4
838
5
839
3
840
6
841
7
842
8
843
9
844
10
845
1
846
2
847
show status like 'Slow_queries';
848
Variable_name	Value
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
849
Slow_queries	0
1 by brian
clean slate
850
drop table t1;
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
851
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) engine=MyISAM;
1 by brian
clean slate
852
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');
853
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);
854
NAME	PHONE	NAME	PHONE
855
a	111	NULL	NULL
856
b	222	NULL	NULL
857
d	444	d	454
858
NULL	NULL	f	666
859
NULL	NULL	g	777
860
drop  table t1;
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
861
create table t1 (col1 int, col2 int);
1 by brian
clean slate
862
insert into t1 values (1,2),(3,4),(5,6),(7,8),(9,10);
863
select col1 n from t1 union select col2 n from t1 order by n;
864
n
865
1
866
2
867
3
868
4
869
5
870
6
871
7
872
8
873
9
874
10
875
alter table t1 add index myindex (col2);
876
select col1 n from t1 union select col2 n from t1 order by n;
877
n
878
1
879
2
880
3
881
4
882
5
883
6
884
7
885
8
886
9
887
10
888
drop  table t1;
889
create table t1 (i int);
890
insert into t1 values (1);
891
select * from t1 UNION select * from t1;
892
i
893
1
894
select * from t1 UNION ALL select * from t1;
895
i
896
1
897
1
898
select * from t1 UNION select * from t1 UNION ALL select * from t1;
899
i
900
1
901
1
902
drop table t1;
903
select 1 as a union all select 1 union all select 2 union select 1 union all select 2;
904
a
905
1
906
2
907
2
908
set sql_select_limit=1;
909
select 1 union select 2;
910
1
911
1
912
(select 1) union (select 2);
913
1
914
1
915
(select 1) union (select 2) union (select 3) limit 2;
916
1
917
1
918
2
919
set sql_select_limit=default;
920
create table t1 (a int);
921
insert into t1 values (100), (1);
922
create table t2 (a int);
923
insert into t2 values (100);
924
select a from t1 union select a from t2 order by a;
925
a
926
1
927
100
928
SET SQL_SELECT_LIMIT=1;
929
select a from t1 union select a from t2 order by a;
930
a
931
1
932
drop table t1, t2;
933
set sql_select_limit=default;
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
934
CREATE TABLE t1 (i int default NULL,c char(1) default NULL,KEY i (i));
935
CREATE TABLE t2 (i int default NULL,c char(1) default NULL,KEY i (i));
1 by brian
clean slate
936
explain (select * from t1) union (select * from t2) order by not_existing_column;
937
ERROR 42S22: Unknown column 'not_existing_column' in 'order clause'
938
drop table t1, t2;
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
939
CREATE TABLE t1 (uid int);
1 by brian
clean slate
940
INSERT INTO t1 SELECT 150;
941
SELECT 'a' UNION SELECT uid FROM t1;
942
a
943
a
944
150
945
drop table t1;
873.1.2 by Jay Pipes
Fixed Field_datetime to never accept any bad datetimes as a string. This broke
946
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
947
CREATE TABLE t2 ( ID int NOT NULL DEFAULT '0' , DATA1 timestamp NULL, PRIMARY KEY (ID));
1 by brian
clean slate
948
(SELECT * FROM t1 AS PARTITIONED, t2 AS
949
PARTITIONED_B WHERE PARTITIONED_B.ID=PARTITIONED.ID1) UNION
950
(SELECT * FROM t1 AS PARTITIONED, t2 AS
951
PARTITIONED_B WHERE PARTITIONED_B.ID=PARTITIONED.ID1) UNION
952
(SELECT * FROM t1 AS PARTITIONED, t2 AS
953
PARTITIONED_B WHERE PARTITIONED_B.ID=PARTITIONED.ID1) UNION
954
(SELECT * FROM t1 AS PARTITIONED, t2 AS
955
PARTITIONED_B WHERE PARTITIONED_B.ID=PARTITIONED.ID1) UNION
956
(SELECT * FROM t1 AS PARTITIONED, t2 AS
957
PARTITIONED_B WHERE PARTITIONED_B.ID=PARTITIONED.ID1) UNION
958
(SELECT * FROM t1 AS PARTITIONED, t2 AS
959
PARTITIONED_B WHERE PARTITIONED_B.ID=PARTITIONED.ID1) UNION
960
(SELECT * FROM t1 AS PARTITIONED, t2 AS
961
PARTITIONED_B WHERE PARTITIONED_B.ID=PARTITIONED.ID1) UNION
962
(SELECT * FROM t1 AS PARTITIONED, t2 AS
963
PARTITIONED_B WHERE PARTITIONED_B.ID=PARTITIONED.ID1) UNION
964
(SELECT * FROM t1 AS PARTITIONED, t2 AS
965
PARTITIONED_B WHERE PARTITIONED_B.ID=PARTITIONED.ID1) UNION
966
(SELECT * FROM t1 AS PARTITIONED, t2 AS
967
PARTITIONED_B WHERE PARTITIONED_B.ID=PARTITIONED.ID1) UNION
968
(SELECT * FROM t1 AS PARTITIONED, t2 AS
969
PARTITIONED_B WHERE PARTITIONED_B.ID=PARTITIONED.ID1) UNION
970
(SELECT * FROM t1 AS PARTITIONED, t2 AS
971
PARTITIONED_B WHERE PARTITIONED_B.ID=PARTITIONED.ID1);
972
ID1	ID2	DATA1	DATA2	DATA3	ID	DATA1
973
drop table t1,t2;
974
create table t1 (a ENUM('Yes', 'No') NOT NULL);
975
create table t2 (a ENUM('aaa', 'bbb') NOT NULL);
976
insert into t1 values ('No');
977
insert into t2 values ('bbb');
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
978
create table t3 (a ENUM('Yes', 'No') NOT NULL);
979
create table t4 (a ENUM('aaa', 'bbb') NOT NULL);
1 by brian
clean slate
980
insert into t3 values (1);
981
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
982
ERROR HY000: Received an invalid enum value '3'.
1 by brian
clean slate
983
select "1" as a union select a from t1;
984
a
985
1
986
No
987
select a as a from t1 union select "1";
988
a
989
No
990
1
991
select a as a from t2 union select a from t1;
992
a
993
bbb
994
No
995
select "1" as a union select a from t3;
996
a
997
1
998
Yes
999
select a as a from t3 union select "1";
1000
a
1001
Yes
1002
1
1003
select a as a from t4 union select a from t3;
1004
a
1005
Yes
1006
select a as a from t1 union select a from t4;
1007
a
1008
No
1009
drop table t1,t2,t3,t4;
1010
create table t1 as
779.3.10 by Monty Taylor
Turned on -Wshadow.
1011
(select 'test') union
1012
(select 'TEST') union
1013
(select 'TeST');
1 by brian
clean slate
1014
show create table t1;
1015
Table	Create Table
1016
t1	CREATE TABLE `t1` (
873.2.35 by Monty Taylor
Update tests based on how Toru's latest patch changes create table statements.
1017
  `test` varchar(4) NOT NULL DEFAULT ''
942.3.1 by Vladimir Kolesnikov
test generalizations
1018
) ENGINE=DEFAULT
1 by brian
clean slate
1019
select count(*) from t1;
1020
count(*)
1021
1
1022
drop table t1;
1023
create table t1 as
779.3.10 by Monty Taylor
Turned on -Wshadow.
1024
(select 'test' collate utf8_bin) union
1025
(select 'TEST') union
1026
(select 'TeST');
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
1027
show create table t1;
1028
Table	Create Table
1029
t1	CREATE TABLE `t1` (
873.2.35 by Monty Taylor
Update tests based on how Toru's latest patch changes create table statements.
1030
  `'test' collate utf8_bin` varchar(4) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL
942.3.1 by Vladimir Kolesnikov
test generalizations
1031
) ENGINE=DEFAULT
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
1032
select count(*) from t1;
1033
count(*)
1034
3
1035
drop table t1;
1036
create table t1 as
779.3.10 by Monty Taylor
Turned on -Wshadow.
1037
(select 'test') union
1038
(select 'TEST' collate utf8_bin) union
1039
(select 'TeST');
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
1040
show create table t1;
1041
Table	Create Table
1042
t1	CREATE TABLE `t1` (
873.2.35 by Monty Taylor
Update tests based on how Toru's latest patch changes create table statements.
1043
  `test` varchar(4) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL
942.3.1 by Vladimir Kolesnikov
test generalizations
1044
) ENGINE=DEFAULT
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
1045
select count(*) from t1;
1046
count(*)
1047
3
1048
drop table t1;
1049
create table t1 as
779.3.10 by Monty Taylor
Turned on -Wshadow.
1050
(select 'test') union
1051
(select 'TEST') union
1052
(select 'TeST' collate utf8_bin);
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
1053
show create table t1;
1054
Table	Create Table
1055
t1	CREATE TABLE `t1` (
873.2.35 by Monty Taylor
Update tests based on how Toru's latest patch changes create table statements.
1056
  `test` varchar(4) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL
942.3.1 by Vladimir Kolesnikov
test generalizations
1057
) ENGINE=DEFAULT
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
1058
select count(*) from t1;
1059
count(*)
1060
3
1061
drop table t1;
1062
create table t2 (
1063
a char character set utf8 collate utf8_swedish_ci,
1064
b char character set utf8 collate utf8_spanish_ci);
1065
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,
1066
b char character set utf8 collate ut' at line 2
1067
create table t2 (
1068
a char collate utf8_swedish_ci,
1069
b char collate utf8_spanish_ci);
1 by brian
clean slate
1070
create table t1 as
1071
(select a from t2) union
1072
(select b from t2);
1073
ERROR HY000: Illegal mix of collations for operation 'UNION'
1074
create table t1 as
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
1075
(select a collate utf8_swedish_ci from t2) union
1 by brian
clean slate
1076
(select b from t2);
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
1077
ERROR 42000: Incorrect column name 'a collate utf8_swedish_ci '
1 by brian
clean slate
1078
create table t1 as
1079
(select a from t2) union
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
1080
(select b collate utf8_swedish_ci from t2);
1 by brian
clean slate
1081
show create table t1;
1082
Table	Create Table
1083
t1	CREATE TABLE `t1` (
873.2.35 by Monty Taylor
Update tests based on how Toru's latest patch changes create table statements.
1084
  `a` varchar(1) CHARACTER SET utf8 COLLATE utf8_swedish_ci DEFAULT NULL
942.3.1 by Vladimir Kolesnikov
test generalizations
1085
) ENGINE=DEFAULT
1 by brian
clean slate
1086
drop table t1;
1087
create table t1 as
1088
(select a from t2) union
1089
(select b from t2) union
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
1090
(select 'c' collate utf8_spanish_ci from t2);
1 by brian
clean slate
1091
show create table t1;
1092
Table	Create Table
1093
t1	CREATE TABLE `t1` (
873.2.35 by Monty Taylor
Update tests based on how Toru's latest patch changes create table statements.
1094
  `a` varchar(1) CHARACTER SET utf8 COLLATE utf8_spanish_ci DEFAULT NULL
942.3.1 by Vladimir Kolesnikov
test generalizations
1095
) ENGINE=DEFAULT
1 by brian
clean slate
1096
drop table t1;
1097
drop table t2;
1098
create table t1(a1 int, f1 char(10));
1099
create table t2
1100
select f2,a1 from (select a1, CAST('2004-12-31' AS DATE) f2 from t1) a
1101
union
1102
select f2,a1 from (select a1, CAST('2004-12-31' AS DATE) f2 from t1) a
1103
order by f2, a1;
1104
show columns from t2;
1105
Field	Type	Null	Key	Default	Extra
1106
f2	date	YES		NULL	
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
1107
a1	int	YES		NULL	
1 by brian
clean slate
1108
drop table t1, t2;
1109
create table t1 (f1 int);
1110
create table t2 (f1 int, f2 int ,f3 date);
1111
create table t3 (f1 int, f2 char(10));
1112
create table t4
1113
(
1114
select t2.f3 as sdate
1115
from t1
1116
left outer join t2 on (t1.f1 = t2.f1)
1117
inner join t3 on (t2.f2 = t3.f1)
1118
order by t1.f1, t3.f1, t2.f3
1119
)
1120
union
1121
(
1122
select cast('2004-12-31' as date) as sdate
1123
from t1
1124
left outer join t2 on (t1.f1 = t2.f1)
1125
inner join t3 on (t2.f2 = t3.f1)
1126
group by t1.f1
1127
order by t1.f1, t3.f1, t2.f3
1128
)
1129
order by sdate;
1130
show columns from t4;
1131
Field	Type	Null	Key	Default	Extra
1132
sdate	date	YES		NULL	
1133
drop table t1, t2, t3, t4;
1134
create table t1 (a int not null, b char (10) not null);
1135
insert into t1 values(1,'a'),(2,'b'),(3,'c'),(3,'c');
1136
select * from ((select * from t1 limit 1)) a;
1137
a	b
1138
1	a
1139
select * from ((select * from t1 limit 1) union (select * from t1 limit 1)) a;
1140
a	b
1141
1	a
1142
select * from ((select * from t1 limit 1) union (select * from t1 limit 1) union (select * from t1 limit 1)) a;
1143
a	b
1144
1	a
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
select * from ((select * from t1) union (((select * from t1))) union (select * from t1)) a;
1151
a	b
1152
1	a
1153
2	b
1154
3	c
1155
drop table t1;
1156
set @val:=6;
1157
select concat('value is: ', @val) union select 'some text';
1158
concat('value is: ', @val)
1159
value is: 6
1160
some text
779.3.10 by Monty Taylor
Turned on -Wshadow.
1161
select concat('a', 'b' collate utf8_bin);
1162
concat('a', 'b' collate utf8_bin)
1 by brian
clean slate
1163
ab
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
1164
create table t1 (foo varchar(100)) collate utf8_bin;
1 by brian
clean slate
1165
insert into t1 (foo) values ("foo");
1166
select foo from t1 union select 'bar' as foo from dual;
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
1167
ERROR 42S02: Table 'test.dual' doesn't exist
1168
select foo from t1 union select 'bar' as foo;
1 by brian
clean slate
1169
foo
1170
foo
1171
bar
1172
drop table t1;
1173
create table t1 (f1 decimal(60,25), f2 decimal(60,25));
1174
insert into t1 values (0.0,0.0);
1175
select f1 from t1 union all select f2 from t1;
1176
f1
1177
0.0000000000000000000000000
1178
0.0000000000000000000000000
1179
select 'XXXXXXXXXXXXXXXXXXXX' as description, f1 from t1
1180
union all
1181
select 'YYYYYYYYYYYYYYYYYYYY' as description, f2 from t1;
1182
description	f1
1183
XXXXXXXXXXXXXXXXXXXX	0.0000000000000000000000000
1184
YYYYYYYYYYYYYYYYYYYY	0.0000000000000000000000000
1185
drop table t1;
1186
create table t1 (f1 decimal(60,24), f2 decimal(60,24));
1187
insert into t1 values (0.0,0.0);
1188
select f1 from t1 union all select f2 from t1;
1189
f1
1190
0.000000000000000000000000
1191
0.000000000000000000000000
1192
select 'XXXXXXXXXXXXXXXXXXXX' as description, f1 from t1
1193
union all
1194
select 'YYYYYYYYYYYYYYYYYYYY' as description, f2 from t1;
1195
description	f1
1196
XXXXXXXXXXXXXXXXXXXX	0.000000000000000000000000
1197
YYYYYYYYYYYYYYYYYYYY	0.000000000000000000000000
1198
drop table t1;
1199
create table t1 (a varchar(5));
1200
create table t2 select * from t1 union select 'abcdefghijkl';
1201
show create table t2;
1202
Table	Create Table
1203
t2	CREATE TABLE `t2` (
873.2.35 by Monty Taylor
Update tests based on how Toru's latest patch changes create table statements.
1204
  `a` varchar(5) DEFAULT NULL
942.3.1 by Vladimir Kolesnikov
test generalizations
1205
) ENGINE=DEFAULT
1 by brian
clean slate
1206
select row_format from information_schema.TABLES where table_schema="test" and table_name="t2";
1207
row_format
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
1208
Compact
1 by brian
clean slate
1209
alter table t2 ROW_FORMAT=fixed;
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
1210
Warnings:
1211
Warning	1478	InnoDB: assuming ROW_FORMAT=COMPACT.
1212
Warning	1478	InnoDB: assuming ROW_FORMAT=COMPACT.
1 by brian
clean slate
1213
show create table t2;
1214
Table	Create Table
1215
t2	CREATE TABLE `t2` (
873.2.35 by Monty Taylor
Update tests based on how Toru's latest patch changes create table statements.
1216
  `a` varchar(5) DEFAULT NULL
942.3.1 by Vladimir Kolesnikov
test generalizations
1217
) ENGINE=DEFAULT ROW_FORMAT=FIXED
1 by brian
clean slate
1218
drop table t1,t2;
1219
CREATE TABLE t1 (a mediumtext);
1220
CREATE TABLE t2 (b varchar(20));
1221
INSERT INTO t1 VALUES ('a'),('b');
1222
SELECT left(a,100000000) FROM t1 UNION  SELECT b FROM t2;
1223
left(a,100000000)
1224
a
1225
b
1226
create table t3 SELECT left(a,100000000) FROM t1 UNION  SELECT b FROM t2;
1227
show create table t3;
1228
Table	Create Table
1229
t3	CREATE TABLE `t3` (
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
1230
  `left(a,100000000)` text
942.3.1 by Vladimir Kolesnikov
test generalizations
1231
) ENGINE=DEFAULT
1 by brian
clean slate
1232
drop tables t1,t2,t3;
1233
CREATE TABLE t1 (a longtext);
1234
CREATE TABLE t2 (b varchar(20));
1235
INSERT INTO t1 VALUES ('a'),('b');
1236
SELECT left(a,100000000) FROM t1 UNION  SELECT b FROM t2;
1237
left(a,100000000)
1238
a
1239
b
1240
create table t3 SELECT left(a,100000000) FROM t1 UNION  SELECT b FROM t2;
1241
show create table t3;
1242
Table	Create Table
1243
t3	CREATE TABLE `t3` (
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
1244
  `left(a,100000000)` text
942.3.1 by Vladimir Kolesnikov
test generalizations
1245
) ENGINE=DEFAULT
1 by brian
clean slate
1246
drop tables t1,t2,t3;
1247
SELECT @tmp_max:= @@max_allowed_packet;
1248
@tmp_max:= @@max_allowed_packet
1249
1048576
1250
SET max_allowed_packet=25000000;
1251
CREATE TABLE t1 (a mediumtext);
1252
CREATE TABLE t2 (b varchar(20));
1253
INSERT INTO t1 VALUES ('a');
1254
CREATE TABLE t3 SELECT REPEAT(a,20000000) AS a FROM t1 UNION SELECT b FROM t2;
1255
SHOW CREATE TABLE t3;
1256
Table	Create Table
1257
t3	CREATE TABLE `t3` (
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
1258
  `a` text
942.3.1 by Vladimir Kolesnikov
test generalizations
1259
) ENGINE=DEFAULT
1 by brian
clean slate
1260
DROP TABLES t1,t3;
1261
CREATE TABLE t1 (a tinytext);
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` (
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
1267
  `a` text
942.3.1 by Vladimir Kolesnikov
test generalizations
1268
) ENGINE=DEFAULT
1 by brian
clean slate
1269
DROP TABLES t1,t3;
1270
CREATE TABLE t1 (a mediumtext);
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` (
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
1276
  `a` text
942.3.1 by Vladimir Kolesnikov
test generalizations
1277
) ENGINE=DEFAULT
1 by brian
clean slate
1278
DROP TABLES t1,t3;
1279
CREATE TABLE t1 (a tinyblob);
1280
INSERT INTO t1 VALUES ('a');
1281
CREATE TABLE t3 SELECT REPEAT(a,2) AS a FROM t1 UNION SELECT b FROM t2;
1282
SHOW CREATE TABLE t3;
1283
Table	Create Table
1284
t3	CREATE TABLE `t3` (
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
1285
  `a` blob
942.3.1 by Vladimir Kolesnikov
test generalizations
1286
) ENGINE=DEFAULT
1 by brian
clean slate
1287
DROP TABLES t1,t2,t3;
1288
SET max_allowed_packet:= @tmp_max;
1289
create table t1 ( id int not null auto_increment, primary key (id), col1 int);
1290
insert into t1 (col1) values (2),(3),(4),(5),(6);
1291
select 99 union all select id from t1 order by 1;
1292
99
1293
1
1294
2
1295
3
1296
4
1297
5
1298
99
1299
select id from t1 union all select 99 order by 1;
1300
id
1301
1
1302
2
1303
3
1304
4
1305
5
1306
99
1307
drop table t1;
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
1308
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
1309
create table t2 as select *, f6 as f8 from t1 union select *, f7 from t1;
1310
show create table t2;
1311
Table	Create Table
1312
t2	CREATE TABLE `t2` (
873.2.35 by Monty Taylor
Update tests based on how Toru's latest patch changes create table statements.
1313
  `f1` varchar(1) DEFAULT NULL,
1314
  `f2` varchar(5) DEFAULT NULL,
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
1315
  `f3` blob,
1316
  `f4` blob,
896.5.1 by Jay Pipes
Removes the TIME column type and related time functions.
1317
  `f5` timestamp NULL DEFAULT NULL,
873.2.35 by Monty Taylor
Update tests based on how Toru's latest patch changes create table statements.
1318
  `f6` varchar(1) DEFAULT NULL,
1 by brian
clean slate
1319
  `f7` text,
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
1320
  `f8` text
942.3.1 by Vladimir Kolesnikov
test generalizations
1321
) ENGINE=DEFAULT
1 by brian
clean slate
1322
drop table t1, t2;
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)) union
1357
(select avg(1)) union (select avg(1)) union (select avg(1)) union
1358
(select avg(1)) union (select avg(1)) union (select avg(1)) union
1359
(select avg(1)) union (select avg(1)) union (select avg(1)) union
1360
(select avg(1)) union (select avg(1)) union (select avg(1)) union
1361
(select avg(1)) union (select avg(1)) union (select avg(1)) union
1362
(select avg(1)) union (select avg(1)) union (select avg(1)) union
1363
(select avg(1)) union (select avg(1)) union (select avg(1)) union
1364
(select avg(1)) union (select avg(1)) union (select avg(1)) union
1365
(select avg(1)) union (select avg(1)) union (select avg(1));
1366
avg(1)
1367
1.0000
779.3.10 by Monty Taylor
Turned on -Wshadow.
1368
select '12' union select '12345';
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
1369
12
1370
12
1 by brian
clean slate
1371
CREATE TABLE t1 (a int);
1372
INSERT INTO t1 VALUES (3),(1),(2),(4),(1);
1373
SELECT a FROM (SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY a) AS test;
1374
a
1375
1
1376
2
1377
3
1378
4
1379
SELECT a FROM (SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY c) AS test;
1380
ERROR 42S22: Unknown column 'c' in 'order clause'
1381
DROP TABLE t1;
1382
(select 1 into @var) union (select 1);
1383
ERROR HY000: Incorrect usage of UNION and INTO
1384
(select 1) union (select 1 into @var);
1385
select @var;
1386
@var
1387
1
1388
(select 2) union (select 1 into @var);
1389
ERROR 42000: Result consisted of more than one row
1390
CREATE TABLE t1 (a int);
1391
INSERT INTO t1 VALUES (10), (20);
1392
CREATE TABLE t2 (b int);
1393
INSERT INTO t2 VALUES (10), (50), (50);
1394
SELECT a,1 FROM t1 
1395
UNION
1396
SELECT b, COUNT(*) FROM t2 GROUP BY b WITH ROLLUP
1397
ORDER BY a;
1398
a	1
1399
NULL	3
1400
10	1
1401
20	1
1402
50	2
1403
SELECT a,1 FROM t1 
1404
UNION
1405
SELECT b, COUNT(*) FROM t2 GROUP BY b WITH ROLLUP
1406
ORDER BY a DESC;
1407
a	1
1408
50	2
1409
20	1
1410
10	1
1411
NULL	3
1412
SELECT a,1 FROM t1 
1413
UNION
1414
SELECT b, COUNT(*) FROM t2 GROUP BY b WITH ROLLUP
1415
ORDER BY a ASC LIMIT 3;
1416
a	1
1417
NULL	3
1418
10	1
1419
20	1
1420
SELECT a,1 FROM t1 
1421
UNION ALL 
1422
SELECT b, COUNT(*) FROM t2 GROUP BY b WITH ROLLUP
1423
ORDER BY a DESC;
1424
a	1
1425
50	2
1426
20	1
1427
10	1
1428
10	1
1429
NULL	3
1430
SELECT a,1 FROM t1
1431
UNION 
1432
(SELECT b, COUNT(*) FROM t2 GROUP BY b WITH ROLLUP ORDER BY a);
1433
ERROR HY000: Incorrect usage of CUBE/ROLLUP and ORDER BY
1434
SELECT a,1 FROM t1
1435
UNION ALL
1436
SELECT b, COUNT(*) FROM t2 GROUP BY b WITH ROLLUP ORDER BY a
1437
UNION
1438
SELECT 1,1;
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
1439
ERROR HY000: Incorrect usage of UNION and order_st BY
1 by brian
clean slate
1440
DROP TABLE t1,t2;
1441
CREATE TABLE t1 (a INT);
1442
INSERT INTO t1 VALUES (1), (2), (3);
1443
CREATE TABLE t2 SELECT * FROM (SELECT NULL) a UNION SELECT a FROM t1;
1444
DESC t2;
1445
Field	Type	Null	Key	Default	Extra
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
1446
NULL	int	YES		NULL	
1 by brian
clean slate
1447
CREATE TABLE t3 SELECT a FROM t1 UNION SELECT * FROM (SELECT NULL) a;
1448
DESC t3;
1449
Field	Type	Null	Key	Default	Extra
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
1450
a	int	YES		NULL	
1 by brian
clean slate
1451
CREATE TABLE t4 SELECT NULL;
1452
DESC t4;
1453
Field	Type	Null	Key	Default	Extra
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
1454
NULL	varbinary(0)	YES		NULL	
1 by brian
clean slate
1455
CREATE TABLE t5 SELECT NULL UNION SELECT NULL;
1456
DESC t5;
1457
Field	Type	Null	Key	Default	Extra
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
1458
NULL	varbinary(0)	YES		NULL	
1 by brian
clean slate
1459
CREATE TABLE t6 
1460
SELECT * FROM (SELECT * FROM (SELECT NULL)a) b UNION SELECT a FROM t1;
1461
DESC t6;
1462
Field	Type	Null	Key	Default	Extra
642.1.49 by Lee
enable type_enum, union, variables-big and type_enum tests
1463
NULL	int	YES		NULL	
1 by brian
clean slate
1464
DROP TABLE t1, t2, t3, t4, t5, t6;
1465
End of 5.0 tests