diff --git a/mysql-test/main/type_timestamp.result b/mysql-test/main/type_timestamp.result index 09ba852e032..d69ebf736d2 100644 --- a/mysql-test/main/type_timestamp.result +++ b/mysql-test/main/type_timestamp.result @@ -1326,6 +1326,8 @@ SET timestamp=DEFAULT; # MDEV-29225 make explicit_defaults_for_timestamps SESSION variable # set explicit_defaults_for_timestamp=OFF; +Warnings: +Warning 1681 'explicit_defaults_for_timestamp=0' is deprecated and will be removed in a future release create table t1 (f1 timestamp, f2 timestamp); show create table t1; Table Create Table diff --git a/mysql-test/suite/rpl/r/rpl_old_master_29078.result b/mysql-test/suite/rpl/r/rpl_old_master_29078.result index bc7f188a48e..43d998048a0 100644 --- a/mysql-test/suite/rpl/r/rpl_old_master_29078.result +++ b/mysql-test/suite/rpl/r/rpl_old_master_29078.result @@ -48,6 +48,8 @@ ROLLBACK /* added by mysqlbinlog */; /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/; connection slave; set global explicit_defaults_for_timestamp=0; +Warnings: +Warning 1681 'explicit_defaults_for_timestamp=0' is deprecated and will be removed in a future release include/reset_slave.inc include/start_slave.inc show create table t1; diff --git a/mysql-test/suite/rpl/r/rpl_parallel_29322.result b/mysql-test/suite/rpl/r/rpl_parallel_29322.result index 752fb321225..2c0cb144027 100644 --- a/mysql-test/suite/rpl/r/rpl_parallel_29322.result +++ b/mysql-test/suite/rpl/r/rpl_parallel_29322.result @@ -10,6 +10,8 @@ set @@session.explicit_defaults_for_timestamp = 1; connection slave; set @sav.explicit_defaults_for_timestamp = @@global.explicit_defaults_for_timestamp; set global explicit_defaults_for_timestamp = 0; +Warnings: +Warning 1681 'explicit_defaults_for_timestamp=0' is deprecated and will be removed in a future release set @sav.slave_parallel_workers = @@global.slave_parallel_workers; include/stop_slave.inc set @@global.slave_parallel_workers = 1; @@ -105,6 +107,8 @@ connection slave; # B. alternate the master and slave vars' values to (0,1) connection master; set @@session.explicit_defaults_for_timestamp = 0; +Warnings: +Warning 1681 'explicit_defaults_for_timestamp=0' is deprecated and will be removed in a future release connection slave; set @@global.explicit_defaults_for_timestamp = 1; connection slave; diff --git a/mysql-test/suite/rpl/r/rpl_timestamp.result b/mysql-test/suite/rpl/r/rpl_timestamp.result index 31ffd1ed371..ff370d61d9f 100644 --- a/mysql-test/suite/rpl/r/rpl_timestamp.result +++ b/mysql-test/suite/rpl/r/rpl_timestamp.result @@ -2,6 +2,8 @@ include/master-slave.inc [connection master] set timestamp=1656940000; set explicit_defaults_for_timestamp=!@@explicit_defaults_for_timestamp; +Warnings: +Warning 1681 'explicit_defaults_for_timestamp=0' is deprecated and will be removed in a future release connection master; create table t1 (f1 timestamp, f2 timestamp); show create table t1; diff --git a/mysql-test/suite/sys_vars/inc/explicit_defaults_for_timestamp.inc b/mysql-test/suite/sys_vars/inc/explicit_defaults_for_timestamp.inc index 0cd8aa2c568..46acf4bac8a 100644 --- a/mysql-test/suite/sys_vars/inc/explicit_defaults_for_timestamp.inc +++ b/mysql-test/suite/sys_vars/inc/explicit_defaults_for_timestamp.inc @@ -105,7 +105,9 @@ SET timestamp=DEFAULT; --echo # --echo # MDEV-29075 Changing explicit_defaults_for_timestamp within stored procedure works inconsistently --echo # +--disable_warnings set statement explicit_defaults_for_timestamp=1-@@explicit_defaults_for_timestamp for create table t1 (ts timestamp); +--enable_warnings show create table t1; drop table t1; diff --git a/mysql-test/suite/sys_vars/r/explicit_defaults_for_timestamp_off.result b/mysql-test/suite/sys_vars/r/explicit_defaults_for_timestamp_off.result index 1d779352df5..a373e6aefca 100644 --- a/mysql-test/suite/sys_vars/r/explicit_defaults_for_timestamp_off.result +++ b/mysql-test/suite/sys_vars/r/explicit_defaults_for_timestamp_off.result @@ -1,4 +1,6 @@ set @@explicit_defaults_for_timestamp=0; +Warnings: +Warning 1681 'explicit_defaults_for_timestamp=0' is deprecated and will be removed in a future release CREATE TABLE t1 (a TIMESTAMP); SHOW CREATE TABLE t1; Table Create Table @@ -224,6 +226,8 @@ t1 CREATE TABLE `t1` ( `a` timestamp NULL DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci set explicit_defaults_for_timestamp=1-@@explicit_defaults_for_timestamp; +Warnings: +Warning 1681 'explicit_defaults_for_timestamp=0' is deprecated and will be removed in a future release execute stmt; show create table t1; Table Create Table diff --git a/mysql-test/suite/sys_vars/r/explicit_defaults_for_timestamp_on.result b/mysql-test/suite/sys_vars/r/explicit_defaults_for_timestamp_on.result index 85cbfbc2962..37d5a82b021 100644 --- a/mysql-test/suite/sys_vars/r/explicit_defaults_for_timestamp_on.result +++ b/mysql-test/suite/sys_vars/r/explicit_defaults_for_timestamp_on.result @@ -233,6 +233,8 @@ t1 CREATE TABLE `t1` ( `a` timestamp NULL DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci set explicit_defaults_for_timestamp=1-@@explicit_defaults_for_timestamp; +Warnings: +Warning 1681 'explicit_defaults_for_timestamp=0' is deprecated and will be removed in a future release execute stmt; show create table t1; Table Create Table diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index f2a52c964cb..c508f73fe25 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -723,13 +723,24 @@ Sys_binlog_direct( CMD_LINE(OPT_ARG), DEFAULT(FALSE), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(binlog_direct_check)); +static bool deprecated_explicit_defaults_for_timestamp(sys_var *self, THD *thd, + set_var *var) +{ + if (var->value && var->save_result.ulonglong_value == 0) + push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, + ER_WARN_DEPRECATED_SYNTAX_NO_REPLACEMENT, + ER_THD(thd, ER_WARN_DEPRECATED_SYNTAX_NO_REPLACEMENT), + "explicit_defaults_for_timestamp=0"); // since 11.0.0 + return false; +} static Sys_var_bit Sys_explicit_defaults_for_timestamp( "explicit_defaults_for_timestamp", "This option causes CREATE TABLE to create all TIMESTAMP columns " "as NULL with DEFAULT NULL attribute, Without this option, " "TIMESTAMP columns are NOT NULL and have implicit DEFAULT clauses.", SESSION_VAR(option_bits), CMD_LINE(OPT_ARG), - OPTION_EXPLICIT_DEF_TIMESTAMP, DEFAULT(TRUE), NO_MUTEX_GUARD, IN_BINLOG); + OPTION_EXPLICIT_DEF_TIMESTAMP, DEFAULT(TRUE), NO_MUTEX_GUARD, IN_BINLOG, + ON_CHECK(deprecated_explicit_defaults_for_timestamp)); static Sys_var_ulonglong Sys_bulk_insert_buff_size( "bulk_insert_buffer_size", "Size of tree cache used in bulk "