5
5
drop table if exists t1,t2;
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 ER_CANT_CREATE_TABLE
32
31
create table t2 like t1;
33
create temporary table t2 like t1;
35
32
insert into t2 select * from t1;
36
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));
37
# @TODO Should this be a MyISAM-specific test or not?
38
# Ignore "rows" in output -- inaccurate for InnoDB
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));
40
34
explain select * from t1 where a is null and b = 2;
41
# Ignore "rows" in output -- inaccurate for InnoDB
43
35
explain select * from t1 where a is null and b = 2 and c=0;
44
# Ignore "rows" in output -- inaccurate for InnoDB
46
36
explain select * from t1 where a is null and b = 7 and c=0;
47
# Ignore "rows" in output -- inaccurate for InnoDB
49
37
explain select * from t1 where a=2 and b = 2;
50
# Ignore "rows" in output -- inaccurate for InnoDB
52
38
explain select * from t1 where a<=>b limit 2;
53
# Ignore "rows" in output -- inaccurate for InnoDB
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
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
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
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
67
43
explain select * from t1 where a > 1 and a < 3 limit 1;
68
# Ignore "rows" in output -- inaccurate for InnoDB
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
73
45
explain select * from t1 where a > 8 and a < 9;
74
# Ignore "rows" in output -- inaccurate for InnoDB
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
90
# @TODO Bug in the following RENAME...changing it out for now.
91
# rename table t2 to t1;
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
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
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
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
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
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
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
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);
136
89
# The following failed for Matt Loschert
139
CREATE TEMPORARY TABLE t1 (
140
id int NOT NULL auto_increment,
141
uniq_id int default NULL,
93
id int(10) NOT NULL auto_increment,
94
uniq_id int(10) default NULL,
143
96
UNIQUE KEY idx1 (uniq_id)
146
CREATE TEMPORARY TABLE t2 (
147
id int NOT NULL auto_increment,
148
uniq_id int default NULL,
100
id int(10) NOT NULL auto_increment,
101
uniq_id int(10) default NULL,
180
133
# This crashed MySQL 3.23.47
183
CREATE TEMPORARY 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`)
189
CREATE TEMPORARY 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`)
195
148
INSERT INTO t1 (order_id, product_id, product_type) VALUES
295
245
# BUG#34945 "ref_or_null queries that are null_rejecting and have a null value crash mysql"
297
247
CREATE TABLE t1 (
248
a int(11) default NULL,
249
b int(11) default NULL,
302
252
INSERT INTO t1 VALUES (0,10),(0,11),(0,12);
304
254
CREATE TABLE t2 (
255
a int(11) default NULL,
256
b int(11) default NULL,
309
259
INSERT INTO t2 VALUES (3,NULL),(3,11),(3,12);