5
5
drop table if exists t1,t2;
8
create table t1 (a int, b int not null,unique key (a,b),index(b)) engine=myisam;
8
create temporary 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
31
32
create table t2 like t1;
33
create temporary table t2 like t1;
32
35
insert into t2 select * from t1;
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));
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
34
40
explain select * from t1 where a is null and b = 2;
41
# Ignore "rows" in output -- inaccurate for InnoDB
35
43
explain select * from t1 where a is null and b = 2 and c=0;
44
# Ignore "rows" in output -- inaccurate for InnoDB
36
46
explain select * from t1 where a is null and b = 7 and c=0;
47
# Ignore "rows" in output -- inaccurate for InnoDB
37
49
explain select * from t1 where a=2 and b = 2;
50
# Ignore "rows" in output -- inaccurate for InnoDB
38
52
explain select * from t1 where a<=>b limit 2;
53
# Ignore "rows" in output -- inaccurate for InnoDB
39
55
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
40
58
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
41
61
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
42
64
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
43
67
explain select * from t1 where a > 1 and a < 3 limit 1;
68
# Ignore "rows" in output -- inaccurate for InnoDB
44
70
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
45
73
explain select * from t1 where a > 8 and a < 9;
74
# Ignore "rows" in output -- inaccurate for InnoDB
46
76
explain select * from t1 where b like "6%";
47
77
select * from t1 where a is null;
48
78
select * from t1 where a is null and b = 7 and c=0;
57
87
# Test ref_or_null optimization
60
rename table t2 to t1;
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;
61
94
alter table t1 modify b int null;
62
95
insert into t1 values (7,null), (8,null), (8,7);
63
96
explain select * from t1 where a = 7 and (b=7 or b is null);
68
101
select * from t1 where (a = 7 or a is null) and (a = 7 or a is null);
69
102
create table t2 (a int);
70
103
insert into t2 values (7),(8);
104
# Ignore "rows" in output -- inaccurate for InnoDB
71
106
explain select * from t2 straight_join t1 where t1.a=t2.a and b is null;
72
107
drop index b on t1;
108
# Ignore "rows" in output -- inaccurate for InnoDB
73
110
explain select * from t2,t1 where t1.a=t2.a and b is null;
74
111
select * from t2,t1 where t1.a=t2.a and b is null;
112
# Ignore "rows" in output -- inaccurate for InnoDB
75
114
explain select * from t2,t1 where t1.a=t2.a and (b= 7 or b is null);
76
115
select * from t2,t1 where t1.a=t2.a and (b= 7 or b is null);
116
# Ignore "rows" in output -- inaccurate for InnoDB
77
118
explain select * from t2,t1 where (t1.a=t2.a or t1.a is null) and b= 7;
78
119
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
79
122
explain select * from t2,t1 where (t1.a=t2.a or t1.a is null) and (b= 7 or b is null);
80
123
select * from t2,t1 where (t1.a=t2.a or t1.a is null) and (b= 7 or b is null);
81
124
insert into t2 values (null),(6);
82
125
delete from t1 where a=8;
126
# Ignore "rows" in output -- inaccurate for InnoDB
83
128
explain select * from t2,t1 where t1.a=t2.a or t1.a is null;
129
# Ignore "rows" in output -- inaccurate for InnoDB
84
131
explain select * from t2,t1 where t1.a<=>t2.a or (t1.a is null and t1.b <> 9);
85
132
select * from t2,t1 where t1.a<=>t2.a or (t1.a is null and t1.b <> 9);
89
136
# The following failed for Matt Loschert
93
id int(10) NOT NULL auto_increment,
94
uniq_id int(10) default NULL,
139
CREATE TEMPORARY TABLE t1 (
140
id int NOT NULL auto_increment,
141
uniq_id int default NULL,
96
143
UNIQUE KEY idx1 (uniq_id)
100
id int(10) NOT NULL auto_increment,
101
uniq_id int(10) default NULL,
146
CREATE TEMPORARY TABLE t2 (
147
id int NOT NULL auto_increment,
148
uniq_id int default NULL,
133
180
# This crashed MySQL 3.23.47
183
CREATE TEMPORARY TABLE `t1` (
137
184
`order_id` char(32) NOT NULL default '',
138
185
`product_id` char(32) NOT NULL default '',
139
`product_type` int(11) NOT NULL default '0',
186
`product_type` int NOT NULL default '0',
140
187
PRIMARY KEY (`order_id`,`product_id`,`product_type`)
189
CREATE TEMPORARY TABLE `t2` (
143
190
`order_id` char(32) NOT NULL default '',
144
191
`product_id` char(32) NOT NULL default '',
145
`product_type` int(11) NOT NULL default '0',
192
`product_type` int NOT NULL default '0',
146
193
PRIMARY KEY (`order_id`,`product_id`,`product_type`)
148
195
INSERT INTO t1 (order_id, product_id, product_type) VALUES
245
295
# BUG#34945 "ref_or_null queries that are null_rejecting and have a null value crash mysql"
247
297
CREATE TABLE t1 (
248
a int(11) default NULL,
249
b int(11) default NULL,
252
302
INSERT INTO t1 VALUES (0,10),(0,11),(0,12);
254
304
CREATE TABLE t2 (
255
a int(11) default NULL,
256
b int(11) default NULL,
259
309
INSERT INTO t2 VALUES (3,NULL),(3,11),(3,12);