~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/null_key.test

  • Committer: jay
  • Date: 2008-12-22 20:14:27 UTC
  • mfrom: (685.4.32 enable-tests)
  • Revision ID: jay@piggy.tangent.org-20081222201427-t6yc273ateslr8h7
Fresh trunk merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
create table t2 like t1;
32
32
insert into t2 select * from t1;
33
33
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));
 
34
# @TODO Should this be a MyISAM-specific test or not?
 
35
# Ignore "rows" in output -- inaccurate for InnoDB
 
36
--regex-replace 9 X
34
37
explain select * from t1 where a is null and b = 2;
 
38
# Ignore "rows" in output -- inaccurate for InnoDB
 
39
--regex-replace 9 X
35
40
explain select * from t1 where a is null and b = 2 and c=0;
 
41
# Ignore "rows" in output -- inaccurate for InnoDB
 
42
--regex-replace 9 X
36
43
explain select * from t1 where a is null and b = 7 and c=0;
 
44
# Ignore "rows" in output -- inaccurate for InnoDB
 
45
--regex-replace 9 X
37
46
explain select * from t1 where a=2 and b = 2;
 
47
# Ignore "rows" in output -- inaccurate for InnoDB
 
48
--regex-replace 9 X
38
49
explain select * from t1 where a<=>b limit 2;
 
50
# Ignore "rows" in output -- inaccurate for InnoDB
 
51
--regex-replace 9 X
39
52
explain select * from t1 where (a is null or a > 0 and a < 3) and b < 5 and c=0 limit 3;
 
53
# Ignore "rows" in output -- inaccurate for InnoDB
 
54
--regex-replace 9 X
40
55
explain select * from t1 where (a is null or a = 7) and b=7 and c=0;
 
56
# Ignore "rows" in output -- inaccurate for InnoDB
 
57
--regex-replace 9 X
41
58
explain select * from t1 where (a is null and b>a) or a is null and b=7 limit 2;
 
59
# Ignore "rows" in output -- inaccurate for InnoDB
 
60
--regex-replace 9 X
42
61
explain select * from t1 where a is null and b=9 or a is null and b=7 limit 3;
 
62
# Ignore "rows" in output -- inaccurate for InnoDB
 
63
--regex-replace 9 X
43
64
explain select * from t1 where a > 1 and a < 3 limit 1;
 
65
# Ignore "rows" in output -- inaccurate for InnoDB
 
66
--regex-replace 9 X
44
67
explain select * from t1 where a is null and b=7 or a > 1 and a < 3 limit 1;
 
68
# Ignore "rows" in output -- inaccurate for InnoDB
 
69
--regex-replace 9 X
45
70
explain select * from t1 where a > 8 and a < 9;
 
71
# Ignore "rows" in output -- inaccurate for InnoDB
 
72
--regex-replace 9 X
46
73
explain select * from t1 where b like "6%";
47
74
select * from t1 where a is null;
48
75
select * from t1 where a is null and b = 7 and c=0;
57
84
# Test ref_or_null optimization
58
85
#
59
86
drop table t1;
60
 
rename table t2 to t1;
 
87
# @TODO Bug in the following RENAME...changing it out for now.
 
88
# rename table t2 to t1;
 
89
drop table t2;
 
90
create table t1 (a int, b int not null,unique key (a,b),index(b)) engine=myisam;
61
91
alter table t1 modify b int null;
62
92
insert into t1 values (7,null), (8,null), (8,7);
63
93
explain select * from t1 where a = 7 and (b=7 or b is null);
68
98
select * from t1 where (a = 7 or a is null) and (a = 7 or a is null);
69
99
create table t2 (a int);
70
100
insert into t2 values (7),(8);
 
101
# Ignore "rows" in output -- inaccurate for InnoDB
 
102
--regex-replace 9 X
71
103
explain select * from t2 straight_join t1 where t1.a=t2.a and b is null;
72
104
drop index b on t1;
 
105
# Ignore "rows" in output -- inaccurate for InnoDB
 
106
--regex-replace 9 X
73
107
explain select * from t2,t1 where t1.a=t2.a and b is null;
74
108
select * from t2,t1 where t1.a=t2.a and b is null;
 
109
# Ignore "rows" in output -- inaccurate for InnoDB
 
110
--regex-replace 9 X
75
111
explain select * from t2,t1 where t1.a=t2.a and (b= 7 or b is null);
76
112
select * from t2,t1 where t1.a=t2.a and (b= 7 or b is null);
 
113
# Ignore "rows" in output -- inaccurate for InnoDB
 
114
--regex-replace 9 X
77
115
explain select * from t2,t1 where (t1.a=t2.a or t1.a is null) and b= 7;
78
116
select * from t2,t1 where (t1.a=t2.a or t1.a is null) and b= 7;
 
117
# Ignore "rows" in output -- inaccurate for InnoDB
 
118
--regex-replace 9 X
79
119
explain select * from t2,t1 where (t1.a=t2.a or t1.a is null) and (b= 7 or b is null);
80
120
select * from t2,t1 where (t1.a=t2.a or t1.a is null) and (b= 7 or b is null);
81
121
insert into t2 values (null),(6);
82
122
delete from t1 where a=8;
 
123
# Ignore "rows" in output -- inaccurate for InnoDB
 
124
--regex-replace 9 X
83
125
explain select * from t2,t1 where t1.a=t2.a or t1.a is null;
 
126
# Ignore "rows" in output -- inaccurate for InnoDB
 
127
--regex-replace 9 X
84
128
explain select * from t2,t1 where t1.a<=>t2.a or (t1.a is null and t1.b <> 9);
85
129
select * from t2,t1 where t1.a<=>t2.a or (t1.a is null and t1.b <> 9);
86
130
drop table t1,t2;
90
134
#
91
135
 
92
136
CREATE TABLE t1 (
93
 
  id int(10) NOT NULL auto_increment,
94
 
  uniq_id int(10) default NULL,
 
137
  id int NOT NULL auto_increment,
 
138
  uniq_id int default NULL,
95
139
  PRIMARY KEY  (id),
96
140
  UNIQUE KEY idx1 (uniq_id)
97
141
) ENGINE=MyISAM;
98
142
 
99
143
CREATE TABLE t2 (
100
 
  id int(10) NOT NULL auto_increment,
101
 
  uniq_id int(10) default NULL,
 
144
  id int NOT NULL auto_increment,
 
145
  uniq_id int default NULL,
102
146
  PRIMARY KEY  (id)
103
147
) ENGINE=MyISAM;
104
148
 
136
180
CREATE TABLE `t1` (
137
181
  `order_id` char(32) NOT NULL default '',
138
182
  `product_id` char(32) NOT NULL default '',
139
 
  `product_type` int(11) NOT NULL default '0',
 
183
  `product_type` int NOT NULL default '0',
140
184
  PRIMARY KEY  (`order_id`,`product_id`,`product_type`)
141
185
) ENGINE=MyISAM;
142
186
CREATE TABLE `t2` (
143
187
  `order_id` char(32) NOT NULL default '',
144
188
  `product_id` char(32) NOT NULL default '',
145
 
  `product_type` int(11) NOT NULL default '0',
 
189
  `product_type` int NOT NULL default '0',
146
190
  PRIMARY KEY  (`order_id`,`product_id`,`product_type`)
147
191
) ENGINE=MyISAM;
148
192
INSERT INTO t1 (order_id, product_id, product_type) VALUES
183
227
  index (id),
184
228
  index (id2)
185
229
);
 
230
--error 1048
186
231
insert into t1 values(null,null),(1,1);
187
232
select * from t1;
188
233
select * from t1 where id <=> null;
230
275
 
231
276
SELECT COUNT(*) FROM t3;
232
277
 
 
278
# Ignore the 9th column (rows in EXPLAIN output - inaccurate in InnoDB)
 
279
--regex_replace 9 X
233
280
EXPLAIN SELECT SQL_CALC_FOUND_ROWS * FROM t1 LEFT JOIN t2 ON t1.a=t2.a
234
281
                                             LEFT JOIN t3 ON t2.b=t3.b;
235
282
FLUSH STATUS ;
245
292
# BUG#34945 "ref_or_null queries that are null_rejecting and have a null value crash mysql"
246
293
247
294
CREATE TABLE t1 (
248
 
  a int(11) default NULL,
249
 
  b int(11) default NULL,
 
295
  a int default NULL,
 
296
  b int default NULL,
250
297
  KEY a (a,b)
251
298
);
252
299
INSERT INTO t1 VALUES (0,10),(0,11),(0,12);
253
300
 
254
301
CREATE TABLE t2 (
255
 
  a int(11) default NULL,
256
 
  b int(11) default NULL,
 
302
  a int default NULL,
 
303
  b int default NULL,
257
304
  KEY a (a)
258
305
);
259
306
INSERT INTO t2 VALUES (3,NULL),(3,11),(3,12);