~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/union.test

  • Committer: Jay Pipes
  • Date: 2009-03-16 15:20:27 UTC
  • mto: (934.3.7 mordred)
  • mto: This revision was merged to the branch mainline in revision 938.
  • Revision ID: jpipes@serialcoder-20090316152027-njlreaim8vxqta6c
Fixes ENUM field type to throw an error on bad data input.  0 is now not
allowed on insertion.  MySQL allows 0, in the manual it states 0 is "the
null string error index" whatever that means.  Drizzle doesn't allow it.

Corrected test cases.

Also cleans up indentation on JOIN::exec() which was bothering me.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
(select a,b from t1 limit 2)  union all (select a,b from t2 order by a) limit 4;
24
24
(select a,b from t1 limit 2)  union all (select a,b from t2 order by a limit 1);
25
25
(select a,b from t1 limit 2)  union all (select a,b from t2 order by a limit 1) order by b desc;
26
 
--error ER_TABLENAME_NOT_ALLOWED_HERE
 
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 #
29
28
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;
30
29
(select sql_calc_found_rows  a,b from t1 limit 2)  union all (select a,b from t2 order by a) limit 2;
31
30
select found_rows();
36
35
# Test some error conditions with UNION
37
36
#
38
37
 
39
 
--replace_column 9 #
40
38
explain select a,b from t1 union all select a,b from t2;
41
39
 
42
 
--error ER_BAD_FIELD_ERROR
 
40
--error  1054
43
41
explain select xx from t1 union select 1;
44
 
--error ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT
 
42
--error 1222
45
43
explain select a,b from t1 union select 1;
46
 
--error ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT
 
44
--error 1222
47
45
explain select 1 union select a,b from t1 union select 1;
48
 
--error ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT
 
46
--error 1222
49
47
explain select a,b from t1 union select 1 limit 0;
50
48
 
51
 
--error ER_WRONG_USAGE
 
49
--error 1221
52
50
select a,b from t1 into outfile 'skr' union select a,b from t2;
53
51
 
54
 
--error ER_WRONG_USAGE
 
52
--error 1221
55
53
select a,b from t1 order by a union select a,b from t2;
56
54
 
57
 
--error ER_WRONG_USAGE
 
55
--error 1221
58
56
insert into t3 select a from t1 order by a union select a from t2;
59
57
 
60
 
--error ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT
 
58
--error 1222
61
59
create table t3 select a,b from t1 union select a from t2;
62
60
 
63
 
--error ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT
 
61
--error 1222
64
62
select a,b from t1 union select a from t2;
65
63
 
66
 
--error ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT
 
64
--error 1222
67
65
select * from t1 union select a from t2;
68
66
 
69
 
--error ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT
 
67
--error 1222
70
68
select a from t1 union select * from t2;
71
69
 
72
 
--error ER_CANT_USE_OPTION_HERE
 
70
--error 1234
73
71
select * from t1 union select SQL_BUFFER_RESULT * from t2;
74
72
 
75
73
# Test CREATE, INSERT and REPLACE
83
81
#
84
82
# Test some unions without tables
85
83
#
86
 
--error ER_NO_TABLES_USED
 
84
--error 1096
87
85
select * union select 1;
88
86
select 1 as a,(select a union select a);
89
 
--error ER_BAD_FIELD_ERROR
 
87
--error 1054
90
88
(select 1) union (select 2) order by 0;
91
89
SELECT @a:=1 UNION SELECT @a:=@a+1;
92
 
--error ER_BAD_FIELD_ERROR
 
90
--error 1054
93
91
(SELECT 1) UNION (SELECT 2) ORDER BY (SELECT a);
94
92
(SELECT 1,3) UNION (SELECT 2,1) ORDER BY (SELECT 2);
95
93
 
103
101
  `same` int NOT NULL default '1',
104
102
  PRIMARY KEY  (`pseudo1`),
105
103
  KEY `pseudo` (`pseudo`)
106
 
);
 
104
) ENGINE=MyISAM;
107
105
INSERT INTO t1 (pseudo,pseudo1,same) VALUES ('joce', 'testtt', 1),('joce', 'tsestset', 1),('dekad', 'joce', 1);
108
106
SELECT pseudo FROM t1 WHERE pseudo1='joce' UNION SELECT pseudo FROM t1 WHERE pseudo='joce';
109
107
SELECT pseudo1 FROM t1 WHERE pseudo1='joce' UNION SELECT pseudo1 FROM t1 WHERE pseudo='joce';
219
217
(SELECT SQL_CALC_FOUND_ROWS * FROM t1) UNION all (SELECT * FROM t2 LIMIT 1);
220
218
select found_rows();
221
219
# This used to work in 4.0 but not anymore in 4.1
222
 
--error ER_PARSE_ERROR
 
220
--error 1064
223
221
(SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 1) UNION SELECT * FROM t2 LIMIT 1;
224
222
#select found_rows();
225
223
 
250
248
(SELECT * FROM t1 ORDER by a) UNION ALL (SELECT * FROM t2 ORDER BY a) ORDER BY A desc LIMIT 4;
251
249
 
252
250
# Wrong usage
253
 
--error ER_CANT_USE_OPTION_HERE
 
251
--error 1234
254
252
(SELECT * FROM t1) UNION all (SELECT SQL_CALC_FOUND_ROWS * FROM t2) LIMIT 1;
255
253
 
256
254
create temporary table t1 select a from t1 union select a from t2;
257
255
drop temporary table t1;
258
 
--error ER_UPDATE_TABLE_USED
 
256
--error 1093
259
257
create table t1 select a from t1 union select a from t2;
260
 
--error ER_BAD_FIELD_ERROR
 
258
--error 1054
261
259
select a from t1 union select a from t2 order by t2.a;
262
260
drop table t1,t2;
263
261
 
278
276
#
279
277
# Test for another bug with UNION and LEFT JOIN
280
278
#
281
 
CREATE TEMPORARY TABLE t1 (  id int default '0') ENGINE=MyISAM;
 
279
CREATE TABLE t1 (  id int default '0') ENGINE=MyISAM;
282
280
INSERT INTO t1 (id) VALUES("1");
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;
 
281
CREATE TABLE t2 ( id int default '0',  id_master int default '0',  text1 varchar(5) default NULL,  text2 varchar(5) default NULL) ENGINE=MyISAM;
284
282
INSERT INTO t2 (id, id_master, text1, text2) VALUES("1", "1",
285
283
"foo1", "bar1");
286
284
INSERT INTO t2 (id, id_master, text1, text2) VALUES("2", "1",
316
314
insert into t2 (group_name) values ('Group A');
317
315
insert into t2 (group_name) values ('Group B');
318
316
insert into t3 (user_id, group_id) values (1,1);
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 CROSS JOIN t2 c;
 
317
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;
320
318
drop table t3, t1, t2;
321
319
 
322
320
#
334
332
#
335
333
create table t1 SELECT "a" as a UNION select "aa" as a;
336
334
select * from t1;
337
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
338
335
show create table t1;
339
336
drop table t1;
340
337
create table t1 SELECT 12 as a UNION select "aa" as a;
341
338
select * from t1;
342
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
343
339
show create table t1;
344
340
drop table t1;
345
341
create table t1 SELECT 12 as a UNION select 12.2 as a;
346
342
select * from t1;
347
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
348
343
show create table t1;
349
344
drop table t1;
350
345
 
353
348
 
354
349
create table t1 SELECT it2 from t2 UNION select it1 from t2;
355
350
select * from t1;
356
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
357
351
show create table t1;
358
352
drop table t1;
359
353
create table t1 SELECT it2 from t2 UNION select i from t2;
360
354
select * from t1;
361
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
362
355
show create table t1;
363
356
drop table t1;
364
357
create table t1 SELECT i from t2 UNION select f from t2;
365
358
select * from t1;
366
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
367
359
show create table t1;
368
360
drop table t1;
369
361
create table t1 SELECT f from t2 UNION select d from t2;
370
362
select * from t1;
371
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
372
363
show create table t1;
373
364
drop table t1;
374
365
create table t1 SELECT ib from t2 UNION select f from t2;
375
366
select * from t1;
376
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
377
367
show create table t1;
378
368
drop table t1;
379
369
create table t1 SELECT ib from t2 UNION select d from t2;
380
370
select * from t1;
381
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
382
371
show create table t1;
383
372
drop table t1;
384
373
create table t1 SELECT f from t2 UNION select da from t2;
385
374
select * from t1;
386
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
387
375
show create table t1;
388
376
drop table t1;
389
377
create table t1 SELECT da from t2 UNION select dt from t2;
390
378
select * from t1;
391
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
392
379
show create table t1;
393
380
drop table t1;
394
381
create table t1 SELECT dt from t2 UNION select trim(sc) from t2;
395
382
select trim(dt) from t1;
396
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
397
383
show create table t1;
398
384
drop table t1;
399
385
create table t1 SELECT dt from t2 UNION select sv from t2;
400
386
select * from t1;
401
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
402
387
show create table t1;
403
388
drop table t1;
404
389
create table t1 SELECT sc from t2 UNION select sv from t2;
405
390
select * from t1;
406
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
407
391
show create table t1;
408
392
drop table t1;
409
393
create table t1 SELECT dt from t2 UNION select b from t2;
410
394
select * from t1;
411
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
412
395
show create table t1;
413
396
drop table t1;
414
397
create table t1 SELECT sv from t2 UNION select b from t2;
415
398
select * from t1;
416
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
417
399
show create table t1;
418
400
drop table t1;
419
401
create table t1 SELECT i from t2 UNION select d from t2 UNION select b from t2;
420
402
select * from t1;
421
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
422
403
show create table t1;
423
404
drop table t1;
424
405
create table t1 SELECT sv from t2 UNION select tx from t2;
425
406
select * from t1;
426
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
427
407
show create table t1;
428
408
drop table t1;
429
409
create table t1 SELECT b from t2 UNION select tx from t2;
430
410
select * from t1;
431
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
432
411
show create table t1;
433
412
drop table t1,t2;
434
413
create table t1 select 1 union select -1;
435
414
select * from t1;
436
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
437
415
show create table t1;
438
416
drop table t1;
439
 
--error ER_BAD_FIELD_ERROR
 
417
-- error 1054
440
418
create table t1 select _latin1"test" union select _latin1"testt" ;
441
 
--error ER_BAD_FIELD_ERROR
 
419
-- error 1054
442
420
create table t1 select _utf8"test" union select _utf8"testt" ;
443
421
create table t1 select "test" union select "testt" ;
444
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
445
422
show create table t1;
446
423
drop table t1;
447
424
 
457
434
insert into t1 select * from t2;
458
435
insert into t2 select * from t1;
459
436
set local tmp_table_size=1024;
460
 
select SQL_BIG_RESULT count(*) from (select SQL_BIG_RESULT * from t1 union all select * from t2 order by 1) b;
 
437
select count(*) from (select * from t1 union all select * from t2 order by 1) b;
461
438
select count(*) from t1;
462
439
select count(*) from t2;
463
440
drop table t1,t2;
474
451
insert t1 select a+1, a+b from t1;
475
452
insert t1 select a+1, a+b from t1;
476
453
FLUSH STATUS;
477
 
--replace_column 2 #
478
454
show status like 'Slow_queries';
479
455
select count(*) from t1 where a=7;
480
 
--replace_column 2 #
481
456
show status like 'Slow_queries';
482
457
select count(*) from t1 where b=13;
483
 
--replace_column 2 #
484
458
show status like 'Slow_queries';
485
459
select count(*) from t1 where b=13 union select count(*) from t1 where a=7;
486
 
--replace_column 2 #
487
460
show status like 'Slow_queries';
488
461
select count(*) from t1 where a=7 union select count(*) from t1 where b=13;
489
 
--replace_column 2 #
490
462
show status like 'Slow_queries';
491
463
# additional test for examined rows
492
464
flush status;
493
465
select a from t1 where b not in (1,2,3) union select a from t1 where b not in (4,5,6); 
494
 
--replace_column 2 #
495
466
show status like 'Slow_queries';
496
467
drop table t1;
497
468
 
498
469
#
499
470
# Column 'name' cannot be null (error with union and left join) (bug #2508)
500
471
#
501
 
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);
 
472
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;
502
473
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');
503
474
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);
504
475
drop  table t1;
548
519
#
549
520
CREATE TABLE t1 (i int default NULL,c char(1) default NULL,KEY i (i));
550
521
CREATE TABLE t2 (i int default NULL,c char(1) default NULL,KEY i (i));
551
 
--error ER_BAD_FIELD_ERROR
 
522
--error 1054
552
523
explain (select * from t1) union (select * from t2) order by not_existing_column;
553
524
drop table t1, t2;
554
525
 
602
573
create table t3 (a ENUM('Yes', 'No') NOT NULL);
603
574
create table t4 (a ENUM('aaa', 'bbb') NOT NULL);
604
575
insert into t3 values (1);
605
 
--error ER_INVALID_ENUM_VALUE # Bad enum
 
576
--error 1691 # Bad enum
606
577
insert into t4 values (3);
607
578
select "1" as a union select a from t1;
608
579
select a as a from t1 union select "1";
620
591
(select 'test') union
621
592
(select 'TEST') union
622
593
(select 'TeST');
623
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
624
594
show create table t1;
625
595
select count(*) from t1;
626
596
drop table t1;
629
599
(select 'test' collate utf8_bin) union
630
600
(select 'TEST') union
631
601
(select 'TeST');
632
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
633
602
show create table t1;
634
603
select count(*) from t1;
635
604
drop table t1;
638
607
(select 'test') union
639
608
(select 'TEST' collate utf8_bin) union
640
609
(select 'TeST');
641
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
642
610
show create table t1;
643
611
select count(*) from t1;
644
612
drop table t1;
647
615
(select 'test') union
648
616
(select 'TEST') union
649
617
(select 'TeST' collate utf8_bin);
650
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
651
618
show create table t1;
652
619
select count(*) from t1;
653
620
drop table t1;
654
621
 
655
622
# Drizzle doesn't support specifying character set, it is all UTF8
656
 
--error ER_PARSE_ERROR
 
623
--error 1064
657
624
create table t2 (
658
625
a char character set utf8 collate utf8_swedish_ci,
659
626
b char character set utf8 collate utf8_spanish_ci);
661
628
create table t2 (
662
629
a char collate utf8_swedish_ci,
663
630
b char collate utf8_spanish_ci);
664
 
--error ER_CANT_AGGREGATE_NCOLLATIONS
 
631
--error 1271
665
632
create table t1 as
666
633
(select a from t2) union
667
634
(select b from t2);
668
635
 
669
 
--error ER_WRONG_COLUMN_NAME
 
636
--error 1166
670
637
create table t1 as
671
638
(select a collate utf8_swedish_ci from t2) union
672
639
(select b from t2);
676
643
create table t1 as
677
644
(select a from t2) union
678
645
(select b collate utf8_swedish_ci from t2);
679
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
680
646
show create table t1;
681
647
drop table t1;
682
648
create table t1 as
683
649
(select a from t2) union
684
650
(select b from t2) union
685
651
(select 'c' collate utf8_spanish_ci from t2);
686
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
687
652
show create table t1;
688
653
drop table t1;
689
654
drop table t2;
746
711
# Bug#15949 union + illegal mix of collations (IMPLICIT + COERCIBLE)
747
712
#
748
713
select concat('a', 'b' collate utf8_bin);
749
 
create table t1 (foo varchar(100)) collate=utf8_bin;
 
714
create table t1 (foo varchar(100)) collate utf8_bin;
750
715
insert into t1 (foo) values ("foo");
751
 
--error ER_TABLE_UNKNOWN
 
716
--error 1146
752
717
select foo from t1 union select 'bar' as foo from dual;
753
718
select foo from t1 union select 'bar' as foo;
754
719
drop table t1;
763
728
#  b ENUM("one", "two") character set utf8,
764
729
#  c ENUM("one", "two")
765
730
#);
766
 
#--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
767
731
#show create table t1;
768
732
#insert into t1 values ('�', 'one', 'one'), ('�', 'two', 'one'), ('�', NULL, NULL);
769
733
#create table t2 select NULL union select a from t1;
779
743
#drop table t2;
780
744
#create table t2 select a from t1 union select b from t1;
781
745
#show columns from t2;
782
 
#drop table t2, t1;`
 
746
#drop table t2, t1;
783
747
 
784
748
785
749
# Bug #14216: UNION + DECIMAL wrong values in result
805
769
 
806
770
create table t1 (a varchar(5));
807
771
create table t2 select * from t1 union select 'abcdefghijkl';
808
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
809
772
show create table t2;
810
 
select row_format from data_dictionary.TABLES where table_schema="test" and table_name="t2";
811
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
 
773
select row_format from information_schema.TABLES where table_schema="test" and table_name="t2";
 
774
alter table t2 ROW_FORMAT=fixed;
812
775
show create table t2;
813
776
drop table t1,t2;
814
777
 
821
784
INSERT INTO t1 VALUES ('a'),('b');
822
785
SELECT left(a,100000000) FROM t1 UNION  SELECT b FROM t2;
823
786
create table t3 SELECT left(a,100000000) FROM t1 UNION  SELECT b FROM t2;
824
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
825
787
show create table t3;
826
788
drop tables t1,t2,t3;
827
789
 
836
798
INSERT INTO t1 VALUES ('a'),('b');
837
799
SELECT left(a,100000000) FROM t1 UNION  SELECT b FROM t2;
838
800
create table t3 SELECT left(a,100000000) FROM t1 UNION  SELECT b FROM t2;
839
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
840
801
show create table t3;
841
802
drop tables t1,t2,t3;
842
803
 
851
812
CREATE TABLE t2 (b varchar(20));
852
813
INSERT INTO t1 VALUES ('a');
853
814
CREATE TABLE t3 SELECT REPEAT(a,20000000) AS a FROM t1 UNION SELECT b FROM t2;
854
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
855
815
SHOW CREATE TABLE t3;
856
816
DROP TABLES t1,t3;
857
817
CREATE TABLE t1 (a tinytext);
858
818
INSERT INTO t1 VALUES ('a');
859
819
CREATE TABLE t3 SELECT REPEAT(a,2) AS a FROM t1 UNION SELECT b FROM t2;
860
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
861
820
SHOW CREATE TABLE t3;
862
821
DROP TABLES t1,t3;
863
822
CREATE TABLE t1 (a mediumtext);
864
823
INSERT INTO t1 VALUES ('a');
865
824
CREATE TABLE t3 SELECT REPEAT(a,2) AS a FROM t1 UNION SELECT b FROM t2;
866
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
867
825
SHOW CREATE TABLE t3;
868
826
DROP TABLES t1,t3;
869
827
CREATE TABLE t1 (a tinyblob);
870
828
INSERT INTO t1 VALUES ('a');
871
829
CREATE TABLE t3 SELECT REPEAT(a,2) AS a FROM t1 UNION SELECT b FROM t2;
872
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
873
830
SHOW CREATE TABLE t3;
874
831
DROP TABLES t1,t2,t3;
875
832
SET max_allowed_packet:= @tmp_max;
891
848
#
892
849
create table t1(f1 char(1), f2 char(5), f3 blob, f4 blob, f5 timestamp, f6 varchar(1) collate utf8_general_ci, f7 text);
893
850
create table t2 as select *, f6 as f8 from t1 union select *, f7 from t1;
894
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
895
851
show create table t2;
896
852
drop table t1, t2;
897
853
 
956
912
INSERT INTO t1 VALUES (3),(1),(2),(4),(1);
957
913
 
958
914
SELECT a FROM (SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY a) AS test;
959
 
--error ER_BAD_FIELD_ERROR 
 
915
--error 1054 
960
916
SELECT a FROM (SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY c) AS test;
961
917
 
962
918
DROP TABLE t1;
964
920
#
965
921
# Bug#23345: Wrongly allowed INTO in a non-last select of a UNION.
966
922
#
967
 
--error ER_WRONG_USAGE
 
923
--error 1221
968
924
(select 1 into @var) union (select 1);
969
925
(select 1) union (select 1 into @var);
970
926
select @var;
971
 
--error ER_TOO_MANY_ROWS
 
927
--error 1172
972
928
(select 2) union (select 1 into @var);
973
929
 
974
930
#