Bug #96211 | insert valid datetime to timestamp column stop working, zero datetime error | ||
---|---|---|---|
Submitted: | 16 Jul 2019 0:38 | Modified: | 17 Jul 2019 14:35 |
Reporter: | saeed parsaee | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server: Data Types | Severity: | S2 (Serious) |
Version: | Server version: 8.0.16 MySQL Community S | OS: | CentOS (CentOS release 6.10 (Final)) |
Assigned to: | MySQL Verification Team | CPU Architecture: | Any (Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz) |
Tags: | 0000-00-00 00:00:00, ERROR 1525, timestamp, zero date |
[16 Jul 2019 0:38]
saeed parsaee
[16 Jul 2019 0:48]
saeed parsaee
yum update log that i think cause the problem
Attachment: yumlog.txt (text/plain), 10.32 KiB.
[16 Jul 2019 0:57]
saeed parsaee
table structure
Attachment: table structure.txt (text/plain), 3.28 KiB.
[16 Jul 2019 22:56]
saeed parsaee
Dear Bogdan, I found the cause, It seems that yum update had updated mysql and i think there is some new roles added foe comparing datetime values, however i think the error thrown is completely irrelevant, i had a trigger on my table which check some parameter and also check if created_at column is equal to '0000-00-00 00:00:00' then change it to current_timestamp. part of trigger is =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-= IF(NEW.created_at = '0000-00-00 00:00:00') THEN SET NEW.created_at = current_timestamp(); END IF =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-= its just a compare and the result should be true or false, and should not throw Incorrect datetime value: '0000-00-00 00:00:00' for column 'created_at' at row 1 .................................................... In short i think comparing a datetime like '2019-07-15 22:22:47' to '0000-00-00 00:00:00' should not throw exception and it just should return true/false.
[17 Jul 2019 14:35]
MySQL Verification Team
Hi, This is not a bug. If you configure mysql to not accept invalid dates you cannot compare a date to an invalid one and error will be thrown. If the mysql is configured to not accept invalid dates that comparison is not needed (it will always fail) and should check if field is null to setup value and not if field is '000...' ... So, you either configure mysql to allow invalid dates or configure mysql to not allow invalid dates and change that trigger. Thanks Bogdan