diff --git a/mysql-test/main/alter_table_online_debug.result b/mysql-test/main/alter_table_online_debug.result index 81fe415cf6f..ecb7ce8518d 100644 --- a/mysql-test/main/alter_table_online_debug.result +++ b/mysql-test/main/alter_table_online_debug.result @@ -1432,6 +1432,8 @@ online set debug_sync= 'now SIGNAL proceed'; connection default; set old_mode= LOCK_ALTER_TABLE_COPY; +Warnings: +Warning 1287 'LOCK_ALTER_TABLE_COPY' is deprecated and will be removed in a future release set debug_sync= 'alter_table_copy_end SIGNAL copy_end WAIT_FOR proceed'; alter table t1 drop primary key, add primary key(b), algorithm= copy; connection con2; diff --git a/mysql-test/main/func_hybrid_type.result b/mysql-test/main/func_hybrid_type.result index 550f61d46e8..1c40d50b2e7 100644 --- a/mysql-test/main/func_hybrid_type.result +++ b/mysql-test/main/func_hybrid_type.result @@ -3880,6 +3880,8 @@ t1 CREATE TABLE `t1` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci DROP TABLE t1; SET old_mode=ZERO_DATE_TIME_CAST; +Warnings: +Warning 1287 'ZERO_DATE_TIME_CAST' is deprecated and will be removed in a future release CREATE TABLE t1 AS SELECT LEAST(CURRENT_DATE,CURRENT_TIME) AS c1; Warnings: Warning 1292 Incorrect datetime value: '0000-00-00 10:20:30' @@ -4012,6 +4014,8 @@ t1 CREATE TABLE `t1` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci DROP TABLE t1; SET old_mode=ZERO_DATE_TIME_CAST; +Warnings: +Warning 1287 'ZERO_DATE_TIME_CAST' is deprecated and will be removed in a future release CREATE TABLE t1 AS SELECT LEAST(CURRENT_DATE,CURRENT_TIME) AS c1; Warnings: Warning 1292 Incorrect datetime value: '0000-00-00 10:20:30' diff --git a/mysql-test/main/insert.result b/mysql-test/main/insert.result index 586dbbff153..484fb8dfce3 100644 --- a/mysql-test/main/insert.result +++ b/mysql-test/main/insert.result @@ -710,6 +710,8 @@ insert ignore into t1 values (1,12); Warnings: Warning 1062 Duplicate entry '1' for key 'f1' set @@old_mode="NO_DUP_KEY_WARNINGS_WITH_IGNORE"; +Warnings: +Warning 1287 'NO_DUP_KEY_WARNINGS_WITH_IGNORE' is deprecated and will be removed in a future release insert ignore into t1 values (1,12); insert ignore into t1 values (1,12) on duplicate key update f2=13; set @@old_mode=""; diff --git a/mysql-test/main/old-mode-master.opt b/mysql-test/main/old-mode.opt similarity index 100% rename from mysql-test/main/old-mode-master.opt rename to mysql-test/main/old-mode.opt diff --git a/mysql-test/main/old-mode.result b/mysql-test/main/old-mode.result index daa2a4dc915..cf2c50872a3 100644 --- a/mysql-test/main/old-mode.result +++ b/mysql-test/main/old-mode.result @@ -1,4 +1,3 @@ -drop table if exists t1,t2; create table t1 (a int, b varchar(200), c text not null) checksum=1; create table t2 (a int, b varchar(200), c text not null) checksum=0; insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, ""); @@ -23,6 +22,8 @@ Id User Host db Command Time State Info # MDEV-5372 Make "CAST(time_expr AS DATETIME)" compatible with the SQL Standard) # set @@old_mode=zero_date_time_cast; +Warnings: +Warning 1287 'ZERO_DATE_TIME_CAST' is deprecated and will be removed in a future release SELECT CAST(TIME'-10:30:30' AS DATETIME); CAST(TIME'-10:30:30' AS DATETIME) NULL @@ -106,6 +107,8 @@ DROP TABLE t1; # SET @@global.mysql56_temporal_format=true; SET @@old_mode=zero_date_time_cast; +Warnings: +Warning 1287 'ZERO_DATE_TIME_CAST' is deprecated and will be removed in a future release CREATE TABLE t1 (a TIME,b TIME(1)); INSERT INTO t1 VALUES (TIME'830:20:30',TIME'830:20:30'); SELECT TO_DAYS(a), TO_DAYS(b) FROM t1; @@ -117,6 +120,8 @@ Warning 1264 Out of range value for column 'b' at row 1 DROP TABLE t1; SET @@global.mysql56_temporal_format=false; SET @@old_mode=zero_date_time_cast; +Warnings: +Warning 1287 'ZERO_DATE_TIME_CAST' is deprecated and will be removed in a future release CREATE TABLE t1 (a TIME,b TIME(1)); INSERT INTO t1 VALUES (TIME'830:20:30',TIME'830:20:30'); SELECT TO_DAYS(a), TO_DAYS(b) FROM t1; @@ -225,6 +230,8 @@ SET global mysql56_temporal_format=true; # MDEV-26765 UNIX_TIMESTAMP(CURRENT_TIME()) return null ?!? # SET old_mode=zero_date_time_cast; +Warnings: +Warning 1287 'ZERO_DATE_TIME_CAST' is deprecated and will be removed in a future release SET @@time_zone='+00:00'; SET timestamp=1234567; SELECT CURRENT_TIMESTAMP; diff --git a/mysql-test/main/old-mode.test b/mysql-test/main/old-mode.test index e4928329b47..3077b9b8537 100644 --- a/mysql-test/main/old-mode.test +++ b/mysql-test/main/old-mode.test @@ -2,11 +2,6 @@ # Test 'old' mode # -# Initialise ---disable_warnings -drop table if exists t1,t2; ---enable_warnings - create table t1 (a int, b varchar(200), c text not null) checksum=1; create table t2 (a int, b varchar(200), c text not null) checksum=0; insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, ""); diff --git a/mysql-test/main/timezone2.result b/mysql-test/main/timezone2.result index 31b17fbc0d9..787552d9159 100644 --- a/mysql-test/main/timezone2.result +++ b/mysql-test/main/timezone2.result @@ -373,6 +373,8 @@ DROP TABLE t1, t2, t3; # (an addition for the test for MDEV-4653) SET timestamp=unix_timestamp('2001-02-03 10:20:30'); SET old_mode=ZERO_DATE_TIME_CAST; +Warnings: +Warning 1287 'ZERO_DATE_TIME_CAST' is deprecated and will be removed in a future release SELECT CONVERT_TZ(TIME('00:00:00'),'+00:00','+7:5'); CONVERT_TZ(TIME('00:00:00'),'+00:00','+7:5') NULL diff --git a/mysql-test/main/type_datetime.result b/mysql-test/main/type_datetime.result index 0c351bcb3cd..ff79c83eb47 100644 --- a/mysql-test/main/type_datetime.result +++ b/mysql-test/main/type_datetime.result @@ -936,6 +936,8 @@ SELECT STR_TO_DATE('0000-00-00 00:00:00.000001','%Y-%m-%d %H:%i:%s.%f'); STR_TO_DATE('0000-00-00 00:00:00.000001','%Y-%m-%d %H:%i:%s.%f') 0000-00-00 00:00:00.000001 SET old_mode=zero_date_time_cast; +Warnings: +Warning 1287 'ZERO_DATE_TIME_CAST' is deprecated and will be removed in a future release SELECT CAST(TIME'10:20:30' AS DATETIME); CAST(TIME'10:20:30' AS DATETIME) 0000-00-00 10:20:30 diff --git a/mysql-test/main/type_time.result b/mysql-test/main/type_time.result index 34bf165a3e4..14aac18a154 100644 --- a/mysql-test/main/type_time.result +++ b/mysql-test/main/type_time.result @@ -788,6 +788,8 @@ Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = DROP TABLE t1; SET timestamp=DEFAULT; SET @@old_mode=zero_date_time_cast; +Warnings: +Warning 1287 'ZERO_DATE_TIME_CAST' is deprecated and will be removed in a future release # TIMESTAMP literal, old mode CREATE TABLE t1 (a TIME); INSERT INTO t1 VALUES ('0000-00-00 10:20:30'),('0000-00-00 10:20:31'); @@ -1231,6 +1233,8 @@ DROP TABLE t1; # SET @save_old_mode=@@old_mode; SET @@old_mode=zero_date_time_cast; +Warnings: +Warning 1287 'ZERO_DATE_TIME_CAST' is deprecated and will be removed in a future release CREATE TABLE t1 (a TIME); INSERT INTO t1 VALUES ('0000-00-00 10:20:30'),('0000-00-00 10:20:31'); INSERT INTO t1 VALUES ('0000-00-01 10:20:30'),('0000-00-01 10:20:31'); diff --git a/mysql-test/main/variables-notembedded-master.opt b/mysql-test/main/variables-notembedded-master.opt deleted file mode 100644 index 8a173a043ac..00000000000 --- a/mysql-test/main/variables-notembedded-master.opt +++ /dev/null @@ -1 +0,0 @@ ---loose-slave-skip-errors=3,100,137,0,643,1752 diff --git a/mysql-test/main/variables-notembedded.opt b/mysql-test/main/variables-notembedded.opt new file mode 100644 index 00000000000..c648e504c97 --- /dev/null +++ b/mysql-test/main/variables-notembedded.opt @@ -0,0 +1,2 @@ +--loose-slave-skip-errors=3,100,137,0,643,1752 +--old-mode=no_dup_key_warnings_with_ignore,compat_5_1_checksum diff --git a/mysql-test/main/variables-notembedded.result b/mysql-test/main/variables-notembedded.result index 70a068cd802..05c87314b05 100644 --- a/mysql-test/main/variables-notembedded.result +++ b/mysql-test/main/variables-notembedded.result @@ -174,4 +174,20 @@ LENGTH(a) SET GLOBAL max_allowed_packet=@save_max_allowed_packet; SET GLOBAL net_buffer_length=@save_net_buffer_length; DROP TABLE t1; -End of 5.1 tests +# +# End of 5.1 tests +# +# +# MDEV-31811 deprecate old_mode values +# +select @@old_mode; +@@old_mode +NO_DUP_KEY_WARNINGS_WITH_IGNORE,COMPAT_5_1_CHECKSUM +set old_mode='zero_date_time_cast,no_progress_info'; +Warnings: +Warning 1287 'NO_PROGRESS_INFO' is deprecated and will be removed in a future release +Warning 1287 'ZERO_DATE_TIME_CAST' is deprecated and will be removed in a future release +FOUND 2 /old-mode='[0-9A-Z_]+' is deprecated and will be removed in a future release/ in mysqld.1.err +# +# End of 11.3 tests +# diff --git a/mysql-test/main/variables-notembedded.test b/mysql-test/main/variables-notembedded.test index 7a1489cf392..6c08f5357d0 100644 --- a/mysql-test/main/variables-notembedded.test +++ b/mysql-test/main/variables-notembedded.test @@ -182,4 +182,19 @@ SET GLOBAL max_allowed_packet=@save_max_allowed_packet; SET GLOBAL net_buffer_length=@save_net_buffer_length; DROP TABLE t1; ---echo End of 5.1 tests +--echo # +--echo # End of 5.1 tests +--echo # + +--echo # +--echo # MDEV-31811 deprecate old_mode values +--echo # +select @@old_mode; +set old_mode='zero_date_time_cast,no_progress_info'; +let SEARCH_FILE=$MYSQLTEST_VARDIR/log/mysqld.1.err; +let SEARCH_PATTERN=old-mode='[0-9A-Z_]+' is deprecated and will be removed in a future release; +source include/search_pattern_in_file.inc; + +--echo # +--echo # End of 11.3 tests +--echo # diff --git a/mysql-test/suite/sys_vars/r/old_mode_basic.result b/mysql-test/suite/sys_vars/r/old_mode_basic.result index 776d45a1fe3..7701bc6bbfa 100644 --- a/mysql-test/suite/sys_vars/r/old_mode_basic.result +++ b/mysql-test/suite/sys_vars/r/old_mode_basic.result @@ -8,11 +8,15 @@ SELECT @session_start_value; UTF8_IS_UTF8MB3 '#--------------------FN_DYNVARS_152_01------------------------#' SET @@global.old_mode = "NO_PROGRESS_INFO"; +Warnings: +Warning 1287 'NO_PROGRESS_INFO' is deprecated and will be removed in a future release SET @@global.old_mode = DEFAULT; SELECT @@global.old_mode; @@global.old_mode UTF8_IS_UTF8MB3 SET @@session.old_mode = "NO_PROGRESS_INFO"; +Warnings: +Warning 1287 'NO_PROGRESS_INFO' is deprecated and will be removed in a future release SET @@session.old_mode = DEFAULT; SELECT @@session.old_mode; @@session.old_mode @@ -40,20 +44,28 @@ SELECT @@session.old_mode; '#--------------------FN_DYNVARS_152_03------------------------#' SET @@global.old_mode = NO_PROGRESS_INFO; +Warnings: +Warning 1287 'NO_PROGRESS_INFO' is deprecated and will be removed in a future release SELECT @@global.old_mode; @@global.old_mode NO_PROGRESS_INFO SET @@global.old_mode = NO_DUP_KEY_WARNINGS_WITH_IGNORE; +Warnings: +Warning 1287 'NO_DUP_KEY_WARNINGS_WITH_IGNORE' is deprecated and will be removed in a future release SELECT @@global.old_mode; @@global.old_mode NO_DUP_KEY_WARNINGS_WITH_IGNORE SET @@global.old_mode = OFF; ERROR 42000: Variable 'old_mode' can't be set to the value of 'OFF' SET @@session.old_mode = NO_PROGRESS_INFO; +Warnings: +Warning 1287 'NO_PROGRESS_INFO' is deprecated and will be removed in a future release SELECT @@session.old_mode; @@session.old_mode NO_PROGRESS_INFO SET @@session.old_mode = NO_DUP_KEY_WARNINGS_WITH_IGNORE; +Warnings: +Warning 1287 'NO_DUP_KEY_WARNINGS_WITH_IGNORE' is deprecated and will be removed in a future release SELECT @@session.old_mode; @@session.old_mode NO_DUP_KEY_WARNINGS_WITH_IGNORE @@ -103,14 +115,20 @@ SELECT @@global.old_mode; @@global.old_mode SET @@global.old_mode = 1; +Warnings: +Warning 1287 'NO_DUP_KEY_WARNINGS_WITH_IGNORE' is deprecated and will be removed in a future release SELECT @@global.old_mode; @@global.old_mode NO_DUP_KEY_WARNINGS_WITH_IGNORE SET @@global.old_mode = 2; +Warnings: +Warning 1287 'NO_PROGRESS_INFO' is deprecated and will be removed in a future release SELECT @@global.old_mode; @@global.old_mode NO_PROGRESS_INFO SET @@global.old_mode = 4; +Warnings: +Warning 1287 'ZERO_DATE_TIME_CAST' is deprecated and will be removed in a future release SELECT @@global.old_mode; @@global.old_mode ZERO_DATE_TIME_CAST @@ -123,6 +141,8 @@ SET @@global.old_mode = 0.4; ERROR 42000: Incorrect argument type to variable 'old_mode' '#---------------------FN_DYNVARS_152_08----------------------#' SET @@global.old_mode = TRUE; +Warnings: +Warning 1287 'NO_DUP_KEY_WARNINGS_WITH_IGNORE' is deprecated and will be removed in a future release SELECT @@global.old_mode; @@global.old_mode NO_DUP_KEY_WARNINGS_WITH_IGNORE @@ -132,7 +152,11 @@ SELECT @@global.old_mode; '#---------------------FN_DYNVARS_152_09----------------------#' SET old_mode = 'NO_PROGRESS_INFO'; +Warnings: +Warning 1287 'NO_PROGRESS_INFO' is deprecated and will be removed in a future release SET session old_mode = 1; +Warnings: +Warning 1287 'NO_DUP_KEY_WARNINGS_WITH_IGNORE' is deprecated and will be removed in a future release SELECT @@old_mode; @@old_mode NO_DUP_KEY_WARNINGS_WITH_IGNORE @@ -142,10 +166,16 @@ SELECT @@global.old_mode; '#---------------------FN_DYNVARS_152_10----------------------#' SET @@session.old_mode = 'NO_PROGRESS_INFO,NO_DUP_KEY_WARNINGS_WITH_IGNORE'; +Warnings: +Warning 1287 'NO_DUP_KEY_WARNINGS_WITH_IGNORE' is deprecated and will be removed in a future release +Warning 1287 'NO_PROGRESS_INFO' is deprecated and will be removed in a future release SELECT @@session.old_mode; @@session.old_mode NO_DUP_KEY_WARNINGS_WITH_IGNORE,NO_PROGRESS_INFO SET @@global.old_mode = 'NO_DUP_KEY_WARNINGS_WITH_IGNORE,NO_PROGRESS_INFO'; +Warnings: +Warning 1287 'NO_DUP_KEY_WARNINGS_WITH_IGNORE' is deprecated and will be removed in a future release +Warning 1287 'NO_PROGRESS_INFO' is deprecated and will be removed in a future release SELECT @@global.old_mode; @@global.old_mode NO_DUP_KEY_WARNINGS_WITH_IGNORE,NO_PROGRESS_INFO @@ -156,6 +186,8 @@ SELECT @@old_mode; @@old_mode SET @@old_mode=',,,,NO_PROGRESS_INFO,,,'; +Warnings: +Warning 1287 'NO_PROGRESS_INFO' is deprecated and will be removed in a future release SELECT @@old_mode; @@old_mode NO_PROGRESS_INFO @@ -292,10 +324,14 @@ SELECT @@OLD_MODE; UTF8_IS_UTF8MB3 SET @save_old_mode = @@OLD_MODE; SET @@OLD_MODE= IGNORE_INDEX_ONLY_FOR_JOIN; +Warnings: +Warning 1287 'IGNORE_INDEX_ONLY_FOR_JOIN' is deprecated and will be removed in a future release SELECT @@OLD_MODE; @@OLD_MODE IGNORE_INDEX_ONLY_FOR_JOIN SET @@OLD_MODE= COMPAT_5_1_CHECKSUM; +Warnings: +Warning 1287 'COMPAT_5_1_CHECKSUM' is deprecated and will be removed in a future release SELECT @@OLD_MODE; @@OLD_MODE COMPAT_5_1_CHECKSUM diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 9a3b3f812f2..5d8c494ad2b 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -4259,6 +4259,8 @@ static int init_common_variables() myf utf8_flag= global_system_variables.old_behavior & OLD_MODE_UTF8_IS_UTF8MB3 ? MY_UTF8_IS_UTF8MB3 : 0; + old_mode_deprecated_warnings(0, global_system_variables.old_behavior); + if (character_set_collations_str[0]) { Lex_cstring_strlen str(character_set_collations_str); diff --git a/sql/sql_class.h b/sql/sql_class.h index 855627c6a9e..e5685bd68ad 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -197,13 +197,17 @@ enum enum_binlog_row_image { /* Bits for different old style modes */ -#define OLD_MODE_NO_DUP_KEY_WARNINGS_WITH_IGNORE (1 << 0) -#define OLD_MODE_NO_PROGRESS_INFO (1 << 1) +#define OLD_MODE_NO_DUP_KEY_WARNINGS_WITH_IGNORE (1 << 0) +#define OLD_MODE_NO_PROGRESS_INFO (1 << 1) #define OLD_MODE_ZERO_DATE_TIME_CAST (1 << 2) -#define OLD_MODE_UTF8_IS_UTF8MB3 (1 << 3) -#define OLD_MODE_IGNORE_INDEX_ONLY_FOR_JOIN (1 << 4) -#define OLD_MODE_COMPAT_5_1_CHECKSUM (1 << 5) -#define OLD_MODE_LOCK_ALTER_TABLE_COPY (1 << 6) +#define OLD_MODE_UTF8_IS_UTF8MB3 (1 << 3) +#define OLD_MODE_IGNORE_INDEX_ONLY_FOR_JOIN (1 << 4) +#define OLD_MODE_COMPAT_5_1_CHECKSUM (1 << 5) +#define OLD_MODE_LOCK_ALTER_TABLE_COPY (1 << 6) + +#define OLD_MODE_DEFAULT_VALUE OLD_MODE_UTF8_IS_UTF8MB3 + +void old_mode_deprecated_warnings(THD *thd, ulonglong v); extern char internal_table_name[2]; extern char empty_c_string[1]; diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 338ed49f11d..03279e945a3 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -3870,25 +3870,45 @@ static Sys_var_set Sys_sql_mode( static const char *old_mode_names[]= { - "NO_DUP_KEY_WARNINGS_WITH_IGNORE", - "NO_PROGRESS_INFO", - "ZERO_DATE_TIME_CAST", + "NO_DUP_KEY_WARNINGS_WITH_IGNORE", // deprecated since 11.3 + "NO_PROGRESS_INFO", // deprecated since 11.3 + "ZERO_DATE_TIME_CAST", // deprecated since 11.3 "UTF8_IS_UTF8MB3", - "IGNORE_INDEX_ONLY_FOR_JOIN", - "COMPAT_5_1_CHECKSUM", - "LOCK_ALTER_TABLE_COPY", + "IGNORE_INDEX_ONLY_FOR_JOIN", // deprecated since 11.3 + "COMPAT_5_1_CHECKSUM", // deprecated since 11.3 + "LOCK_ALTER_TABLE_COPY", // deprecated since 11.3 0 }; -/* - sql_mode should *not* be IN_BINLOG as the slave can't remember this - anyway on restart. -*/ +void old_mode_deprecated_warnings(THD *thd, ulonglong v) +{ + v &= ~OLD_MODE_DEFAULT_VALUE; + for (uint i=0; old_mode_names[i]; i++) + if ((1ULL<save_result.ulonglong_value); + return false; +} + static Sys_var_set Sys_old_behavior( "old_mode", "Used to emulate old behavior from earlier MariaDB or MySQL versions", SESSION_VAR(old_behavior), CMD_LINE(REQUIRED_ARG), - old_mode_names, DEFAULT(OLD_MODE_UTF8_IS_UTF8MB3)); + old_mode_names, DEFAULT(OLD_MODE_DEFAULT_VALUE), + NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(old_mode_deprecated)); #if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY) #define SSL_OPT(X) CMD_LINE(REQUIRED_ARG,X)