~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/r/null_key.result

  • Committer: Brian Aker
  • Date: 2010-01-22 00:53:13 UTC
  • Revision ID: brian@gaz-20100122005313-jmizcbcdi1lt4tcx
Revert db patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
1       SIMPLE  t1      range   a,b     a       9       NULL    3       Using where; Using index
22
22
explain select * from t1 where (a is null or a = 7) and b=7;
23
23
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
24
 
1       SIMPLE  t1      ref_or_null     a,b     a       9       const,const     2       Using where; Using index
 
24
1       SIMPLE  t1      ref_or_null     a,b     a       9       const,const     2       Using index
25
25
explain select * from t1 where (a is null or a = 7) and b=7 order by a;
26
26
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
27
 
1       SIMPLE  t1      ref_or_null     a,b     a       9       const,const     2       Using where; Using index; Using filesort
 
27
1       SIMPLE  t1      ref_or_null     a,b     a       9       const,const     2       Using index; Using filesort
28
28
explain select * from t1 where (a is null and b>a) or a is null and b=7 limit 2;
29
29
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
30
30
1       SIMPLE  t1      ref     a,b     a       5       const   3       Using where; Using index
77
77
show create table t2;
78
78
Table   Create Table
79
79
t2      CREATE TEMPORARY TABLE `t2` (
80
 
  `a` INT DEFAULT NULL,
81
 
  `b` INT NOT NULL,
 
80
  `a` int DEFAULT NULL,
 
81
  `b` int NOT NULL,
82
82
  UNIQUE KEY `a` (`a`,`b`),
83
83
  KEY `b` (`b`)
84
 
) ENGINE=MyISAM COLLATE = utf8_general_ci
 
84
) ENGINE=MyISAM
85
85
insert into t2 select * from t1;
86
 
alter table t1 modify b blob not null, add c int DEFAULT 42 not null, drop key a, add unique key (a,b(20),c), drop key b, add key (b(10));
 
86
alter table t1 modify b blob not null, add c int not null, drop key a, add unique key (a,b(20),c), drop key b, add key (b(10));
87
87
explain select * from t1 where a is null and b = 2;
88
88
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
89
89
1       SIMPLE  t1      ref     a,b     a       5       const   X       Using where
125
125
1       SIMPLE  t1      range   b       b       12      NULL    X       Using where
126
126
select * from t1 where a is null;
127
127
a       b       c
128
 
NULL    7       42
129
 
NULL    9       42
130
 
NULL    9       42
 
128
NULL    7       0
 
129
NULL    9       0
 
130
NULL    9       0
131
131
select * from t1 where a is null and b = 7 and c=0;
132
132
a       b       c
 
133
NULL    7       0
133
134
select * from t1 where a<=>b limit 2;
134
135
a       b       c
135
 
1       1       42
136
 
2       2       42
 
136
1       1       0
 
137
2       2       0
137
138
select * from t1 where (a is null or a > 0 and a < 3) and b < 5 limit 3;
138
139
a       b       c
139
 
1       1       42
140
 
2       2       42
 
140
1       1       0
 
141
2       2       0
141
142
select * from t1 where (a is null or a > 0 and a < 3) and b > 7 limit 3;
142
143
a       b       c
143
 
NULL    9       42
144
 
NULL    9       42
 
144
NULL    9       0
 
145
NULL    9       0
145
146
select * from t1 where (a is null or a = 7) and b=7 and c=0;
146
147
a       b       c
 
148
7       7       0
 
149
NULL    7       0
147
150
select * from t1 where a is null and b=9 or a is null and b=7 limit 3;
148
151
a       b       c
149
 
NULL    7       42
150
 
NULL    9       42
151
 
NULL    9       42
 
152
NULL    7       0
 
153
NULL    9       0
 
154
NULL    9       0
152
155
select * from t1 where b like "6%";
153
156
a       b       c
154
 
6       6       42
 
157
6       6       0
155
158
drop table t1;
156
159
drop table t2;
157
160
create temporary table t1 (a int, b int not null,unique key (a,b),index(b)) engine=myisam;
159
162
insert into t1 values (7,null), (8,null), (8,7);
160
163
explain select * from t1 where a = 7 and (b=7 or b is null);
161
164
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
162
 
1       SIMPLE  t1      ref_or_null     a,b     a       10      const,const     2       Using where; Using index
 
165
1       SIMPLE  t1      ref_or_null     a,b     a       10      const,const     2       Using index
163
166
select * from t1 where a = 7 and (b=7 or b is null);
164
167
a       b
165
168
7       NULL
171
174
7       NULL
172
175
explain select * from t1 where (a = 7 or a is null) and (a = 7 or a is null);
173
176
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
174
 
1       SIMPLE  t1      ref_or_null     a       a       5       const   2       Using where; Using index
 
177
1       SIMPLE  t1      ref_or_null     a       a       5       const   2       Using index
175
178
select * from t1 where (a = 7 or a is null) and (a = 7 or a is null);
176
179
a       b
177
180
7       NULL
193
196
explain select * from t2,t1 where t1.a=t2.a and (b= 7 or b is null);
194
197
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
195
198
1       SIMPLE  t2      ALL     NULL    NULL    NULL    NULL    X       
196
 
1       SIMPLE  t1      ref_or_null     a       a       10      test.t2.a,const X       Using where; Using index
 
199
1       SIMPLE  t1      ref_or_null     a       a       10      test.t2.a,const X       Using index
197
200
select * from t2,t1 where t1.a=t2.a and (b= 7 or b is null);
198
201
a       a       b
199
202
7       7       NULL
202
205
explain select * from t2,t1 where (t1.a=t2.a or t1.a is null) and b= 7;
203
206
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
204
207
1       SIMPLE  t2      ALL     NULL    NULL    NULL    NULL    X       
205
 
1       SIMPLE  t1      ref_or_null     a       a       10      test.t2.a,const X       Using where; Using index
 
208
1       SIMPLE  t1      ref_or_null     a       a       10      test.t2.a,const X       Using index
206
209
select * from t2,t1 where (t1.a=t2.a or t1.a is null) and b= 7;
207
210
a       a       b
208
211
8       8       7