drop table if exists t1, t2; select 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; 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 NULL 1 1 1 1 TRUE TRUE 1 1 Warnings: Warning 1365 Division by 0 Warning 1365 Division by 0 Warning 1365 Division by 0 explain select 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; id select_type table partitions type possible_keys key key_len ref rows filtered Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: Warning 1365 Division by 0 Warning 1365 Division by 0 Warning 1365 Division by 0 Note 1003 /* select#1 */ select NULL AS `NULL`,(NULL is null) AS `isnull(null)`,((1 / 0) is null) AS `isnull(1/0)`,(((1 / 0) = NULL) is 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")`,((1 / 0) is null) AS `1/0 is null`,(1 is not null) AS `1 is not null` select 1 | NULL,1 & NULL,1+NULL,1-NULL; 1 | NULL 1 & NULL 1+NULL 1-NULL NULL NULL NULL NULL select NULL=NULL,NULL<>NULL,IFNULL(NULL,1.1)+0,IFNULL(NULL,1) | 0; NULL=NULL NULL<>NULL IFNULL(NULL,1.1)+0 IFNULL(NULL,1) | 0 NULL NULL 1.1 1 select strcmp("a",NULL),(1NULL; indexed_field NULL NULL DROP TABLE t1; create table t1 (a int, b int); insert into t1 values(20,null); select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on t2.b=t3.a; b ifnull(t2.b,"this is null") NULL this is null select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on t2.b=t3.a order by 1; b ifnull(t2.b,"this is null") NULL this is null insert into t1 values(10,null); select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on t2.b=t3.a order by 1; b ifnull(t2.b,"this is null") NULL this is null NULL this is null drop table t1; SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; 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); Warnings: Warning 1681 Integer display width is deprecated and will be removed in a future release. Warning 1681 Integer display width is deprecated and will be removed in a future release. INSERT INTO t1 SET a = "", d= "2003-01-14 03:54:55"; Warnings: Warning 1265 Data truncated for column 'd' at row 1 UPDATE t1 SET d=1/NULL; Warnings: Warning 1048 Column 'd' cannot be null UPDATE t1 SET d=NULL; Warnings: Warning 1048 Column 'd' cannot be null INSERT INTO t1 (a) values (null); ERROR 23000: Column 'a' cannot be null INSERT INTO t1 (a) values (1/null); ERROR 23000: Column 'a' cannot be null INSERT INTO t1 (a) values (null),(null); Warnings: Warning 1048 Column 'a' cannot be null INSERT INTO t1 (b) values (null); ERROR 23000: Column 'b' cannot be null INSERT INTO t1 (b) values (1/null); ERROR 23000: Column 'b' cannot be null INSERT INTO t1 (b) values (null),(null); Warnings: Warning 1048 Column 'b' cannot be null INSERT INTO t1 (c) values (null); ERROR 23000: Column 'c' cannot be null INSERT INTO t1 (c) values (1/null); ERROR 23000: Column 'c' cannot be null INSERT INTO t1 (c) values (null),(null); Warnings: Warning 1048 Column 'c' cannot be null INSERT INTO t1 (d) values (null); ERROR 23000: Column 'd' cannot be null INSERT INTO t1 (d) values (1/null); ERROR 23000: Column 'd' cannot be null INSERT INTO t1 (d) values (null),(null); Warnings: Warning 1048 Column 'd' cannot be null select * from t1; a b c d 0 0000-00-00 00:00:00 0 0 0000-00-00 00:00:00 0 0 0000-00-00 00:00:00 0 0 0000-00-00 00:00:00 0 0 0000-00-00 00:00:00 0 0 0000-00-00 00:00:00 0 0 0000-00-00 00:00:00 0 0 0000-00-00 00:00:00 0 0 0000-00-00 00:00:00 0 drop table t1; SET sql_mode = default; create table t1 (a int not null, b int not null, index idx(a)); insert into t1 values (1,1), (2,2), (3,3), (4,4), (5,5), (6,6), (7,7), (8,8), (9,9), (10,10), (11,11), (12,12); analyze table t1; Table Op Msg_type Msg_text test.t1 analyze status OK explain select * from t1 where a between 2 and 3; id select_type table partitions type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 NULL range idx idx 4 NULL 1 100.00 Using index condition Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` between 2 and 3) explain select * from t1 where a between 2 and 3 or b is null; id select_type table partitions type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 NULL range idx idx 4 NULL 1 100.00 Using index condition Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a` between 2 and 3) drop table t1; select cast(NULL as signed); cast(NULL as signed) NULL create table t1(i int, key(i)); insert into t1 values(1); insert into t1 select i*2 from t1; insert into t1 select i*2 from t1; insert into t1 select i*2 from t1; insert into t1 select i*2 from t1; insert into t1 select i*2 from t1; insert into t1 select i*2 from t1; insert into t1 select i*2 from t1; insert into t1 select i*2 from t1; insert into t1 select i*2 from t1; insert into t1 values(null); analyze table t1; Table Op Msg_type Msg_text test.t1 analyze status OK explain select * from t1 where i=2 or i is null; id select_type table partitions type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 NULL ref_or_null i i 5 const 2 100.00 Using where; Using index Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` where ((`test`.`t1`.`i` = 2) or (`test`.`t1`.`i` is null)) select count(*) from t1 where i=2 or i is null; count(*) 10 SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; alter table t1 change i i int not null; Warnings: Warning 1265 Data truncated for column 'i' at row 513 SET sql_mode = default; analyze table t1; Table Op Msg_type Msg_text test.t1 analyze status OK explain select * from t1 where i=2 or i is null; id select_type table partitions type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 NULL ref i i 4 const 1 100.00 Using index Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` where (`test`.`t1`.`i` = 2) select count(*) from t1 where i=2 or i is null; count(*) 9 drop table t1; set names latin2; create table t1 select null as c00, if(1, null, 'string') as c01, if(0, null, 'string') as c02, ifnull(null, 'string') as c03, ifnull('string', null) as c04, case when 0 then null else 'string' end as c05, case when 1 then null else 'string' end as c06, coalesce(null, 'string') as c07, coalesce('string', null) as c08, least('string',null) as c09, least(null, 'string') as c10, greatest('string',null) as c11, greatest(null, 'string') as c12, nullif('string', null) as c13, nullif(null, 'string') as c14, trim('string' from null) as c15, trim(null from 'string') as c16, substring_index('string', null, 1) as c17, substring_index(null, 'string', 1) as c18, elt(1, null, 'string') as c19, elt(1, 'string', null) as c20, concat('string', null) as c21, concat(null, 'string') as c22, concat_ws('sep', 'string', null) as c23, concat_ws('sep', null, 'string') as c24, concat_ws(null, 'string', 'string') as c25, make_set(3, 'string', null) as c26, make_set(3, null, 'string') as c27, export_set(3, null, 'off', 'sep') as c29, export_set(3, 'on', null, 'sep') as c30, export_set(3, 'on', 'off', null) as c31, replace(null, 'from', 'to') as c32, replace('str', null, 'to') as c33, replace('str', 'from', null) as c34, insert('str', 1, 2, null) as c35, insert(null, 1, 2, 'str') as c36, lpad('str', 10, null) as c37, rpad(null, 10, 'str') as c38; show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `c00` binary(0) DEFAULT NULL, `c01` varchar(6) CHARACTER SET latin2 DEFAULT NULL, `c02` varchar(6) CHARACTER SET latin2 DEFAULT NULL, `c03` varchar(6) CHARACTER SET latin2 NOT NULL DEFAULT '', `c04` varchar(6) CHARACTER SET latin2 NOT NULL DEFAULT '', `c05` varchar(6) CHARACTER SET latin2 DEFAULT NULL, `c06` varchar(6) CHARACTER SET latin2 DEFAULT NULL, `c07` varchar(6) CHARACTER SET latin2 NOT NULL DEFAULT '', `c08` varchar(6) CHARACTER SET latin2 NOT NULL DEFAULT '', `c09` varchar(6) CHARACTER SET latin2 DEFAULT NULL, `c10` varchar(6) CHARACTER SET latin2 DEFAULT NULL, `c11` varchar(6) CHARACTER SET latin2 DEFAULT NULL, `c12` varchar(6) CHARACTER SET latin2 DEFAULT NULL, `c13` varchar(6) CHARACTER SET latin2 DEFAULT NULL, `c14` char(0) CHARACTER SET latin2 DEFAULT NULL, `c15` char(0) CHARACTER SET latin2 DEFAULT NULL, `c16` varchar(6) CHARACTER SET latin2 DEFAULT NULL, `c17` varchar(6) CHARACTER SET latin2 DEFAULT NULL, `c18` char(0) CHARACTER SET latin2 DEFAULT NULL, `c19` varchar(6) CHARACTER SET latin2 DEFAULT NULL, `c20` varchar(6) CHARACTER SET latin2 DEFAULT NULL, `c21` varchar(6) CHARACTER SET latin2 DEFAULT NULL, `c22` varchar(6) CHARACTER SET latin2 DEFAULT NULL, `c23` varchar(9) CHARACTER SET latin2 DEFAULT NULL, `c24` varchar(9) CHARACTER SET latin2 DEFAULT NULL, `c25` varchar(12) CHARACTER SET latin2 DEFAULT NULL, `c26` varchar(7) CHARACTER SET latin2 DEFAULT NULL, `c27` varchar(7) CHARACTER SET latin2 DEFAULT NULL, `c29` varchar(381) CHARACTER SET latin2 DEFAULT NULL, `c30` varchar(317) CHARACTER SET latin2 DEFAULT NULL, `c31` varchar(192) CHARACTER SET latin2 DEFAULT NULL, `c32` char(0) CHARACTER SET latin2 DEFAULT NULL, `c33` varchar(3) CHARACTER SET latin2 DEFAULT NULL, `c34` varchar(3) CHARACTER SET latin2 DEFAULT NULL, `c35` varchar(3) CHARACTER SET latin2 DEFAULT NULL, `c36` varchar(3) CHARACTER SET latin2 DEFAULT NULL, `c37` varchar(10) CHARACTER SET latin2 DEFAULT NULL, `c38` varchar(10) CHARACTER SET latin2 DEFAULT NULL ) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci drop table t1; select case 'str' when 'STR' then 'str' when null then 'null' end as c01, case 'str' when null then 'null' when 'STR' then 'str' end as c02, field(null, 'str1', 'str2') as c03, field('str1','STR1', null) as c04, field('str1', null, 'STR1') as c05, 'string' in ('STRING', null) as c08, 'string' in (null, 'STRING') as c09; c01 c02 c03 c04 c05 c08 c09 str str 0 1 2 1 1 set names latin1; create table bug19145a (e enum('a','b','c') default 'b' , s set('x', 'y', 'z') default 'y' ); create table bug19145b (e enum('a','b','c') default null, s set('x', 'y', 'z') default null); create table bug19145c (e enum('a','b','c') not null default 'b' , s set('x', 'y', 'z') not null default 'y' ); create table bug19145setnotnulldefaultnull (e enum('a','b','c') default null, s set('x', 'y', 'z') not null default null); ERROR 42000: Invalid default value for 's' create table bug19145enumnotnulldefaultnull (e enum('a','b','c') not null default null, s set('x', 'y', 'z') default null); ERROR 42000: Invalid default value for 'e' alter table bug19145a alter column e set default null; alter table bug19145a alter column s set default null; alter table bug19145a add column (i int); alter table bug19145b alter column e set default null; alter table bug19145b alter column s set default null; alter table bug19145b add column (i int); alter table bug19145c alter column e set default null; ERROR 42000: Invalid default value for 'e' alter table bug19145c alter column s set default null; ERROR 42000: Invalid default value for 's' alter table bug19145c add column (i int); show create table bug19145a; Table Create Table bug19145a CREATE TABLE `bug19145a` ( `e` enum('a','b','c') COLLATE utf8mb4_general_ci DEFAULT NULL, `s` set('x','y','z') COLLATE utf8mb4_general_ci DEFAULT NULL, `i` int(11) DEFAULT NULL ) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci show create table bug19145b; Table Create Table bug19145b CREATE TABLE `bug19145b` ( `e` enum('a','b','c') COLLATE utf8mb4_general_ci DEFAULT NULL, `s` set('x','y','z') COLLATE utf8mb4_general_ci DEFAULT NULL, `i` int(11) DEFAULT NULL ) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci show create table bug19145c; Table Create Table bug19145c CREATE TABLE `bug19145c` ( `e` enum('a','b','c') COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'b', `s` set('x','y','z') COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'y', `i` int(11) DEFAULT NULL ) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci drop table bug19145a; drop table bug19145b; drop table bug19145c; # End of 4.1 tests # # Bug #31471: decimal_bin_size: Assertion `scale >= 0 && # precision > 0 && scale <= precision' # CREATE TABLE t1 (a DECIMAL (1, 0) ZEROFILL, b DECIMAL (1, 0) ZEROFILL); Warnings: Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. Warning 1681 The ZEROFILL attribute is deprecated and will be removed in a future release. Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column. INSERT INTO t1 (a, b) VALUES (0, 0); CREATE TABLE t2 SELECT IFNULL(a, b) FROM t1; Warnings: Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. DESCRIBE t2; Field Type Null Key Default Extra IFNULL(a, b) decimal(1,0) unsigned YES NULL DROP TABLE t2; CREATE TABLE t2 SELECT IFNULL(a, NULL) FROM t1; Warnings: Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. DESCRIBE t2; Field Type Null Key Default Extra IFNULL(a, NULL) decimal(1,0) unsigned YES NULL DROP TABLE t2; CREATE TABLE t2 SELECT IFNULL(NULL, b) FROM t1; Warnings: Warning 1681 UNSIGNED for decimal and floating point data types is deprecated and support for it will be removed in a future release. DESCRIBE t2; Field Type Null Key Default Extra IFNULL(NULL, b) decimal(1,0) unsigned YES NULL DROP TABLE t1, t2; # End of 5.0 tests # # WL#7247: Removal of \N # SELECT \N; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\N' at line 1