~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/union.test

  • Committer: Monty Taylor
  • Date: 2009-04-14 19:16:51 UTC
  • mto: (997.2.5 mordred)
  • mto: This revision was merged to the branch mainline in revision 994.
  • Revision ID: mordred@inaugust.com-20090414191651-ltbww6hpqks8k7qk
Clarified instructions in README.

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 #
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
40
--error  1054
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';
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",
474
472
insert t1 select a+1, a+b from t1;
475
473
insert t1 select a+1, a+b from t1;
476
474
FLUSH STATUS;
477
 
--replace_column 2 #
478
475
show status like 'Slow_queries';
479
476
select count(*) from t1 where a=7;
480
 
--replace_column 2 #
481
477
show status like 'Slow_queries';
482
478
select count(*) from t1 where b=13;
483
 
--replace_column 2 #
484
479
show status like 'Slow_queries';
485
480
select count(*) from t1 where b=13 union select count(*) from t1 where a=7;
486
 
--replace_column 2 #
487
481
show status like 'Slow_queries';
488
482
select count(*) from t1 where a=7 union select count(*) from t1 where b=13;
489
 
--replace_column 2 #
490
483
show status like 'Slow_queries';
491
484
# additional test for examined rows
492
485
flush status;
493
486
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
487
show status like 'Slow_queries';
496
488
drop table t1;
497
489
 
498
490
#
499
491
# Column 'name' cannot be null (error with union and left join) (bug #2508)
500
492
#
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);
 
493
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
494
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
495
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
496
drop  table t1;
807
799
create table t2 select * from t1 union select 'abcdefghijkl';
808
800
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
809
801
show create table t2;
810
 
select row_format from data_dictionary.TABLES where table_schema="test" and table_name="t2";
 
802
select row_format from information_schema.TABLES where table_schema="test" and table_name="t2";
 
803
alter table t2 ROW_FORMAT=fixed;
811
804
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
812
805
show create table t2;
813
806
drop table t1,t2;