You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
sequence tests verify that one cannot change the structure
of the table. for that they need a valid alter table that
adds an index over an existing column. there's no column 'start'
in the table
Copy file name to clipboardExpand all lines: mysql-test/main/null.result
+41-9Lines changed: 41 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,6 @@
1
-
drop table if exists t1, t2;
1
+
#
2
+
# Testing of NULL in a lot of different places
3
+
#
2
4
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
5
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
6
NULL NULL 1 1 1 1 TRUE TRUE 1 1
@@ -62,6 +64,9 @@ insert into t1 values (null);
62
64
select * from t1 where x != 0;
63
65
x
64
66
drop table t1;
67
+
#
68
+
# Test problem med index on NULL columns and testing with =NULL;
69
+
#
65
70
CREATE TABLE t1 (
66
71
indexed_field int default NULL,
67
72
KEY indexed_field (indexed_field)
@@ -78,6 +83,9 @@ indexed_field
78
83
NULL
79
84
NULL
80
85
DROP TABLE t1;
86
+
#
87
+
# Testing of IFNULL
88
+
#
81
89
create table t1 (a int, b int) engine=myisam;
82
90
insert into t1 values(20,null);
83
91
select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on
@@ -95,6 +103,9 @@ b ifnull(t2.b,"this is null")
95
103
NULL this is null
96
104
NULL this is null
97
105
drop table t1;
106
+
#
107
+
# Test inserting and updating with NULL
108
+
#
98
109
CREATE TABLE t1 (a varchar(16) NOT NULL default '', b smallint(6) NOT NULL default 0, c datetime NOT NULL default '0000-00-00 00:00:00', d smallint(6) NOT NULL default 0);
99
110
INSERT IGNORE INTO t1 SET a = "", d= "2003-01-14 03:54:55";
100
111
Warnings:
@@ -149,6 +160,10 @@ a b c d
149
160
0 0000-00-00 00:00:00 0
150
161
0 0000-00-00 00:00:00 0
151
162
drop table t1;
163
+
#
164
+
# Test to check elimination of IS NULL predicate for a non-nullable attribute
165
+
# (bug #1990)
166
+
#
152
167
create table t1 (a int not null, b int not null, index idx(a));
153
168
insert into t1 values
154
169
(1,1), (2,2), (3,3), (4,4), (5,5), (6,6),
@@ -163,6 +178,10 @@ drop table t1;
163
178
select cast(NULL as signed);
164
179
cast(NULL as signed)
165
180
NULL
181
+
#
182
+
# IS NULL is unable to use index in range if column is declared not null
183
+
# (Bug #4256)
184
+
#
166
185
create table t1(i int, key(i));
167
186
insert into t1 values(1);
168
187
insert into t1 select i*2 from t1;
@@ -192,6 +211,11 @@ select count(*) from t1 where i=2 or i is null;
192
211
count(*)
193
212
9
194
213
drop table t1;
214
+
#
215
+
# NULL has its own type BINARY(0) by default.
216
+
# But NULL should be weaker than a constant
217
+
# when mixing charsets/collations
218
+
#
195
219
set names latin2;
196
220
create table t1 select
197
221
null as c00,
@@ -275,6 +299,11 @@ t1 CREATE TABLE `t1` (
275
299
`c38` varchar(10) CHARACTER SET latin2 DEFAULT NULL
276
300
) ENGINE=MyISAM DEFAULT CHARSET=latin1
277
301
drop table t1;
302
+
#
303
+
# Check that comparison is done according to
304
+
# non-null string collation, i.e. case insensitively,
305
+
# rather than according to NULL's collation, i.e. case sensitively
306
+
#
278
307
select
279
308
case 'str' when 'STR' then 'str' when null then 'null' end as c01,
280
309
case 'str' when null then 'null' when 'STR' then 'str' end as c02,
@@ -286,10 +315,13 @@ field('str1', null, 'STR1') as c05,
286
315
c01 c02 c03 c04 c05 c08 c09
287
316
str str 0 1 2 1 1
288
317
set names latin1;
289
-
create table bug19145a (e enum('a','b','c') default 'b' , s set('x', 'y', 'z') default 'y' ) engine=MyISAM;
290
-
create table bug19145b (e enum('a','b','c') default null, s set('x', 'y', 'z') default null) engine=MyISAM;
318
+
#
319
+
# Bug#19145: mysqld crashes if you set the default value of an enum field to NULL
320
+
#
321
+
create table bug19145a (e enum('a','b','c') default 'b' , s set('x', 'y', 'z') default 'y' ) engine=MyISAM;
322
+
create table bug19145b (e enum('a','b','c') default null, s set('x', 'y', 'z') default null) engine=MyISAM;
291
323
create table bug19145c (e enum('a','b','c') not null default 'b' , s set('x', 'y', 'z') not null default 'y' ) engine=MyISAM;
292
-
create table bug19145setnotnulldefaultnull (e enum('a','b','c') default null, s set('x', 'y', 'z') not null default null) engine=MyISAM;
324
+
create table bug19145setnotnulldefaultnull (e enum('a','b','c') default null, s set('x', 'y', 'z') not null default null) engine=MyISAM;
293
325
ERROR 42000: Invalid default value for 's'
294
326
create table bug19145enumnotnulldefaultnull (e enum('a','b','c') not null default null, s set('x', 'y', 'z') default null) engine=MyISAM;
Copy file name to clipboardExpand all lines: mysql-test/main/null.test
+53-60Lines changed: 53 additions & 60 deletions
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,6 @@
1
-
# Initialise
2
-
--disable_warnings
3
-
drop table if exists t1, t2;
4
-
--enable_warnings
5
-
6
-
#
7
-
# Testing of NULL in a lot of different places
8
-
#
1
+
--echo #
2
+
--echo # Testing of NULL in a lot of different places
3
+
--echo #
9
4
10
5
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;
11
6
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;
@@ -29,9 +24,9 @@ insert into t1 values (null);
29
24
select * from t1 where x != 0;
30
25
drop table t1;
31
26
32
-
#
33
-
# Test problem med index on NULL columns and testing with =NULL;
34
-
#
27
+
--echo #
28
+
--echo # Test problem med index on NULL columns and testing with =NULL;
29
+
--echo #
35
30
36
31
CREATE TABLE t1 (
37
32
indexed_field int default NULL,
@@ -43,9 +38,9 @@ SELECT * FROM t1 WHERE indexed_field IS NULL;
43
38
SELECT * FROM t1 WHERE indexed_field<=>NULL;
44
39
DROP TABLE t1;
45
40
46
-
#
47
-
# Testing of IFNULL
48
-
#
41
+
--echo #
42
+
--echo # Testing of IFNULL
43
+
--echo #
49
44
create table t1 (a int, b int) engine=myisam;
50
45
insert into t1 values(20,null);
51
46
select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on
@@ -57,40 +52,40 @@ select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on
57
52
t2.b=t3.a order by 1;
58
53
drop table t1;
59
54
60
-
#
61
-
# Test inserting and updating with NULL
62
-
#
55
+
--echo #
56
+
--echo # Test inserting and updating with NULL
57
+
--echo #
63
58
CREATE TABLE t1 (a varchar(16) NOT NULL default '', b smallint(6) NOT NULL default 0, c datetime NOT NULL default '0000-00-00 00:00:00', d smallint(6) NOT NULL default 0);
64
59
INSERT IGNORE INTO t1 SET a = "", d= "2003-01-14 03:54:55";
65
60
UPDATE IGNORE t1 SET d=1/NULL;
66
61
UPDATE IGNORE t1 SET d=NULL;
67
-
--error 1048
62
+
--error ER_BAD_NULL_ERROR
68
63
INSERT INTO t1 (a) values (null);
69
-
--error 1048
64
+
--error ER_BAD_NULL_ERROR
70
65
INSERT INTO t1 (a) values (1/null);
71
66
INSERT IGNORE INTO t1 (a) values (null),(null);
72
-
--error 1048
67
+
--error ER_BAD_NULL_ERROR
73
68
INSERT INTO t1 (b) values (null);
74
-
--error 1048
69
+
--error ER_BAD_NULL_ERROR
75
70
INSERT INTO t1 (b) values (1/null);
76
71
INSERT IGNORE INTO t1 (b) values (null),(null);
77
-
--error 1048
72
+
--error ER_BAD_NULL_ERROR
78
73
INSERT INTO t1 (c) values (null);
79
-
--error 1048
74
+
--error ER_BAD_NULL_ERROR
80
75
INSERT INTO t1 (c) values (1/null);
81
76
INSERT IGNORE INTO t1 (c) values (null),(null);
82
-
--error 1048
77
+
--error ER_BAD_NULL_ERROR
83
78
INSERT INTO t1 (d) values (null);
84
-
--error 1048
79
+
--error ER_BAD_NULL_ERROR
85
80
INSERT INTO t1 (d) values (1/null);
86
81
INSERT IGNORE INTO t1 (d) values (null),(null);
87
82
select * from t1;
88
83
drop table t1;
89
84
90
-
#
91
-
# Test to check elimination of IS NULL predicate for a non-nullable attribute
92
-
# (bug #1990)
93
-
#
85
+
--echo #
86
+
--echo # Test to check elimination of IS NULL predicate for a non-nullable attribute
87
+
--echo # (bug #1990)
88
+
--echo #
94
89
create table t1 (a int not null, b int not null, index idx(a));
95
90
insert into t1 values
96
91
(1,1), (2,2), (3,3), (4,4), (5,5), (6,6),
@@ -100,10 +95,10 @@ explain select * from t1 where a between 2 and 3 or b is null;
100
95
drop table t1;
101
96
select cast(NULL as signed);
102
97
103
-
#
104
-
# IS NULL is unable to use index in range if column is declared not null
105
-
# (Bug #4256)
106
-
#
98
+
--echo #
99
+
--echo # IS NULL is unable to use index in range if column is declared not null
100
+
--echo # (Bug #4256)
101
+
--echo #
107
102
create table t1(i int, key(i));
108
103
insert into t1 values(1);
109
104
insert into t1 select i*2 from t1;
@@ -124,11 +119,11 @@ explain select * from t1 where i=2 or i is null;
124
119
select count(*) from t1 where i=2 or i is null;
125
120
drop table t1;
126
121
127
-
#
128
-
# NULL has its own type BINARY(0) by default.
129
-
# But NULL should be weaker than a constant
130
-
# when mixing charsets/collations
131
-
#
122
+
--echo #
123
+
--echo # NULL has its own type BINARY(0) by default.
124
+
--echo # But NULL should be weaker than a constant
125
+
--echo # when mixing charsets/collations
126
+
--echo #
132
127
set names latin2;
133
128
# Check that result type is taken from a non-null string
134
129
create table t1 select
@@ -174,11 +169,11 @@ create table t1 select
174
169
show create table t1;
175
170
drop table t1;
176
171
177
-
#
178
-
# Check that comparison is done according to
179
-
# non-null string collation, i.e. case insensitively,
180
-
# rather than according to NULL's collation, i.e. case sensitively
181
-
#
172
+
--echo #
173
+
--echo # Check that comparison is done according to
174
+
--echo # non-null string collation, i.e. case insensitively,
175
+
--echo # rather than according to NULL's collation, i.e. case sensitively
176
+
--echo #
182
177
# in field
183
178
select
184
179
case 'str' when 'STR' then 'str' when null then 'null' end as c01,
@@ -192,20 +187,20 @@ select
192
187
# Restore charset to the default value.
193
188
set names latin1;
194
189
195
-
#
196
-
# Bug#19145: mysqld crashes if you set the default value of an enum field to NULL
197
-
#
198
-
create table bug19145a (e enum('a','b','c') default 'b' , s set('x', 'y', 'z') default 'y' ) engine=MyISAM;
199
-
create table bug19145b (e enum('a','b','c') default null, s set('x', 'y', 'z') default null) engine=MyISAM;
190
+
--echo #
191
+
--echo # Bug#19145: mysqld crashes if you set the default value of an enum field to NULL
192
+
--echo #
193
+
create table bug19145a (e enum('a','b','c') default 'b' , s set('x', 'y', 'z') default 'y' ) engine=MyISAM;
194
+
create table bug19145b (e enum('a','b','c') default null, s set('x', 'y', 'z') default null) engine=MyISAM;
200
195
201
196
create table bug19145c (e enum('a','b','c') not null default 'b' , s set('x', 'y', 'z') not null default 'y' ) engine=MyISAM;
202
197
203
198
# Invalid default value for 's'
204
-
--error 1067
205
-
create table bug19145setnotnulldefaultnull (e enum('a','b','c') default null, s set('x', 'y', 'z') not null default null) engine=MyISAM;
199
+
--error ER_INVALID_DEFAULT
200
+
create table bug19145setnotnulldefaultnull (e enum('a','b','c') default null, s set('x', 'y', 'z') not null default null) engine=MyISAM;
206
201
207
202
# Invalid default value for 'e'
208
-
--error 1067
203
+
--error ER_INVALID_DEFAULT
209
204
create table bug19145enumnotnulldefaultnull (e enum('a','b','c') not null default null, s set('x', 'y', 'z') default null) engine=MyISAM;
210
205
211
206
alter table bug19145a alter column e set default null;
@@ -217,11 +212,11 @@ alter table bug19145b alter column s set default null;
217
212
alter table bug19145b add column (i int);
218
213
219
214
# Invalid default value for 'e'
220
-
--error 1067
215
+
--error ER_INVALID_DEFAULT
221
216
alter table bug19145c alter column e set default null;
222
217
223
218
# Invalid default value for 's'
224
-
--error 1067
219
+
--error ER_INVALID_DEFAULT
225
220
alter table bug19145c alter column s set default null;
0 commit comments