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
34
37
explain select * from t1 where a is null and b = 2;
38
# Ignore "rows" in output -- inaccurate for InnoDB
35
40
explain select * from t1 where a is null and b = 2 and c=0;
41
# Ignore "rows" in output -- inaccurate for InnoDB
36
43
explain select * from t1 where a is null and b = 7 and c=0;
44
# Ignore "rows" in output -- inaccurate for InnoDB
37
46
explain select * from t1 where a=2 and b = 2;
47
# Ignore "rows" in output -- inaccurate for InnoDB
38
49
explain select * from t1 where a<=>b limit 2;
50
# Ignore "rows" in output -- inaccurate for InnoDB
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
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
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
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
43
64
explain select * from t1 where a > 1 and a < 3 limit 1;
65
# Ignore "rows" in output -- inaccurate for InnoDB
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
45
70
explain select * from t1 where a > 8 and a < 9;
71
# Ignore "rows" in output -- inaccurate for InnoDB
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
60
rename table t2 to t1;
87
# @TODO Bug in the following RENAME...changing it out for now.
88
# rename table t2 to t1;
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
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
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
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
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
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
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
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);
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,
96
140
UNIQUE KEY idx1 (uniq_id)
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,
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`)
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`)
148
192
INSERT INTO t1 (order_id, product_id, product_type) VALUES
245
292
# BUG#34945 "ref_or_null queries that are null_rejecting and have a null value crash mysql"
247
294
CREATE TABLE t1 (
248
a int(11) default NULL,
249
b int(11) default NULL,
252
299
INSERT INTO t1 VALUES (0,10),(0,11),(0,12);
254
301
CREATE TABLE t2 (
255
a int(11) default NULL,
256
b int(11) default NULL,
259
306
INSERT INTO t2 VALUES (3,NULL),(3,11),(3,12);