~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/null_key.test

  • Committer: Brian Aker
  • Date: 2010-12-08 22:35:56 UTC
  • mfrom: (1819.9.158 update-innobase)
  • Revision ID: brian@tangent.org-20101208223556-37mi4omqg7lkjzf3
Merge in Stewart's changes, 1.3 changes.

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 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;
 
34
show create table t2;
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
 
39
--replace_column 9 X
34
40
explain select * from t1 where a is null and b = 2;
 
41
# Ignore "rows" in output -- inaccurate for InnoDB
 
42
--replace_column 9 X
35
43
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
36
46
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
37
49
explain select * from t1 where a=2 and b = 2;
 
50
# Ignore "rows" in output -- inaccurate for InnoDB
 
51
--replace_column 9 X
38
52
explain select * from t1 where a<=>b limit 2;
 
53
# Ignore "rows" in output -- inaccurate for InnoDB
 
54
--replace_column 9 X
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
 
57
--replace_column 9 X
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
 
60
--replace_column 9 X
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
 
63
--replace_column 9 X
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
 
66
--replace_column 9 X
43
67
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
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
 
72
--replace_column 9 X
45
73
explain select * from t1 where a > 8 and a < 9;
 
74
# Ignore "rows" in output -- inaccurate for InnoDB
 
75
--replace_column 9 X
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
58
88
#
59
89
drop table t1;
60
 
rename table t2 to 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;
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
 
105
--replace_column 9 X
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
 
109
--replace_column 9 X
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
 
113
--replace_column 9 X
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
 
117
--replace_column 9 X
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
 
121
--replace_column 9 X
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
 
127
--replace_column 9 X
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
 
130
--replace_column 9 X
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);
86
133
drop table t1,t2;
89
136
# The following failed for Matt Loschert
90
137
#
91
138
 
92
 
CREATE TABLE t1 (
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,
95
142
  PRIMARY KEY  (id),
96
143
  UNIQUE KEY idx1 (uniq_id)
97
144
) ENGINE=MyISAM;
98
145
 
99
 
CREATE TABLE t2 (
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,
102
149
  PRIMARY KEY  (id)
103
150
) ENGINE=MyISAM;
104
151
 
133
180
# This crashed MySQL 3.23.47
134
181
#
135
182
 
136
 
CREATE TABLE `t1` (
 
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`)
141
188
) ENGINE=MyISAM;
142
 
CREATE TABLE `t2` (
 
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`)
147
194
) ENGINE=MyISAM;
148
195
INSERT INTO t1 (order_id, product_id, product_type) VALUES
183
230
  index (id),
184
231
  index (id2)
185
232
);
 
233
--error ER_BAD_NULL_ERROR
186
234
insert into t1 values(null,null),(1,1);
187
235
select * from t1;
188
236
select * from t1 where id <=> null;
230
278
 
231
279
SELECT COUNT(*) FROM t3;
232
280
 
 
281
# Ignore the 9th column (rows in EXPLAIN output - inaccurate in InnoDB)
 
282
--replace_column 9 X
233
283
EXPLAIN SELECT SQL_CALC_FOUND_ROWS * FROM t1 LEFT JOIN t2 ON t1.a=t2.a
234
284
                                             LEFT JOIN t3 ON t2.b=t3.b;
235
285
FLUSH STATUS ;
245
295
# BUG#34945 "ref_or_null queries that are null_rejecting and have a null value crash mysql"
246
296
247
297
CREATE TABLE t1 (
248
 
  a int(11) default NULL,
249
 
  b int(11) default NULL,
 
298
  a int default NULL,
 
299
  b int default NULL,
250
300
  KEY a (a,b)
251
301
);
252
302
INSERT INTO t1 VALUES (0,10),(0,11),(0,12);
253
303
 
254
304
CREATE TABLE t2 (
255
 
  a int(11) default NULL,
256
 
  b int(11) default NULL,
 
305
  a int default NULL,
 
306
  b int default NULL,
257
307
  KEY a (a)
258
308
);
259
309
INSERT INTO t2 VALUES (3,NULL),(3,11),(3,12);