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
37
34
explain select * from t1 where a is null and b = 2;
38
# Ignore "rows" in output -- inaccurate for InnoDB
40
35
explain select * from t1 where a is null and b = 2 and c=0;
41
# Ignore "rows" in output -- inaccurate for InnoDB
43
36
explain select * from t1 where a is null and b = 7 and c=0;
44
# Ignore "rows" in output -- inaccurate for InnoDB
46
37
explain select * from t1 where a=2 and b = 2;
47
# Ignore "rows" in output -- inaccurate for InnoDB
49
38
explain select * from t1 where a<=>b limit 2;
50
# Ignore "rows" in output -- inaccurate for InnoDB
52
39
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
55
40
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
58
41
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
61
42
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
64
43
explain select * from t1 where a > 1 and a < 3 limit 1;
65
# Ignore "rows" in output -- inaccurate for InnoDB
67
44
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
70
45
explain select * from t1 where a > 8 and a < 9;
71
# Ignore "rows" in output -- inaccurate for InnoDB
73
46
explain select * from t1 where b like "6%";
74
47
select * from t1 where a is null;
75
48
select * from t1 where a is null and b = 7 and c=0;
84
57
# Test ref_or_null optimization
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;
60
rename table t2 to t1;
91
61
alter table t1 modify b int null;
92
62
insert into t1 values (7,null), (8,null), (8,7);
93
63
explain select * from t1 where a = 7 and (b=7 or b is null);
98
68
select * from t1 where (a = 7 or a is null) and (a = 7 or a is null);
99
69
create table t2 (a int);
100
70
insert into t2 values (7),(8);
101
# Ignore "rows" in output -- inaccurate for InnoDB
103
71
explain select * from t2 straight_join t1 where t1.a=t2.a and b is null;
104
72
drop index b on t1;
105
# Ignore "rows" in output -- inaccurate for InnoDB
107
73
explain select * from t2,t1 where t1.a=t2.a and b is null;
108
74
select * from t2,t1 where t1.a=t2.a and b is null;
109
# Ignore "rows" in output -- inaccurate for InnoDB
111
75
explain select * from t2,t1 where t1.a=t2.a and (b= 7 or b is null);
112
76
select * from t2,t1 where t1.a=t2.a and (b= 7 or b is null);
113
# Ignore "rows" in output -- inaccurate for InnoDB
115
77
explain select * from t2,t1 where (t1.a=t2.a or t1.a is null) and b= 7;
116
78
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
119
79
explain select * from t2,t1 where (t1.a=t2.a or t1.a is null) and (b= 7 or b is null);
120
80
select * from t2,t1 where (t1.a=t2.a or t1.a is null) and (b= 7 or b is null);
121
81
insert into t2 values (null),(6);
122
82
delete from t1 where a=8;
123
# Ignore "rows" in output -- inaccurate for InnoDB
125
83
explain select * from t2,t1 where t1.a=t2.a or t1.a is null;
126
# Ignore "rows" in output -- inaccurate for InnoDB
128
84
explain select * from t2,t1 where t1.a<=>t2.a or (t1.a is null and t1.b <> 9);
129
85
select * from t2,t1 where t1.a<=>t2.a or (t1.a is null and t1.b <> 9);
137
id int NOT NULL auto_increment,
138
uniq_id int default NULL,
93
id int(10) NOT NULL auto_increment,
94
uniq_id int(10) default NULL,
140
96
UNIQUE KEY idx1 (uniq_id)
144
id int NOT NULL auto_increment,
145
uniq_id int default NULL,
100
id int(10) NOT NULL auto_increment,
101
uniq_id int(10) default NULL,
180
136
CREATE TABLE `t1` (
181
137
`order_id` char(32) NOT NULL default '',
182
138
`product_id` char(32) NOT NULL default '',
183
`product_type` int NOT NULL default '0',
139
`product_type` int(11) NOT NULL default '0',
184
140
PRIMARY KEY (`order_id`,`product_id`,`product_type`)
186
142
CREATE TABLE `t2` (
187
143
`order_id` char(32) NOT NULL default '',
188
144
`product_id` char(32) NOT NULL default '',
189
`product_type` int NOT NULL default '0',
145
`product_type` int(11) NOT NULL default '0',
190
146
PRIMARY KEY (`order_id`,`product_id`,`product_type`)
192
148
INSERT INTO t1 (order_id, product_id, product_type) VALUES
292
245
# BUG#34945 "ref_or_null queries that are null_rejecting and have a null value crash mysql"
294
247
CREATE TABLE t1 (
248
a int(11) default NULL,
249
b int(11) default NULL,
299
252
INSERT INTO t1 VALUES (0,10),(0,11),(0,12);
301
254
CREATE TABLE t2 (
255
a int(11) default NULL,
256
b int(11) default NULL,
306
259
INSERT INTO t2 VALUES (3,NULL),(3,11),(3,12);