Bug #107096 Conflicting statements re NULL and TIMESTAMP
Submitted: 22 Apr 9:17 Modified: 25 Apr 19:32
Reporter: hanzhong zhang Email Updates:
Status: Closed Impact on me:
Category:MySQL Server: Documentation Severity:S2 (Serious)
Version:ALL OS:Any (CentOS Linux release 7.9.2009 (Core) 3.10.0-1160.el7.x86_64)
Assigned to: Jon Stephens CPU Architecture:Any ( Intel(R) Xeon(R) Silver 4210 CPU @ 2.20GHz)
Tags: null, timestamp

[22 Apr 9:17] hanzhong zhang
In https://dev.mysql.com/doc/refman/5.7/en/problems-with-null.html ,The last line says " If you insert NULL into a TIMESTAMP column, the current date and time is inserted."

but the fact is "If you insert NULL into a TIMESTAMP column, the NULL is inserted."

How to repeat:
root@CentOS 16:58:  [test]>  create table test_null(id int auto_increment primary key ,`expire_at` timestamp NULL DEFAULT NULL COMMENT '具体失效时间',`expire_at_test` timestamp  COMMENT '具体失效时间')
    -> ;
Query OK, 0 rows affected (0.11 sec)

root@CentOS 16:59:  [test]> insert into test_null values(NULL,NULL,NULL);
Query OK, 1 row affected (0.02 sec)

root@CentOS 16:59:  [test]> select * from test_null;
| id | expire_at | expire_at_test |
|  1 | NULL      | NULL           |
1 row in set (0.00 sec)

Suggested fix:
Please update the official documents as soon as possible. Don't mislead people's children and attack the enthusiasm of beginners.
[22 Apr 13:04] MySQL Verification Team
Hello hanzhong zhang,

Thank you for the report and feedback.

[25 Apr 19:32] Jon Stephens

The exact behaviour of NULL + TIMESTAMP is dependent on a number of factors, including the server SQL mode and the value of the explicit_defaults_for_timestamp system variable (note the default value changes from OFF in 5.7 to ON in MySQL 8.0).

I have updated this item in all versions of the Manual to make this clearer. Thanks for pointing this out!