~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
drop table if exists t1, t2;
2
select null,\N,isnull(null),isnull(1/0),isnull(1/0 = null),ifnull(null,1),ifnull(null,"TRUE"),ifnull("TRUE","ERROR"),1/0 is null,1 is not null;
3
NULL	NULL	isnull(null)	isnull(1/0)	isnull(1/0 = null)	ifnull(null,1)	ifnull(null,"TRUE")	ifnull("TRUE","ERROR")	1/0 is null	1 is not null
4
NULL	NULL	1	1	1	1	TRUE	TRUE	1	1
685.4.1 by Jay Pipes
Enabled the null.test.
5
Warnings:
6
Error	1365	Division by 0
7
Error	1365	Division by 0
8
Error	1365	Division by 0
1 by brian
clean slate
9
explain extended select null,\N,isnull(null),isnull(1/0),isnull(1/0 = null),ifnull(null,1),ifnull(null,"TRUE"),ifnull("TRUE","ERROR"),1/0 is null,1 is not null;
10
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
11
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
12
Warnings:
685.4.1 by Jay Pipes
Enabled the null.test.
13
Error	1365	Division by 0
14
Error	1365	Division by 0
15
Error	1365	Division by 0
1 by brian
clean slate
16
Note	1003	select NULL AS `NULL`,NULL AS `NULL`,isnull(NULL) AS `isnull(null)`,isnull((1 / 0)) AS `isnull(1/0)`,isnull(((1 / 0) = NULL)) AS `isnull(1/0 = null)`,ifnull(NULL,1) AS `ifnull(null,1)`,ifnull(NULL,'TRUE') AS `ifnull(null,"TRUE")`,ifnull('TRUE','ERROR') AS `ifnull("TRUE","ERROR")`,isnull((1 / 0)) AS `1/0 is null`,(1 is not null) AS `1 is not null`
685.4.1 by Jay Pipes
Enabled the null.test.
17
select CONCAT(1, NULL),1+NULL,1-NULL;
18
CONCAT(1, NULL)	1+NULL	1-NULL
19
NULL	NULL	NULL
20
select NULL=NULL,NULL<>NULL,IFNULL(NULL,1.1)+0,CONCAT(IFNULL(NULL,1), 0);
21
NULL=NULL	NULL<>NULL	IFNULL(NULL,1.1)+0	CONCAT(IFNULL(NULL,1), 0)
22
NULL	NULL	1.1	10
23
select strcmp("a",NULL),(1<NULL)+0.0,null like "a%","a%" like null;
24
strcmp("a",NULL)	(1<NULL)+0.0	null like "a%"	"a%" like null
1 by brian
clean slate
25
NULL	NULL	NULL	NULL
26
select concat("a",NULL),replace(NULL,"a","b"),replace("string","i",NULL),replace("string",NULL,"i"),insert("abc",1,1,NULL),left(NULL,1);
27
concat("a",NULL)	replace(NULL,"a","b")	replace("string","i",NULL)	replace("string",NULL,"i")	insert("abc",1,1,NULL)	left(NULL,1)
28
NULL	NULL	NULL	NULL	NULL	NULL
29
select repeat("a",0),repeat("ab",5+5),repeat("ab",-1),reverse(NULL);
30
repeat("a",0)	repeat("ab",5+5)	repeat("ab",-1)	reverse(NULL)
31
	abababababababababab		NULL
32
select field(NULL,"a","b","c");
33
field(NULL,"a","b","c")
34
0
35
select 2 between null and 1,2 between 3 AND NULL,NULL between 1 and 2,2 between NULL and 3, 2 between 1 AND null;
36
2 between null and 1	2 between 3 AND NULL	NULL between 1 and 2	2 between NULL and 3	2 between 1 AND null
37
0	0	NULL	NULL	NULL
38
explain extended select 2 between null and 1,2 between 3 AND NULL,NULL between 1 and 2,2 between NULL and 3, 2 between 1 AND null;
39
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
40
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
41
Warnings:
42
Note	1003	select (2 between NULL and 1) AS `2 between null and 1`,(2 between 3 and NULL) AS `2 between 3 AND NULL`,(NULL between 1 and 2) AS `NULL between 1 and 2`,(2 between NULL and 3) AS `2 between NULL and 3`,(2 between 1 and NULL) AS `2 between 1 AND null`
43
SELECT NULL AND NULL, 1 AND NULL, NULL AND 1, NULL OR NULL, 0 OR NULL, NULL OR 0;
44
NULL AND NULL	1 AND NULL	NULL AND 1	NULL OR NULL	0 OR NULL	NULL OR 0
45
NULL	NULL	NULL	NULL	NULL	NULL
46
SELECT (NULL OR NULL) IS NULL;
47
(NULL OR NULL) IS NULL
48
1
49
select NULL AND 0, 0 and NULL;
50
NULL AND 0	0 and NULL
51
0	0
52
create table t1 (x int);
53
insert into t1 values (null);
54
select * from t1 where x != 0;
55
x
56
drop table t1;
57
CREATE TABLE t1 (
58
indexed_field int default NULL,
59
KEY indexed_field (indexed_field)
60
);
61
INSERT INTO t1 VALUES (NULL),(NULL);
62
SELECT * FROM t1 WHERE indexed_field=NULL;
63
indexed_field
64
SELECT * FROM t1 WHERE indexed_field IS NULL;
65
indexed_field
66
NULL
67
NULL
68
SELECT * FROM t1 WHERE indexed_field<=>NULL;
69
indexed_field
70
NULL
71
NULL
72
DROP TABLE t1;
685.4.1 by Jay Pipes
Enabled the null.test.
73
create table t1 (a int, b int);
1 by brian
clean slate
74
insert into t1 values(20,null);
75
select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on
76
t2.b=t3.a;
77
b	ifnull(t2.b,"this is null")
78
NULL	this is null
79
select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on
80
t2.b=t3.a order by 1;
81
b	ifnull(t2.b,"this is null")
82
NULL	this is null
83
insert into t1 values(10,null);
84
select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on
85
t2.b=t3.a order by 1;
86
b	ifnull(t2.b,"this is null")
87
NULL	this is null
88
NULL	this is null
89
drop table t1;
873.1.2 by Jay Pipes
Fixed Field_datetime to never accept any bad datetimes as a string. This broke
90
CREATE TABLE t1 (a varchar(16) NOT NULL default '', b int NOT NULL default 0, c datetime NOT NULL default '2009-02-10 00:00:00', d int NOT NULL default 0);
1 by brian
clean slate
91
INSERT INTO t1 (a) values (null);
92
ERROR 23000: Column 'a' cannot be null
93
INSERT INTO t1 (a) values (1/null);
94
ERROR 23000: Column 'a' cannot be null
95
INSERT INTO t1 (a) values (null),(null);
685.4.1 by Jay Pipes
Enabled the null.test.
96
ERROR 23000: Column 'a' cannot be null
1 by brian
clean slate
97
INSERT INTO t1 (b) values (null);
98
ERROR 23000: Column 'b' cannot be null
99
INSERT INTO t1 (b) values (1/null);
100
ERROR 23000: Column 'b' cannot be null
101
INSERT INTO t1 (b) values (null),(null);
685.4.1 by Jay Pipes
Enabled the null.test.
102
ERROR 23000: Column 'b' cannot be null
1 by brian
clean slate
103
INSERT INTO t1 (c) values (null);
104
ERROR 23000: Column 'c' cannot be null
105
INSERT INTO t1 (c) values (1/null);
106
ERROR 23000: Column 'c' cannot be null
107
INSERT INTO t1 (c) values (null),(null);
685.4.1 by Jay Pipes
Enabled the null.test.
108
ERROR 23000: Column 'c' cannot be null
1 by brian
clean slate
109
INSERT INTO t1 (d) values (null);
110
ERROR 23000: Column 'd' cannot be null
111
INSERT INTO t1 (d) values (1/null);
112
ERROR 23000: Column 'd' cannot be null
113
INSERT INTO t1 (d) values (null),(null);
685.4.1 by Jay Pipes
Enabled the null.test.
114
ERROR 23000: Column 'd' cannot be null
115
UPDATE t1 SET d= NULL;
116
INSERT INTO t1 VALUES ();
117
UPDATE t1 SET a=1/NULL;
118
ERROR 23000: Column 'a' cannot be null
119
UPDATE t1 SET a=NULL;
120
ERROR 23000: Column 'a' cannot be null
121
UPDATE t1 SET b=NULL;
122
ERROR 23000: Column 'b' cannot be null
123
UPDATE t1 SET c=NULL;
124
ERROR 23000: Column 'c' cannot be null
125
UPDATE t1 SET d=NULL;
126
ERROR 23000: Column 'd' cannot be null
127
truncate table t1;
128
LOAD DATA INFILE '../std_data_ln/null_test.txt' INTO TABLE t1 FIELDS ENCLOSED BY '"';
129
ERROR 22004: Column set to default value; NULL supplied to NOT NULL column 'a' at row 1
1 by brian
clean slate
130
drop table t1;
131
create table t1 (a int not null, b int not null, index idx(a));
132
insert into t1 values
133
(1,1), (2,2), (3,3), (4,4), (5,5), (6,6),
134
(7,7), (8,8), (9,9), (10,10), (11,11), (12,12);
135
explain select * from t1 where a between 2 and 3;
136
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1100.1.1 by Brian Aker
Disable MRR
137
1	SIMPLE	t1	range	idx	idx	4	NULL	2	Using where
1 by brian
clean slate
138
explain select * from t1 where a between 2 and 3 or b is null;
139
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1100.1.1 by Brian Aker
Disable MRR
140
1	SIMPLE	t1	range	idx	idx	4	NULL	2	Using where
685.4.1 by Jay Pipes
Enabled the null.test.
141
drop table t1;
1 by brian
clean slate
142
create table t1 select
143
null as c00,
144
if(1, null, 'string') as c01,
145
if(0, null, 'string') as c02,
146
ifnull(null, 'string') as c03,
147
ifnull('string', null) as c04,
148
case when 0 then null else 'string' end as c05,
149
case when 1 then null else 'string' end as c06,
150
coalesce(null, 'string') as c07,
151
coalesce('string', null) as c08,
152
least('string',null) as c09,
153
least(null, 'string') as c10,
154
greatest('string',null) as c11,
155
greatest(null, 'string') as c12,
156
nullif('string', null) as c13,
157
nullif(null, 'string') as c14,
158
trim('string' from null) as c15,
159
trim(null from 'string') as c16,
160
substring_index('string', null, 1) as c17,
161
substring_index(null, 'string', 1) as c18,
162
elt(1, null, 'string') as c19,
163
elt(1, 'string', null) as c20,
164
concat('string', null) as c21,
165
concat(null, 'string') as c22,
166
concat_ws('sep', 'string', null) as c23,
167
concat_ws('sep', null, 'string') as c24,
168
concat_ws(null, 'string', 'string') as c25,
169
make_set(3, 'string', null) as c26,
170
make_set(3, null, 'string') as c27,
171
export_set(3, null, 'off', 'sep') as c29,
172
export_set(3, 'on', null, 'sep') as c30,
173
export_set(3, 'on', 'off', null) as c31,
174
replace(null, 'from', 'to') as c32,
175
replace('str', null, 'to') as c33,
176
replace('str', 'from', null) as c34,
177
insert('str', 1, 2, null) as c35,
178
insert(null, 1, 2, 'str') as c36,
179
lpad('str', 10, null) as c37,
180
rpad(null, 10, 'str') as c38;
181
show create table t1;
182
Table	Create Table
183
t1	CREATE TABLE `t1` (
873.2.35 by Monty Taylor
Update tests based on how Toru's latest patch changes create table statements.
184
  `c00` varbinary(0) DEFAULT NULL,
185
  `c01` varchar(6) DEFAULT NULL,
186
  `c02` varchar(6) DEFAULT NULL,
896.3.6 by Stewart Smith
Read Fields out of proto instead of FRM.
187
  `c03` varchar(6) NOT NULL,
873.2.35 by Monty Taylor
Update tests based on how Toru's latest patch changes create table statements.
188
  `c04` varchar(6) DEFAULT NULL,
189
  `c05` varchar(6) DEFAULT NULL,
190
  `c06` varchar(6) DEFAULT NULL,
191
  `c07` varchar(6) DEFAULT NULL,
192
  `c08` varchar(6) DEFAULT NULL,
193
  `c09` varchar(6) DEFAULT NULL,
194
  `c10` varchar(6) DEFAULT NULL,
195
  `c11` varchar(6) DEFAULT NULL,
196
  `c12` varchar(6) DEFAULT NULL,
197
  `c13` varchar(6) DEFAULT NULL,
198
  `c14` varchar(0) DEFAULT NULL,
199
  `c15` varchar(0) DEFAULT NULL,
200
  `c16` varchar(6) DEFAULT NULL,
201
  `c17` varchar(6) DEFAULT NULL,
202
  `c18` varchar(0) DEFAULT NULL,
203
  `c19` varchar(6) DEFAULT NULL,
204
  `c20` varchar(6) DEFAULT NULL,
205
  `c21` varchar(6) DEFAULT NULL,
206
  `c22` varchar(6) DEFAULT NULL,
207
  `c23` varchar(9) DEFAULT NULL,
208
  `c24` varchar(9) DEFAULT NULL,
209
  `c25` varchar(12) DEFAULT NULL,
210
  `c26` varchar(7) DEFAULT NULL,
211
  `c27` varchar(7) DEFAULT NULL,
212
  `c29` varchar(381) DEFAULT NULL,
213
  `c30` varchar(317) DEFAULT NULL,
214
  `c31` varchar(192) DEFAULT NULL,
215
  `c32` varchar(0) DEFAULT NULL,
216
  `c33` varchar(3) DEFAULT NULL,
217
  `c34` varchar(3) DEFAULT NULL,
218
  `c35` varchar(3) DEFAULT NULL,
219
  `c36` varchar(3) DEFAULT NULL,
220
  `c37` varchar(10) DEFAULT NULL,
221
  `c38` varchar(10) DEFAULT NULL
942.3.1 by Vladimir Kolesnikov
test generalizations
222
) ENGINE=DEFAULT
1 by brian
clean slate
223
drop table t1;
224
select 
225
case 'str' when 'STR' then 'str' when null then 'null' end as c01,
226
case 'str' when null then 'null' when 'STR' then 'str' end as c02,
227
field(null, 'str1', 'str2') as c03,
228
field('str1','STR1', null) as c04,
229
field('str1', null, 'STR1') as c05,
230
'string' in ('STRING', null) as c08,
231
'string' in (null, 'STRING') as c09;
232
c01	c02	c03	c04	c05	c08	c09
233
str	str	0	1	2	1	1
234
# End of 4.1 tests
235
#
236
# Bug #31471: decimal_bin_size: Assertion `scale >= 0 &&
237
#             precision > 0 && scale <= precision'
238
#
685.4.1 by Jay Pipes
Enabled the null.test.
239
CREATE TABLE t1 (a DECIMAL (1, 0) , b DECIMAL (1, 0) );
1 by brian
clean slate
240
INSERT INTO t1 (a, b) VALUES (0, 0);
241
CREATE TABLE t2 SELECT IFNULL(a, b) FROM t1;
242
DESCRIBE t2;
1309.4.3 by Brian Aker
Refactor DESC to use new table.
243
Field	Type	Null	Default	Default_is_NULL	On_Update
1273.19.4 by Brian Aker
Updates for DESC.
244
IFNULL(a, b)	DECIMAL	TRUE		TRUE	
1 by brian
clean slate
245
DROP TABLE t2;
246
CREATE TABLE t2 SELECT IFNULL(a, NULL) FROM t1;
247
DESCRIBE t2;
1309.4.3 by Brian Aker
Refactor DESC to use new table.
248
Field	Type	Null	Default	Default_is_NULL	On_Update
1273.19.4 by Brian Aker
Updates for DESC.
249
IFNULL(a, NULL)	DECIMAL	TRUE		TRUE	
1 by brian
clean slate
250
DROP TABLE t2;
251
CREATE TABLE t2 SELECT IFNULL(NULL, b) FROM t1;
252
DESCRIBE t2;
1309.4.3 by Brian Aker
Refactor DESC to use new table.
253
Field	Type	Null	Default	Default_is_NULL	On_Update
1273.19.4 by Brian Aker
Updates for DESC.
254
IFNULL(NULL, b)	DECIMAL	TRUE		TRUE	
1 by brian
clean slate
255
DROP TABLE t1, t2;
256
# End of 5.0 tests