~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/r/join_outer.result

  • Committer: Brian Aker
  • Date: 2009-12-29 01:38:38 UTC
  • mfrom: (1251.1.1 drizzle)
  • Revision ID: brian@gaz-20091229013838-03kb2z5xbqw03ddt
Merge of Diego fix.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
drop table if exists t0,t1,t2,t3,t4,t5;
2
2
CREATE TABLE t1 (
3
3
grp int default NULL,
4
 
a bigint unsigned default NULL,
 
4
a bigint default NULL,
5
5
c char(10) NOT NULL default ''
6
 
) ENGINE=MyISAM;
 
6
);
7
7
INSERT INTO t1 VALUES (1,1,'a'),(2,2,'b'),(2,3,'c'),(3,4,'E'),(3,5,'C'),(3,6,'D'),(NULL,NULL,'');
8
 
create table t2 (id int, a bigint unsigned not null, c char(10), d int, primary key (a));
 
8
create table t2 (id int, a bigint not null, c char(10), d int, primary key (a));
9
9
insert into t2 values (1,1,"a",1),(3,4,"A",4),(3,5,"B",5),(3,6,"C",6),(4,7,"D",7);
10
10
select t1.*,t2.* from t1 JOIN t2 where t1.a=t2.a;
11
11
grp     a       c       id      a       c       d
91
91
NULL    NULL            NULL    NULL    NULL    NULL
92
92
explain select t1.*,t2.* from t1,t2 where t1.a=t2.a and isnull(t2.a)=1;
93
93
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
94
 
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    Impossible WHERE
 
94
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    #       Impossible WHERE
95
95
explain select t1.*,t2.* from t1 left join t2 on t1.a=t2.a where isnull(t2.a)=1;
96
96
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
97
 
1       SIMPLE  t1      ALL     NULL    NULL    NULL    NULL    7       
98
 
1       SIMPLE  t2      eq_ref  PRIMARY PRIMARY 8       test.t1.a       1       Using where
 
97
1       SIMPLE  t1      ALL     NULL    NULL    NULL    NULL    #       
 
98
1       SIMPLE  t2      eq_ref  PRIMARY PRIMARY 8       test.t1.a       #       Using where
99
99
select t1.*,t2.*,t3.a from t1 left join t2 on (t1.a=t2.a) left join t1 as t3 on (t2.a=t3.a);
100
100
grp     a       c       id      a       c       d       a
101
101
1       1       a       1       1       a       1       1
128
128
1       1       a       1       1       a       1
129
129
drop table t1,t2;
130
130
CREATE TABLE t1 (
131
 
usr_id INT unsigned NOT NULL,
132
 
uniq_id INT unsigned NOT NULL AUTO_INCREMENT,
133
 
start_num INT unsigned NOT NULL DEFAULT 1,
134
 
increment INT unsigned NOT NULL DEFAULT 1,
 
131
usr_id INT NOT NULL,
 
132
uniq_id INT NOT NULL AUTO_INCREMENT,
 
133
start_num INT NOT NULL DEFAULT 1,
 
134
increment INT NOT NULL DEFAULT 1,
135
135
PRIMARY KEY (uniq_id),
136
136
INDEX usr_uniq_idx (usr_id, uniq_id),
137
137
INDEX uniq_usr_idx (uniq_id, usr_id)
138
138
);
139
139
CREATE TABLE t2 (
140
 
id INT unsigned NOT NULL DEFAULT 0,
141
 
usr2_id INT unsigned NOT NULL DEFAULT 0,
142
 
max INT unsigned NOT NULL DEFAULT 0,
143
 
c_amount INT unsigned NOT NULL DEFAULT 0,
144
 
d_max INT unsigned NOT NULL DEFAULT 0,
145
 
d_num INT unsigned NOT NULL DEFAULT 0,
146
 
orig_time INT unsigned NOT NULL DEFAULT 0,
147
 
c_time INT unsigned NOT NULL DEFAULT 0,
 
140
id INT NOT NULL DEFAULT 0,
 
141
usr2_id INT NOT NULL DEFAULT 0,
 
142
max INT NOT NULL DEFAULT 0,
 
143
c_amount INT NOT NULL DEFAULT 0,
 
144
d_max INT NOT NULL DEFAULT 0,
 
145
d_num INT NOT NULL DEFAULT 0,
 
146
orig_time INT NOT NULL DEFAULT 0,
 
147
c_time INT NOT NULL DEFAULT 0,
148
148
active ENUM ("no","yes") NOT NULL,
149
149
PRIMARY KEY (id,usr2_id),
150
150
INDEX id_idx (id),
204
204
CREATE TABLE t2 (
205
205
idAssignatura int DEFAULT '0' NOT NULL,
206
206
Grup int DEFAULT '0' NOT NULL,
207
 
Places smallint DEFAULT '0' NOT NULL,
 
207
Places int DEFAULT '0' NOT NULL,
208
208
PlacesOcupades int DEFAULT '0',
209
209
PRIMARY KEY (idAssignatura,Grup)
210
210
);
238
238
dni_pasaporte char(16) DEFAULT '' NOT NULL,
239
239
idPla int DEFAULT '0' NOT NULL,
240
240
cod_asig int DEFAULT '0' NOT NULL,
241
 
any smallint DEFAULT '0' NOT NULL,
242
 
quatrimestre smallint DEFAULT '0' NOT NULL,
 
241
any int DEFAULT '0' NOT NULL,
 
242
quatrimestre int DEFAULT '0' NOT NULL,
243
243
estat char(1) DEFAULT 'M' NOT NULL,
244
244
PRIMARY KEY (id),
245
245
UNIQUE dni_pasaporte (dni_pasaporte,idPla),
284
284
10362   NULL
285
285
drop table t1,t2,t3,test.t4;
286
286
CREATE TABLE t1 (
287
 
id smallint unsigned NOT NULL auto_increment,
 
287
id int NOT NULL auto_increment,
288
288
name char(60) DEFAULT '' NOT NULL,
289
289
PRIMARY KEY (id)
290
290
);
292
292
INSERT INTO t1 VALUES (2,'Lilliana Angelovska');
293
293
INSERT INTO t1 VALUES (3,'Thimble Smith');
294
294
CREATE TABLE t2 (
295
 
id smallint unsigned NOT NULL auto_increment,
296
 
owner smallint unsigned DEFAULT '0' NOT NULL,
 
295
id int NOT NULL auto_increment,
 
296
owner int DEFAULT '0' NOT NULL,
297
297
name char(60),
298
298
PRIMARY KEY (id)
299
299
);
577
577
CREATE TABLE t1 (
578
578
id int,
579
579
pid int,
580
 
rep_del tinyint,
 
580
rep_del int,
581
581
KEY id (id),
582
582
KEY pid (pid)
583
583
);
598
598
name tinytext DEFAULT '' NOT NULL,
599
599
UNIQUE id (id)
600
600
);
601
 
Warnings:
602
 
Warning 1101    BLOB/TEXT column 'name' can't have a default value
603
601
INSERT INTO t1 VALUES (1,'yes'),(2,'no');
604
602
CREATE TABLE t2 (
605
603
id int DEFAULT '0' NOT NULL,
623
621
bug_id  reporter        bug_id  who
624
622
1       1       1       2
625
623
drop table t1,t2;
626
 
create table t1 (fooID smallint unsigned auto_increment, primary key (fooID));
627
 
create table t2 (fooID smallint unsigned not null, barID smallint unsigned not null, primary key (fooID,barID));
 
624
create table t1 (fooID int auto_increment, primary key (fooID));
 
625
create table t2 (fooID int not null, barID int not null, primary key (fooID,barID));
628
626
insert into t1 (fooID) values (10),(20),(30);
629
627
insert into t2 values (10,1),(20,2),(30,3);
630
628
explain select * from t2 left join t1 on t1.fooID = t2.fooID and t1.fooID = 30;
631
629
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
632
 
1       SIMPLE  t2      index   NULL    PRIMARY 4       NULL    3       Using index
633
 
1       SIMPLE  t1      const   PRIMARY PRIMARY 2       const   1       Using index
 
630
1       SIMPLE  t2      index   NULL    PRIMARY 8       NULL    3       Using index
 
631
1       SIMPLE  t1      const   PRIMARY PRIMARY 4       const   1       Using index
634
632
select * from t2 left join t1 on t1.fooID = t2.fooID and t1.fooID = 30;
635
633
fooID   barID   fooID
636
634
10      1       NULL
712
710
4       NULL    NULL
713
711
drop table t1,t2;
714
712
create table t1 (
715
 
match_id tinyint unsigned not null auto_increment,
716
 
home tinyint unsigned default '0',
 
713
match_id int not null auto_increment,
 
714
home int default '0',
717
715
unique key match_id (match_id),
718
716
key match_id_2 (match_id)
719
717
);
720
718
insert into t1 values("1", "2");
721
719
create table t2 (
722
 
player_id tinyint unsigned default '0',
723
 
match_1_h tinyint unsigned default '0',
 
720
player_id int default '0',
 
721
match_1_h int default '0',
724
722
key player_id (player_id)
725
723
);
726
724
insert into t2 values("1", "5");
738
736
order by m.match_id desc;
739
737
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
740
738
1       SIMPLE  s       ALL     NULL    NULL    NULL    NULL    10      Using temporary; Using filesort
741
 
1       SIMPLE  m       const   match_id,match_id_2     match_id        1       const   1       
 
739
1       SIMPLE  m       const   match_id,match_id_2     match_id        4       const   1       
742
740
explain select s.*, '*', m.*, (s.match_1_h - m.home) UUX from 
743
741
(t2 s left join t1 m on m.match_id = 1) 
744
742
order by UUX desc;
745
743
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
746
744
1       SIMPLE  s       ALL     NULL    NULL    NULL    NULL    10      Using temporary; Using filesort
747
 
1       SIMPLE  m       const   match_id,match_id_2     match_id        1       const   1       
 
745
1       SIMPLE  m       const   match_id,match_id_2     match_id        4       const   1       
748
746
select s.*, '*', m.*, (s.match_1_h - m.home) UUX from 
749
747
(t2 s left join t1 m on m.match_id = 1) 
750
748
order by UUX desc;
764
762
order by UUX desc;
765
763
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
766
764
1       SIMPLE  s       ALL     NULL    NULL    NULL    NULL    10      Using temporary; Using filesort
767
 
1       SIMPLE  m       const   match_id,match_id_2     match_id        1       const   1       
 
765
1       SIMPLE  m       const   match_id,match_id_2     match_id        4       const   1       
768
766
select s.*, '*', m.*, (s.match_1_h - m.home) UUX from 
769
767
t2 s straight_join t1 m where m.match_id = 1 
770
768
order by UUX desc;
790
788
a       b       c
791
789
1       11      NULL
792
790
drop table t1, t2;
793
 
CREATE TABLE t1 (
794
 
ts_id bigint default NULL,
795
 
inst_id tinyint default NULL,
796
 
flag_name varchar(64) default NULL,
797
 
flag_value text,
798
 
UNIQUE KEY ts_id (ts_id,inst_id,flag_name)
799
 
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
800
 
CREATE TABLE t2 (
801
 
ts_id bigint default NULL,
802
 
inst_id tinyint default NULL,
803
 
flag_name varchar(64) default NULL,
804
 
flag_value text,
805
 
UNIQUE KEY ts_id (ts_id,inst_id,flag_name)
806
 
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
 
791
CREATE TEMPORARY TABLE t1 (
 
792
ts_id bigint default NULL,
 
793
inst_id int default NULL,
 
794
flag_name varchar(64) default NULL,
 
795
flag_value text,
 
796
UNIQUE KEY ts_id (ts_id,inst_id,flag_name)
 
797
) ENGINE=MyISAM;
 
798
CREATE TEMPORARY TABLE t2 (
 
799
ts_id bigint default NULL,
 
800
inst_id int default NULL,
 
801
flag_name varchar(64) default NULL,
 
802
flag_value text,
 
803
UNIQUE KEY ts_id (ts_id,inst_id,flag_name)
 
804
) ENGINE=MyISAM;
807
805
INSERT INTO t1 VALUES
808
806
(111056548820001, 0, 'flag1', NULL),
809
807
(111056548820001, 0, 'flag2', NULL),
820
818
flag2   NULL
821
819
DROP TABLE t1,t2;
822
820
CREATE TABLE t1 (
823
 
id int unsigned NOT NULL auto_increment,
824
 
text_id int unsigned default NULL,
 
821
id int NOT NULL auto_increment,
 
822
text_id int default NULL,
825
823
PRIMARY KEY  (id)
826
824
);
827
825
INSERT INTO t1 VALUES("1", "0");
963
961
Warning 1260    2 line(s) were cut by GROUP_CONCAT()
964
962
drop table t1, t2;
965
963
set group_concat_max_len=default;
966
 
create table t1 (gid smallint unsigned not null, x int not null, y int not null, art int not null, primary key  (gid,x,y));
 
964
create table t1 (gid int not null, x int not null, y int not null, art int not null, primary key  (gid,x,y));
967
965
insert t1 values (1, -5, -8, 2), (1, 2, 2, 1), (1, 1, 1, 1);
968
 
create table t2 (gid smallint unsigned not null, x int not null, y int not null, id int not null, primary key  (gid,id,x,y), key id (id));
 
966
create table t2 (gid int not null, x int not null, y int not null, id int not null, primary key  (gid,id,x,y), key id (id));
969
967
insert t2 values (1, -5, -8, 1), (1, 1, 1, 1), (1, 2, 2, 1);
970
 
create table t3 ( set_id smallint unsigned not null, id tinyint unsigned not null, name char(12) not null, primary key  (id,set_id));
 
968
create table t3 ( set_id int not null, id int not null, name char(12) not null, primary key  (id,set_id));
971
969
insert t3 values (0, 1, 'a'), (1, 1, 'b'), (0, 2, 'c'), (1, 2, 'd'), (1, 3, 'e'), (1, 4, 'f'), (1, 5, 'g'), (1, 6, 'h');
972
970
explain select name from t1 left join t2 on t1.x = t2.x and t1.y = t2.y
973
971
left join t3 on t1.art = t3.id where t2.id =1 and t2.x = -5 and t2.y =-8
974
972
and t1.gid =1 and t2.gid =1 and t3.set_id =1;
975
973
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
976
 
1       SIMPLE  t1      const   PRIMARY PRIMARY 10      const,const,const       1       
977
 
1       SIMPLE  t2      const   PRIMARY,id      PRIMARY 14      const,const,const,const 1       Using index
978
 
1       SIMPLE  t3      const   PRIMARY PRIMARY 3       const,const     1       
 
974
1       SIMPLE  t1      const   PRIMARY PRIMARY 12      const,const,const       1       
 
975
1       SIMPLE  t2      const   PRIMARY,id      PRIMARY 16      const,const,const,const 1       Using index
 
976
1       SIMPLE  t3      const   PRIMARY PRIMARY 8       const,const     1       
979
977
drop tables t1,t2,t3;
980
978
CREATE TABLE t1 (c11 int);
981
979
CREATE TABLE t2 (c21 int);
1154
1152
4       NULL
1155
1153
DROP TABLE t1,t2;
1156
1154
CREATE TABLE t1 (
1157
 
f1 varchar(16) collate latin1_swedish_ci PRIMARY KEY,
1158
 
f2 varchar(16) collate latin1_swedish_ci
 
1155
f1 varchar(16) collate utf8_swedish_ci PRIMARY KEY,
 
1156
f2 varchar(16) collate utf8_swedish_ci
1159
1157
);
1160
1158
CREATE TABLE t2 (
1161
 
f1 varchar(16) collate latin1_swedish_ci PRIMARY KEY,
1162
 
f3 varchar(16) collate latin1_swedish_ci
 
1159
f1 varchar(16) collate utf8_swedish_ci PRIMARY KEY,
 
1160
f3 varchar(16) collate utf8_swedish_ci
1163
1161
);
1164
1162
INSERT INTO t1 VALUES ('bla','blah');
1165
1163
INSERT INTO t2 VALUES ('bla','sheep');