Bug #84088 how operate null value in MySQL?
Submitted: 7 Dec 2016 8:24 Modified: 12 Dec 2016 12:34
Reporter: chong ge Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: DML Severity:S3 (Non-critical)
Version:5.6.29-log, 5.6.34, 5.5.53 OS:Linux (CentOS6.5)
Assigned to: CPU Architecture:Any
Tags: 5.6.23-log, 5.6.29-log, null

[7 Dec 2016 8:24] chong ge
Description:
I get a different timestamp value about null in the same environment!

How to repeat:
mysql> select version() \G
*************************** 1. row ***************************
version(): 5.7.12-log
1 row in set (0.00 sec)

mysql> create table tab1(name varchar(8) default null) engine = innodb default charset=utf8;
Query OK, 0 rows affected (0.01 sec)

mysql> create table tab2(name varchar(8) default 'test') engine = innodb default charset=utf8;
Query OK, 0 rows affected (0.02 sec)

mysql> insert into tab1 values(null);
Query OK, 1 row affected (0.00 sec)

mysql> insert into tab2 values(null);
Query OK, 1 row affected (0.00 sec)

mysql> update tab1 set name=null;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1  Changed: 0  Warnings: 0

mysql> update tab2 set name=null;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1  Changed: 0  Warnings: 0

mysql> create table tab_timestamp1(name varchar(8) default null,gmt_modify timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP)engine = innodb default charset=utf8;
Query OK, 0 rows affected (0.01 sec)

mysql> create table tab_timestamp2(name varchar(8) default 'test',gmt_modify timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP)engine = innodb default charset=utf8;
Query OK, 0 rows affected (0.01 sec)

mysql> insert into tab_timestamp1 values(null,now());
Query OK, 1 row affected (0.00 sec)

mysql> insert into tab_timestamp2 values(null,now());
Query OK, 1 row affected (0.01 sec)

mysql> update tab_timestamp1 set name = null;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1  Changed: 0  Warnings: 0

mysql> update tab_timestamp2 set name = null;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

Suggested fix:
I get a different timestamp value about null in the same environment!
[12 Dec 2016 12:34] MySQL Verification Team
Hello Chong ge,

Thank you for the report and test case.

Thanks,
Umesh