Skip to content

Commit 4ce1470

Browse files
vuvovasanja-byelkin
authored andcommitted
cleanup: tests
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
1 parent 1c19284 commit 4ce1470

File tree

7 files changed

+101
-76
lines changed

7 files changed

+101
-76
lines changed

mysql-test/main/alter_table.test

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -647,11 +647,11 @@ set sql_mode="no_zero_date";
647647
create table t1(f1 int);
648648
alter table t1 add column f2 datetime not null, add column f21 date not null;
649649
insert into t1 values(1,'2000-01-01','2000-01-01');
650-
--error 1292
650+
--error ER_TRUNCATED_WRONG_VALUE
651651
alter table t1 add column f3 datetime not null;
652-
--error 1292
652+
--error ER_TRUNCATED_WRONG_VALUE
653653
alter table t1 add column f3 date not null;
654-
--error 1292
654+
--error ER_TRUNCATED_WRONG_VALUE
655655
alter table t1 add column f4 datetime not null default '2002-02-02',
656656
add column f41 date not null;
657657
alter table t1 add column f4 datetime not null default '2002-02-02',

mysql-test/main/null.result

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff 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+
#
24
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;
35
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
46
NULL NULL 1 1 1 1 TRUE TRUE 1 1
@@ -62,6 +64,9 @@ insert into t1 values (null);
6264
select * from t1 where x != 0;
6365
x
6466
drop table t1;
67+
#
68+
# Test problem med index on NULL columns and testing with =NULL;
69+
#
6570
CREATE TABLE t1 (
6671
indexed_field int default NULL,
6772
KEY indexed_field (indexed_field)
@@ -78,6 +83,9 @@ indexed_field
7883
NULL
7984
NULL
8085
DROP TABLE t1;
86+
#
87+
# Testing of IFNULL
88+
#
8189
create table t1 (a int, b int) engine=myisam;
8290
insert into t1 values(20,null);
8391
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")
95103
NULL this is null
96104
NULL this is null
97105
drop table t1;
106+
#
107+
# Test inserting and updating with NULL
108+
#
98109
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);
99110
INSERT IGNORE INTO t1 SET a = "", d= "2003-01-14 03:54:55";
100111
Warnings:
@@ -149,6 +160,10 @@ a b c d
149160
0 0000-00-00 00:00:00 0
150161
0 0000-00-00 00:00:00 0
151162
drop table t1;
163+
#
164+
# Test to check elimination of IS NULL predicate for a non-nullable attribute
165+
# (bug #1990)
166+
#
152167
create table t1 (a int not null, b int not null, index idx(a));
153168
insert into t1 values
154169
(1,1), (2,2), (3,3), (4,4), (5,5), (6,6),
@@ -163,6 +178,10 @@ drop table t1;
163178
select cast(NULL as signed);
164179
cast(NULL as signed)
165180
NULL
181+
#
182+
# IS NULL is unable to use index in range if column is declared not null
183+
# (Bug #4256)
184+
#
166185
create table t1(i int, key(i));
167186
insert into t1 values(1);
168187
insert into t1 select i*2 from t1;
@@ -192,6 +211,11 @@ select count(*) from t1 where i=2 or i is null;
192211
count(*)
193212
9
194213
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+
#
195219
set names latin2;
196220
create table t1 select
197221
null as c00,
@@ -275,6 +299,11 @@ t1 CREATE TABLE `t1` (
275299
`c38` varchar(10) CHARACTER SET latin2 DEFAULT NULL
276300
) ENGINE=MyISAM DEFAULT CHARSET=latin1
277301
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+
#
278307
select
279308
case 'str' when 'STR' then 'str' when null then 'null' end as c01,
280309
case 'str' when null then 'null' when 'STR' then 'str' end as c02,
@@ -286,10 +315,13 @@ field('str1', null, 'STR1') as c05,
286315
c01 c02 c03 c04 c05 c08 c09
287316
str str 0 1 2 1 1
288317
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;
291323
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;
293325
ERROR 42000: Invalid default value for 's'
294326
create table bug19145enumnotnulldefaultnull (e enum('a','b','c') not null default null, s set('x', 'y', 'z') default null) engine=MyISAM;
295327
ERROR 42000: Invalid default value for 'e'
@@ -328,8 +360,10 @@ bug19145c CREATE TABLE `bug19145c` (
328360
drop table bug19145a;
329361
drop table bug19145b;
330362
drop table bug19145c;
363+
#
331364
# End of 4.1 tests
332365
#
366+
#
333367
# Bug #31471: decimal_bin_size: Assertion `scale >= 0 &&
334368
# precision > 0 && scale <= precision'
335369
#
@@ -350,8 +384,10 @@ DESCRIBE t2;
350384
Field Type Null Key Default Extra
351385
IFNULL(NULL, b) decimal(1,0) YES NULL
352386
DROP TABLE t1, t2;
387+
#
353388
# End of 5.0 tests
354389
#
390+
#
355391
# MDEV-4895 Valgrind warnings (Conditional jump or move depends on uninitialised value) in Field_datetime::get_date on GREATEST(..) IS NULL
356392
#
357393
CREATE TABLE t1 (dt DATETIME NOT NULL);
@@ -382,18 +418,14 @@ SELECT * FROM t1 WHERE NOT (concat( dt, '1' ) IS NOT NULL);
382418
dt
383419
DROP TABLE t1;
384420
#
385-
# Bug mdev-5132: crash when exeicuting a join query
386-
# with IS NULL and IS NOT NULL in where
421+
# MDEV-5132 crash when exeicuting a join query with IS NULL and IS NOT NULL in where
387422
#
388423
CREATE TABLE t1 (a DATE, b INT, c INT, KEY(a), KEY(b), KEY(c)) ENGINE=MyISAM;
389424
CREATE TABLE t2 (d DATE) ENGINE=MyISAM;
390425
SELECT * FROM t1,t2 WHERE 1 IS NOT NULL AND t1.b IS NULL;
391426
a b c d
392427
DROP TABLE t1,t2;
393428
#
394-
# Start of 10.0 tests
395-
#
396-
#
397429
# MDEV-7001 Bad result for NOT NOT STRCMP('a','b') and NOT NOT NULLIF(2,3)
398430
#
399431
SELECT NOT NOT NULLIF(2,3);

mysql-test/main/null.test

Lines changed: 53 additions & 60 deletions
Original file line numberDiff line numberDiff 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 #
94

105
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;
116
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);
2924
select * from t1 where x != 0;
3025
drop table t1;
3126

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 #
3530

3631
CREATE TABLE t1 (
3732
indexed_field int default NULL,
@@ -43,9 +38,9 @@ SELECT * FROM t1 WHERE indexed_field IS NULL;
4338
SELECT * FROM t1 WHERE indexed_field<=>NULL;
4439
DROP TABLE t1;
4540

46-
#
47-
# Testing of IFNULL
48-
#
41+
--echo #
42+
--echo # Testing of IFNULL
43+
--echo #
4944
create table t1 (a int, b int) engine=myisam;
5045
insert into t1 values(20,null);
5146
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
5752
t2.b=t3.a order by 1;
5853
drop table t1;
5954

60-
#
61-
# Test inserting and updating with NULL
62-
#
55+
--echo #
56+
--echo # Test inserting and updating with NULL
57+
--echo #
6358
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);
6459
INSERT IGNORE INTO t1 SET a = "", d= "2003-01-14 03:54:55";
6560
UPDATE IGNORE t1 SET d=1/NULL;
6661
UPDATE IGNORE t1 SET d=NULL;
67-
--error 1048
62+
--error ER_BAD_NULL_ERROR
6863
INSERT INTO t1 (a) values (null);
69-
--error 1048
64+
--error ER_BAD_NULL_ERROR
7065
INSERT INTO t1 (a) values (1/null);
7166
INSERT IGNORE INTO t1 (a) values (null),(null);
72-
--error 1048
67+
--error ER_BAD_NULL_ERROR
7368
INSERT INTO t1 (b) values (null);
74-
--error 1048
69+
--error ER_BAD_NULL_ERROR
7570
INSERT INTO t1 (b) values (1/null);
7671
INSERT IGNORE INTO t1 (b) values (null),(null);
77-
--error 1048
72+
--error ER_BAD_NULL_ERROR
7873
INSERT INTO t1 (c) values (null);
79-
--error 1048
74+
--error ER_BAD_NULL_ERROR
8075
INSERT INTO t1 (c) values (1/null);
8176
INSERT IGNORE INTO t1 (c) values (null),(null);
82-
--error 1048
77+
--error ER_BAD_NULL_ERROR
8378
INSERT INTO t1 (d) values (null);
84-
--error 1048
79+
--error ER_BAD_NULL_ERROR
8580
INSERT INTO t1 (d) values (1/null);
8681
INSERT IGNORE INTO t1 (d) values (null),(null);
8782
select * from t1;
8883
drop table t1;
8984

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 #
9489
create table t1 (a int not null, b int not null, index idx(a));
9590
insert into t1 values
9691
(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;
10095
drop table t1;
10196
select cast(NULL as signed);
10297

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 #
107102
create table t1(i int, key(i));
108103
insert into t1 values(1);
109104
insert into t1 select i*2 from t1;
@@ -124,11 +119,11 @@ explain select * from t1 where i=2 or i is null;
124119
select count(*) from t1 where i=2 or i is null;
125120
drop table t1;
126121

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 #
132127
set names latin2;
133128
# Check that result type is taken from a non-null string
134129
create table t1 select
@@ -174,11 +169,11 @@ create table t1 select
174169
show create table t1;
175170
drop table t1;
176171

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 #
182177
# in field
183178
select
184179
case 'str' when 'STR' then 'str' when null then 'null' end as c01,
@@ -192,20 +187,20 @@ select
192187
# Restore charset to the default value.
193188
set names latin1;
194189

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;
200195

201196
create table bug19145c (e enum('a','b','c') not null default 'b' , s set('x', 'y', 'z') not null default 'y' ) engine=MyISAM;
202197

203198
# 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;
206201

207202
# Invalid default value for 'e'
208-
--error 1067
203+
--error ER_INVALID_DEFAULT
209204
create table bug19145enumnotnulldefaultnull (e enum('a','b','c') not null default null, s set('x', 'y', 'z') default null) engine=MyISAM;
210205

211206
alter table bug19145a alter column e set default null;
@@ -217,11 +212,11 @@ alter table bug19145b alter column s set default null;
217212
alter table bug19145b add column (i int);
218213

219214
# Invalid default value for 'e'
220-
--error 1067
215+
--error ER_INVALID_DEFAULT
221216
alter table bug19145c alter column e set default null;
222217

223218
# Invalid default value for 's'
224-
--error 1067
219+
--error ER_INVALID_DEFAULT
225220
alter table bug19145c alter column s set default null;
226221
alter table bug19145c add column (i int);
227222

@@ -233,7 +228,9 @@ drop table bug19145a;
233228
drop table bug19145b;
234229
drop table bug19145c;
235230

231+
--echo #
236232
--echo # End of 4.1 tests
233+
--echo #
237234

238235
--echo #
239236
--echo # Bug #31471: decimal_bin_size: Assertion `scale >= 0 &&
@@ -256,7 +253,9 @@ DESCRIBE t2;
256253

257254
DROP TABLE t1, t2;
258255

256+
--echo #
259257
--echo # End of 5.0 tests
258+
--echo #
260259

261260
--echo #
262261
--echo # MDEV-4895 Valgrind warnings (Conditional jump or move depends on uninitialised value) in Field_datetime::get_date on GREATEST(..) IS NULL
@@ -287,8 +286,7 @@ SELECT * FROM t1 WHERE NOT (concat( dt, '1' ) IS NOT NULL);
287286
DROP TABLE t1;
288287

289288
--echo #
290-
--echo # Bug mdev-5132: crash when exeicuting a join query
291-
--echo # with IS NULL and IS NOT NULL in where
289+
--echo # MDEV-5132 crash when exeicuting a join query with IS NULL and IS NOT NULL in where
292290
--echo #
293291

294292
CREATE TABLE t1 (a DATE, b INT, c INT, KEY(a), KEY(b), KEY(c)) ENGINE=MyISAM;
@@ -298,10 +296,6 @@ SELECT * FROM t1,t2 WHERE 1 IS NOT NULL AND t1.b IS NULL;
298296

299297
DROP TABLE t1,t2;
300298

301-
--echo #
302-
--echo # Start of 10.0 tests
303-
--echo #
304-
305299
--echo #
306300
--echo # MDEV-7001 Bad result for NOT NOT STRCMP('a','b') and NOT NOT NULLIF(2,3)
307301
--echo #
@@ -1177,7 +1171,6 @@ SELECT * FROM t1 WHERE ((c1 IS NOT NULL) >= (NOT TRUE)) IS NOT NULL;
11771171
SELECT * FROM t1 WHERE ((c1 IS NOT NULL) >= (NOT TRUE)) IS NOT NULL;
11781172
DROP TABLE t1;
11791173

1180-
11811174
--echo #
11821175
--echo # End of 10.1 tests
11831176
--echo #

0 commit comments

Comments
 (0)