~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysql-test/t/null_key.test

Merged in changes. 
Edited a the comment test case so deal with our version bump.

Show diffs side-by-side

added added

removed removed

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