You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
WL#6292 - Make TIMESTAMP columns nullable by default.
This worklog implements new behavior for TIMESTAMP columns,
defined by CREATE TABLE, ALTER TABLE and CREATE SELECT commands.
This is in effort to make TIMESTAMP columns behavior to be
more closer to SQL standard. The change in behavior is as
described below,
Current behavior:
=================
1) Unlike all the other types, TIMESTAMP columns which are not
explicitly specified as NULLable automatically get NOT NULL
as attribute.
2) If the first TIMESTAMP column in table is not specified as
NULLable and doesn't have explicit DEFAULT or ON UPDATE
value specified it automatically gets DEFAULT NOW()
ON UPDATE NOW() as attributes.
3) All other TIMESTAMP columns which are not NULLable and
don't have explicit default specified get '0' as default
value and treated as having explicit default value after
that (i.e. if you don't provide explicit value for such
a column when inserting into table no warning or error
is emitted).
New behavior:
=============
1) TIMESTAMP columns which are not explicitly specified as
NOT NULL become NULLable.
2) No TIMESTAMP columns get DEFAULT NOW() or ON UPDATE NOW()
attributes automatically, without them being explicitly
specified.
3) Non-NULLable TIMESTAMP columns without explicit default
value treated as having no default value. I.e. warning
or error is emitted (depends on sql_mode) if we insert
a row without providing and explicit value for such a
column. In case when warning is emitted and not an
error such a column will still get '0' if no explicit
value was specified for it.
A new command line option '--explicit_defaults_for_timestamp'
is introduced for MySQL server to enable new behavior. The old
behavior is kept as default, so that the existing applications
assuming old semantics work without any changes.
Replication slave applier thread is extended with new interface,
such that the slave applies the logs with old behavior, if the
logs are generated by master with older version than slave.
MySQL system table definitions at scripts/* were updated,
such that they work fine with old and new behavior with
any change. MTR tests which use TIMESTAMP columns are also
updated, such that the test works both in old and new
behavior. This should help easy transition to new behavior
going forward.
This worklog addresses Bug#11762529 and Bug#13344629.
Copy file name to clipboardExpand all lines: mysql-test/include/mtr_warnings.sql
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -173,6 +173,8 @@ INSERT INTO global_suppressions VALUES
173
173
174
174
/*It will print a warning if a new UUID of server is generated.*/
175
175
("No existing UUID has been found, so we assume that this is the first time that this server has been started.*"),
176
+
/*It will print a warning if server is run without --explicit_defaults_for_timestamp.*/
177
+
("TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details)*"),
INSERT INTO t1 VALUES (200001,2,1,1,100,1,1,1,0,0,0,1,0,1,20020425060057,'\\\\ARKIVIO-TESTPDC\\E$',''),(200002,2,2,1,101,1,1,1,0,0,0,1,0,1,20020425060057,'\\\\ARKIVIO-TESTPDC\\C$',''),(200003,1,3,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,1,0,1,20020425060427,'c:',NULL);
Copy file name to clipboardExpand all lines: mysql-test/r/create.result
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -458,7 +458,7 @@ a b c d e f g h dd
458
458
1 -7 7 2000-01-01 b 2000-01-01 00:00:00 05:04:03 yet another binary data 02:00:00
459
459
2 -2 2 1825-12-14 a 2003-01-01 03:02:01 04:03:02 binary data 02:00:00
460
460
drop table t1, t2;
461
-
create table t1 (a tinyint, b smallint, c mediumint, d int, e bigint, f float(3,2), g double(4,3), h decimal(5,4), i year, j date, k timestamp, l datetime, m enum('a','b'), n set('a','b'), o char(10));
461
+
create table t1 (a tinyint, b smallint, c mediumint, d int, e bigint, f float(3,2), g double(4,3), h decimal(5,4), i year, j date, k timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, l datetime, m enum('a','b'), n set('a','b'), o char(10));
0 commit comments