[Maria-developers] Please review MDEV-10802 TIMESTAMP NOT NULL field with explicit_defaults_for_timestamp and NO_ZERO_DATE shouldn't throw error

Hi, Alexander! On Oct 07, Alexander Barkov wrote:
Why is it inside if()? 1. if you want it to run only when @@explicit_defaults_for_timestamp is set, you should put it directly into explicit_defaults_for_timestamp_on.test. 2. But it's better to run this test for either value of @@explicit_defaults_for_timestamp, so it rightfully belongs into this .inc file, but not inside if().
why opt_explicit_defaults_for_timestamp is relevant here?
Regards, Sergei Chief Architect MariaDB and security@mariadb.org

Hello Sergei, Thanks for review. Please find a modified version attached. See comments below. On 10/13/2017 02:08 PM, Sergei Golubchik wrote:
I used examples from the beginning of this file: if (`SELECT @@explicit_defaults_for_timestamp=0`) { --error ER_INVALID_DEFAULT CREATE TABLE t1 (a TIMESTAMP DEFAULT NULL); } if (`SELECT @@explicit_defaults_for_timestamp=1`) { CREATE TABLE t1 (a TIMESTAMP DEFAULT NULL); SHOW CREATE TABLE t1; DROP TABLE t1; } But it's indeed better to have it outside of "if". Fixed.
When explicit-defaults-for-timestamp is 0, this script: SET sql_mode=NO_ZERO_DATE; DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a TIMESTAMP NOT NULL, b TIMESTAMP NOT NULL); is considered to be equal to: SET sql_mode=NO_ZERO_DATE; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( a TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, b TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00' ); Therefore both scripts should return this error: ERROR 1067 (42000): Invalid default value for 'b' When explicit-defaults-for-timestamp is 1, then the first script should not return any errors errors.
participants (2)
-
Alexander Barkov
-
Sergei Golubchik