~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/union.test

pandora-build v0.72 - Moved remaining hard-coded tests into pandora-build
macros.
Add PANDORA_DRIZZLE_BUILD to run the extra checks that drizzle needs that 
plugins would also need to run so we can just use that macro in generated
external plugin builds.
Added support to register_plugins for external plugin building.
Renamed register_plugins.py to pandora-plugin.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
(select a,b from t1 limit 2)  union all (select a,b from t2 order by a limit 1) order by b desc;
26
26
--error 1250
27
27
(select a,b from t1 limit 2)  union all (select a,b from t2 order by a limit 1) order by t1.b;
 
28
--replace_column 9 #
28
29
explain extended (select a,b from t1 limit 2)  union all (select a,b from t2 order by a limit 1) order by b desc;
29
30
(select sql_calc_found_rows  a,b from t1 limit 2)  union all (select a,b from t2 order by a) limit 2;
30
31
select found_rows();
35
36
# Test some error conditions with UNION
36
37
#
37
38
 
 
39
--replace_column 9 #
38
40
explain select a,b from t1 union all select a,b from t2;
39
41
 
40
42
--error  1054
98
100
CREATE TABLE t1 (
99
101
  `pseudo` char(35) NOT NULL default '',
100
102
  `pseudo1` char(35) NOT NULL default '',
101
 
  `same` tinyint(1) unsigned NOT NULL default '1',
 
103
  `same` int NOT NULL default '1',
102
104
  PRIMARY KEY  (`pseudo1`),
103
105
  KEY `pseudo` (`pseudo`)
104
 
) ENGINE=MyISAM;
 
106
);
105
107
INSERT INTO t1 (pseudo,pseudo1,same) VALUES ('joce', 'testtt', 1),('joce', 'tsestset', 1),('dekad', 'joce', 1);
106
108
SELECT pseudo FROM t1 WHERE pseudo1='joce' UNION SELECT pseudo FROM t1 WHERE pseudo='joce';
107
109
SELECT pseudo1 FROM t1 WHERE pseudo1='joce' UNION SELECT pseudo1 FROM t1 WHERE pseudo='joce';
128
130
#
129
131
 
130
132
CREATE TABLE t1 (
131
 
  cid smallint(5) unsigned NOT NULL default '0',
132
 
  cv varchar(250) NOT NULL default '',
 
133
  cid int NOT NULL default '0',
 
134
  cv varchar(190) NOT NULL default '',
133
135
  PRIMARY KEY  (cid),
134
136
  UNIQUE KEY cv (cv)
135
137
) ;
136
138
INSERT INTO t1 VALUES (8,'dummy');
137
139
CREATE TABLE t2 (
138
 
  cid bigint(20) unsigned NOT NULL auto_increment,
 
140
  cid int NOT NULL auto_increment,
139
141
  cap varchar(255) NOT NULL default '',
140
142
  PRIMARY KEY  (cid),
141
143
  KEY cap (cap)
142
144
) ;
143
145
CREATE TABLE t3 (
144
 
  gid bigint(20) unsigned NOT NULL auto_increment,
 
146
  gid int NOT NULL auto_increment,
145
147
  gn varchar(255) NOT NULL default '',
146
 
  must tinyint(4) default NULL,
 
148
  must int default NULL,
147
149
  PRIMARY KEY  (gid),
148
150
  KEY gn (gn)
149
151
) ;
150
152
INSERT INTO t3 VALUES (1,'V1',NULL);
151
153
CREATE TABLE t4 (
152
 
  uid bigint(20) unsigned NOT NULL default '0',
153
 
  gid bigint(20) unsigned default NULL,
154
 
  rid bigint(20) unsigned default NULL,
155
 
  cid bigint(20) unsigned default NULL,
 
154
  uid bigint NOT NULL default '0',
 
155
  gid bigint default NULL,
 
156
  rid bigint default NULL,
 
157
  cid bigint default NULL,
156
158
  UNIQUE KEY m (uid,gid,rid,cid),
157
159
  KEY uid (uid),
158
160
  KEY rid (rid),
161
163
) ;
162
164
INSERT INTO t4 VALUES (1,1,NULL,NULL);
163
165
CREATE TABLE t5 (
164
 
  rid bigint(20) unsigned NOT NULL auto_increment,
 
166
  rid bigint NOT NULL auto_increment,
165
167
  rl varchar(255) NOT NULL default '',
166
168
  PRIMARY KEY  (rid),
167
169
  KEY rl (rl)
168
170
) ;
169
171
CREATE TABLE t6 (
170
 
  uid bigint(20) unsigned NOT NULL auto_increment,
171
 
  un varchar(250) NOT NULL default '',
172
 
  uc smallint(5) unsigned NOT NULL default '0',
 
172
  uid bigint NOT NULL auto_increment,
 
173
  un varchar(190) NOT NULL default '',
 
174
  uc int NOT NULL default '0',
173
175
  PRIMARY KEY  (uid),
174
176
  UNIQUE KEY nc (un,uc),
175
177
  KEY un (un)
276
278
#
277
279
# Test for another bug with UNION and LEFT JOIN
278
280
#
279
 
CREATE TABLE t1 (  id int(3) unsigned default '0') ENGINE=MyISAM;
 
281
CREATE TEMPORARY TABLE t1 (  id int default '0') ENGINE=MyISAM;
280
282
INSERT INTO t1 (id) VALUES("1");
281
 
CREATE TABLE t2 ( id int(3) unsigned default '0',  id_master int(5) default '0',  text1 varchar(5) default NULL,  text2 varchar(5) default NULL) ENGINE=MyISAM;
 
283
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;
282
284
INSERT INTO t2 (id, id_master, text1, text2) VALUES("1", "1",
283
285
"foo1", "bar1");
284
286
INSERT INTO t2 (id, id_master, text1, text2) VALUES("2", "1",
309
311
drop table t1,t2;
310
312
create table t1 (   id int not null auto_increment, primary key (id)   ,user_name text );
311
313
create table t2 (    id int not null auto_increment, primary key (id)   ,group_name text );
312
 
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 users(id)   ,group_id int   ,index group_idx (group_id)   ,foreign key (group_id) references groups(id) );
 
314
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) );
313
315
insert into t1 (user_name) values ('Tester');
314
316
insert into t2 (group_name) values ('Group A');
315
317
insert into t2 (group_name) values ('Group B');
316
318
insert into t3 (user_id, group_id) values (1,1);
317
319
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;
318
 
drop table t1, t2, t3;
 
320
drop table t3, t1, t2;
319
321
 
320
322
#
321
323
# fix_fields problem
322
324
#
323
 
create table t1 (mat_id MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, matintnum CHAR(6) NOT NULL, test MEDIUMINT UNSIGNED NULL);
324
 
create table t2 (mat_id MEDIUMINT UNSIGNED NOT NULL, pla_id MEDIUMINT UNSIGNED NOT NULL);
 
325
create table t1 (mat_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, matintnum CHAR(6) NOT NULL, test INT NULL);
 
326
create table t2 (mat_id INT NOT NULL, pla_id INT NOT NULL);
325
327
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);
326
328
insert into t2 values (1, 100), (1, 101), (1, 102), (2, 100), (2, 103), (2, 104), (3, 101), (3, 102), (3, 105);
327
329
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;
332
334
#
333
335
create table t1 SELECT "a" as a UNION select "aa" as a;
334
336
select * from t1;
 
337
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
335
338
show create table t1;
336
339
drop table t1;
337
340
create table t1 SELECT 12 as a UNION select "aa" as a;
338
341
select * from t1;
 
342
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
339
343
show create table t1;
340
344
drop table t1;
341
345
create table t1 SELECT 12 as a UNION select 12.2 as a;
342
346
select * from t1;
 
347
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
343
348
show create table t1;
344
349
drop table t1;
345
350
 
346
 
create table t2 (it1 tinyint, it2 tinyint not null, i int not null, ib bigint, f float, d double, y year, da date, dt datetime, sc char(10), sv varchar(10), b blob, tx text);
347
 
insert into t2 values (NULL, 1, 3, 4, 1.5, 2.5, 1972, '1972-10-22', '1972-10-22 11:50', 'testc', 'testv', 'tetetetetest', 'teeeeeeeeeeeest');
 
351
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);
 
352
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');
348
353
 
349
354
create table t1 SELECT it2 from t2 UNION select it1 from t2;
350
355
select * from t1;
 
356
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
351
357
show create table t1;
352
358
drop table t1;
353
359
create table t1 SELECT it2 from t2 UNION select i from t2;
354
360
select * from t1;
 
361
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
355
362
show create table t1;
356
363
drop table t1;
357
364
create table t1 SELECT i from t2 UNION select f from t2;
358
365
select * from t1;
 
366
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
359
367
show create table t1;
360
368
drop table t1;
361
369
create table t1 SELECT f from t2 UNION select d from t2;
362
370
select * from t1;
 
371
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
363
372
show create table t1;
364
373
drop table t1;
365
374
create table t1 SELECT ib from t2 UNION select f from t2;
366
375
select * from t1;
 
376
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
367
377
show create table t1;
368
378
drop table t1;
369
379
create table t1 SELECT ib from t2 UNION select d from t2;
370
380
select * from t1;
371
 
show create table t1;
372
 
drop table t1;
373
 
create table t1 SELECT f from t2 UNION select y from t2;
374
 
select * from t1;
 
381
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
375
382
show create table t1;
376
383
drop table t1;
377
384
create table t1 SELECT f from t2 UNION select da from t2;
378
385
select * from t1;
379
 
show create table t1;
380
 
drop table t1;
381
 
create table t1 SELECT y from t2 UNION select da from t2;
382
 
select * from t1;
383
 
show create table t1;
384
 
drop table t1;
385
 
create table t1 SELECT y from t2 UNION select dt from t2;
386
 
select * from t1;
 
386
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
387
387
show create table t1;
388
388
drop table t1;
389
389
create table t1 SELECT da from t2 UNION select dt from t2;
390
390
select * from t1;
 
391
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
391
392
show create table t1;
392
393
drop table t1;
393
394
create table t1 SELECT dt from t2 UNION select trim(sc) from t2;
394
395
select trim(dt) from t1;
 
396
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
395
397
show create table t1;
396
398
drop table t1;
397
399
create table t1 SELECT dt from t2 UNION select sv from t2;
398
400
select * from t1;
 
401
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
399
402
show create table t1;
400
403
drop table t1;
401
404
create table t1 SELECT sc from t2 UNION select sv from t2;
402
405
select * from t1;
 
406
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
403
407
show create table t1;
404
408
drop table t1;
405
409
create table t1 SELECT dt from t2 UNION select b from t2;
406
410
select * from t1;
 
411
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
407
412
show create table t1;
408
413
drop table t1;
409
414
create table t1 SELECT sv from t2 UNION select b from t2;
410
415
select * from t1;
 
416
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
411
417
show create table t1;
412
418
drop table t1;
413
419
create table t1 SELECT i from t2 UNION select d from t2 UNION select b from t2;
414
420
select * from t1;
 
421
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
415
422
show create table t1;
416
423
drop table t1;
417
424
create table t1 SELECT sv from t2 UNION select tx from t2;
418
425
select * from t1;
 
426
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
419
427
show create table t1;
420
428
drop table t1;
421
429
create table t1 SELECT b from t2 UNION select tx from t2;
422
430
select * from t1;
 
431
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
423
432
show create table t1;
424
433
drop table t1,t2;
425
434
create table t1 select 1 union select -1;
426
435
select * from t1;
 
436
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
427
437
show create table t1;
428
438
drop table t1;
429
 
create table t1 select _latin1"test" union select _latin2"testt" ;
430
 
create table t1 select _latin2"test" union select _latin2"testt" ;
 
439
-- error 1054
 
440
create table t1 select _latin1"test" union select _latin1"testt" ;
 
441
-- error 1054
 
442
create table t1 select _utf8"test" union select _utf8"testt" ;
 
443
create table t1 select "test" union select "testt" ;
 
444
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
431
445
show create table t1;
432
446
drop table t1;
433
447
 
479
492
#
480
493
# Column 'name' cannot be null (error with union and left join) (bug #2508)
481
494
#
482
 
create table t1 (   RID int(11) not null default '0',   IID int(11) not null default '0',    nada varchar(50)  not null,NAME varchar(50) not null,PHONE varchar(50) not null) engine=MyISAM;
 
495
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);
483
496
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');
484
497
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);
485
498
drop  table t1;
488
501
# Bug #2809 (UNION fails on MyIsam tables when index on second column from
489
502
# same table)
490
503
#
491
 
create table t1 (col1 tinyint unsigned, col2 tinyint unsigned);
 
504
create table t1 (col1 int, col2 int);
492
505
insert into t1 values (1,2),(3,4),(5,6),(7,8),(9,10);
493
506
select col1 n from t1 union select col2 n from t1 order by n;
494
507
alter table t1 add index myindex (col2);
527
540
#
528
541
# nonexisting column in global ORDER BY
529
542
#
530
 
CREATE TABLE t1 (i int(11) default NULL,c char(1) default NULL,KEY i (i));
531
 
CREATE TABLE t2 (i int(11) default NULL,c char(1) default NULL,KEY i (i));
 
543
CREATE TABLE t1 (i int default NULL,c char(1) default NULL,KEY i (i));
 
544
CREATE TABLE t2 (i int default NULL,c char(1) default NULL,KEY i (i));
532
545
--error 1054
533
546
explain (select * from t1) union (select * from t2) order by not_existing_column;
534
547
drop table t1, t2;
536
549
#
537
550
# length detecting
538
551
#
539
 
CREATE TABLE t1 (uid int(1));
 
552
CREATE TABLE t1 (uid int);
540
553
INSERT INTO t1 SELECT 150;
541
554
SELECT 'a' UNION SELECT uid FROM t1;
542
555
drop table t1;
544
557
#
545
558
# parser stack overflow
546
559
#
547
 
CREATE TABLE t1 ( ID1 int(10) unsigned NOT NULL DEFAULT '0' , ID2 datetime NOT NULL DEFAULT '0000-00-00 00:00:00' , DATA1 varchar(10) , DATA2 double(5,4) , DATA3 datetime , PRIMARY KEY (ID1,ID2));
 
560
CREATE TABLE t1 ( ID1 int NOT NULL DEFAULT '0' , ID2 datetime, DATA1 varchar(10) , DATA2 double(5,4) , DATA3 datetime , PRIMARY KEY (ID1,ID2));
548
561
 
549
 
CREATE TABLE t2 ( ID int(3) unsigned NOT NULL DEFAULT '0' , DATA1 timestamp DEFAULT '0000-00-00 00:00:00' , PRIMARY KEY (ID));
 
562
CREATE TABLE t2 ( ID int NOT NULL DEFAULT '0' , DATA1 timestamp NULL, PRIMARY KEY (ID));
550
563
(SELECT * FROM t1 AS PARTITIONED, t2 AS
551
564
PARTITIONED_B WHERE PARTITIONED_B.ID=PARTITIONED.ID1) UNION
552
565
(SELECT * FROM t1 AS PARTITIONED, t2 AS
580
593
create table t2 (a ENUM('aaa', 'bbb') NOT NULL);
581
594
insert into t1 values ('No');
582
595
insert into t2 values ('bbb');
583
 
create table t3 (a SET('Yes', 'No') NOT NULL);
584
 
create table t4 (a SET('aaa', 'bbb') NOT NULL);
 
596
create table t3 (a ENUM('Yes', 'No') NOT NULL);
 
597
create table t4 (a ENUM('aaa', 'bbb') NOT NULL);
585
598
insert into t3 values (1);
 
599
--error 1691 # Bad enum
586
600
insert into t4 values (3);
587
601
select "1" as a union select a from t1;
588
602
select a as a from t1 union select "1";
597
611
# Bug #6139 UNION doesn't understand collate in the column of second select
598
612
#
599
613
create table t1 as
600
 
(select _latin1'test') union
601
 
(select _latin1'TEST') union
602
 
(select _latin1'TeST');
603
 
show create table t1;
604
 
select count(*) from t1;
605
 
drop table t1;
606
 
 
607
 
create table t1 as
608
 
(select _latin1'test' collate latin1_bin) union
609
 
(select _latin1'TEST') union
610
 
(select _latin1'TeST');
611
 
show create table t1;
612
 
select count(*) from t1;
613
 
drop table t1;
614
 
 
615
 
create table t1 as
616
 
(select _latin1'test') union
617
 
(select _latin1'TEST' collate latin1_bin) union
618
 
(select _latin1'TeST');
619
 
show create table t1;
620
 
select count(*) from t1;
621
 
drop table t1;
622
 
 
623
 
create table t1 as
624
 
(select _latin1'test') union
625
 
(select _latin1'TEST') union
626
 
(select _latin1'TeST' collate latin1_bin);
627
 
show create table t1;
628
 
select count(*) from t1;
629
 
drop table t1;
630
 
 
631
 
create table t2 (
632
 
a char character set latin1 collate latin1_swedish_ci,
633
 
b char character set latin1 collate latin1_german1_ci);
 
614
(select 'test') union
 
615
(select 'TEST') union
 
616
(select 'TeST');
 
617
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
 
618
show create table t1;
 
619
select count(*) from t1;
 
620
drop table t1;
 
621
 
 
622
create table t1 as
 
623
(select 'test' collate utf8_bin) union
 
624
(select 'TEST') union
 
625
(select 'TeST');
 
626
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
 
627
show create table t1;
 
628
select count(*) from t1;
 
629
drop table t1;
 
630
 
 
631
create table t1 as
 
632
(select 'test') union
 
633
(select 'TEST' collate utf8_bin) union
 
634
(select 'TeST');
 
635
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
 
636
show create table t1;
 
637
select count(*) from t1;
 
638
drop table t1;
 
639
 
 
640
create table t1 as
 
641
(select 'test') union
 
642
(select 'TEST') union
 
643
(select 'TeST' collate utf8_bin);
 
644
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
 
645
show create table t1;
 
646
select count(*) from t1;
 
647
drop table t1;
 
648
 
 
649
# Drizzle doesn't support specifying character set, it is all UTF8
 
650
--error 1064
 
651
create table t2 (
 
652
a char character set utf8 collate utf8_swedish_ci,
 
653
b char character set utf8 collate utf8_spanish_ci);
 
654
 
 
655
create table t2 (
 
656
a char collate utf8_swedish_ci,
 
657
b char collate utf8_spanish_ci);
634
658
--error 1271
635
659
create table t1 as
636
660
(select a from t2) union
637
661
(select b from t2);
 
662
 
 
663
--error 1166
638
664
create table t1 as
639
 
(select a collate latin1_german1_ci from t2) union
 
665
(select a collate utf8_swedish_ci from t2) union
640
666
(select b from t2);
641
 
show create table t1;
642
 
drop table t1;
 
667
#show create table t1;
 
668
#drop table t1;
 
669
 
643
670
create table t1 as
644
671
(select a from t2) union
645
 
(select b collate latin1_german1_ci from t2);
 
672
(select b collate utf8_swedish_ci from t2);
 
673
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
646
674
show create table t1;
647
675
drop table t1;
648
676
create table t1 as
649
677
(select a from t2) union
650
678
(select b from t2) union
651
 
(select 'c' collate latin1_german1_ci from t2);
 
679
(select 'c' collate utf8_spanish_ci from t2);
 
680
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
652
681
show create table t1;
653
682
drop table t1;
654
683
drop table t2;
710
739
#
711
740
# Bug#15949 union + illegal mix of collations (IMPLICIT + COERCIBLE)
712
741
#
713
 
select concat(_latin1'a', _ascii'b' collate ascii_bin);
714
 
create table t1 (foo varchar(100)) collate ascii_bin;
 
742
select concat('a', 'b' collate utf8_bin);
 
743
create table t1 (foo varchar(100)) collate utf8_bin;
715
744
insert into t1 (foo) values ("foo");
 
745
--error 1146
716
746
select foo from t1 union select 'bar' as foo from dual;
 
747
select foo from t1 union select 'bar' as foo;
717
748
drop table t1;
718
749
 
 
750
 
 
751
# Commenting out this test until Bug 308841 is fixed
719
752
#
720
753
# Enum merging test
721
754
#
722
 
CREATE TABLE t1 (
723
 
  a ENUM('�','�','�') character set utf8 not null default '�',
724
 
  b ENUM("one", "two") character set utf8,
725
 
  c ENUM("one", "two")
726
 
);
727
 
show create table t1;
728
 
insert into t1 values ('�', 'one', 'one'), ('�', 'two', 'one'), ('�', NULL, NULL);
729
 
create table t2 select NULL union select a from t1;
730
 
show columns from t2;
731
 
drop table t2;
732
 
create table t2 select a from t1 union select NULL;
733
 
show columns from t2;
734
 
drop table t2;
735
 
create table t2 select a from t1 union select a from t1;
736
 
show columns from t2;
737
 
drop table t2;
738
 
create table t2 select a from t1 union select c from t1;
739
 
drop table t2;
740
 
create table t2 select a from t1 union select b from t1;
741
 
show columns from t2;
742
 
drop table t2, t1;
 
755
#CREATE TABLE t1 (
 
756
#  a ENUM('�','�','�') character set utf8 not null default '�',
 
757
#  b ENUM("one", "two") character set utf8,
 
758
#  c ENUM("one", "two")
 
759
#);
 
760
#--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
 
761
#show create table t1;
 
762
#insert into t1 values ('�', 'one', 'one'), ('�', 'two', 'one'), ('�', NULL, NULL);
 
763
#create table t2 select NULL union select a from t1;
 
764
#show columns from t2;
 
765
#drop table t2;
 
766
#create table t2 select a from t1 union select NULL;
 
767
#show columns from t2;
 
768
#drop table t2;
 
769
#create table t2 select a from t1 union select a from t1;
 
770
#show columns from t2;
 
771
#drop table t2;
 
772
#create table t2 select a from t1 union select c from t1;
 
773
#drop table t2;
 
774
#create table t2 select a from t1 union select b from t1;
 
775
#show columns from t2;
 
776
#drop table t2, t1;`
743
777
 
744
778
745
779
# Bug #14216: UNION + DECIMAL wrong values in result
765
799
 
766
800
create table t1 (a varchar(5));
767
801
create table t2 select * from t1 union select 'abcdefghijkl';
 
802
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
768
803
show create table t2;
769
804
select row_format from information_schema.TABLES where table_schema="test" and table_name="t2";
770
805
alter table t2 ROW_FORMAT=fixed;
 
806
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
771
807
show create table t2;
772
808
drop table t1,t2;
773
809
 
780
816
INSERT INTO t1 VALUES ('a'),('b');
781
817
SELECT left(a,100000000) FROM t1 UNION  SELECT b FROM t2;
782
818
create table t3 SELECT left(a,100000000) FROM t1 UNION  SELECT b FROM t2;
 
819
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
783
820
show create table t3;
784
821
drop tables t1,t2,t3;
785
822
 
794
831
INSERT INTO t1 VALUES ('a'),('b');
795
832
SELECT left(a,100000000) FROM t1 UNION  SELECT b FROM t2;
796
833
create table t3 SELECT left(a,100000000) FROM t1 UNION  SELECT b FROM t2;
 
834
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
797
835
show create table t3;
798
836
drop tables t1,t2,t3;
799
837
 
808
846
CREATE TABLE t2 (b varchar(20));
809
847
INSERT INTO t1 VALUES ('a');
810
848
CREATE TABLE t3 SELECT REPEAT(a,20000000) AS a FROM t1 UNION SELECT b FROM t2;
 
849
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
811
850
SHOW CREATE TABLE t3;
812
851
DROP TABLES t1,t3;
813
852
CREATE TABLE t1 (a tinytext);
814
853
INSERT INTO t1 VALUES ('a');
815
854
CREATE TABLE t3 SELECT REPEAT(a,2) AS a FROM t1 UNION SELECT b FROM t2;
 
855
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
816
856
SHOW CREATE TABLE t3;
817
857
DROP TABLES t1,t3;
818
858
CREATE TABLE t1 (a mediumtext);
819
859
INSERT INTO t1 VALUES ('a');
820
860
CREATE TABLE t3 SELECT REPEAT(a,2) AS a FROM t1 UNION SELECT b FROM t2;
 
861
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
821
862
SHOW CREATE TABLE t3;
822
863
DROP TABLES t1,t3;
823
864
CREATE TABLE t1 (a tinyblob);
824
865
INSERT INTO t1 VALUES ('a');
825
866
CREATE TABLE t3 SELECT REPEAT(a,2) AS a FROM t1 UNION SELECT b FROM t2;
 
867
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
826
868
SHOW CREATE TABLE t3;
827
869
DROP TABLES t1,t2,t3;
828
870
SET max_allowed_packet:= @tmp_max;
842
884
#
843
885
# Bug#12185: Data type aggregation may produce wrong result
844
886
#
845
 
create table t1(f1 char(1), f2 char(5), f3 binary(1), f4 binary(5), f5 timestamp, f6 varchar(1) character set utf8 collate utf8_general_ci, f7 text);
 
887
create table t1(f1 char(1), f2 char(5), f3 blob, f4 blob, f5 timestamp, f6 varchar(1) collate utf8_general_ci, f7 text);
846
888
create table t2 as select *, f6 as f8 from t1 union select *, f7 from t1;
 
889
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
847
890
show create table t2;
848
891
drop table t1, t2;
849
892
 
898
941
# Bug #16881: password() and union select
899
942
# (The issue was poor handling of character set aggregation.)
900
943
#
901
 
select _utf8'12' union select _latin1'12345';
 
944
select '12' union select '12345';
902
945
 
903
946
#
904
947
# Bug #26661: UNION with ORDER BY undefined column in FROM list