Commit 6b9e1220 authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-31811 deprecate old_mode values

mark non-default values of old_mode as deprecated.
print a warning when they're set from the command line and in SQL.
parent 82174dae
......@@ -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;
......
......@@ -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'
......
......@@ -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="";
......
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;
......
......@@ -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, "");
......
......@@ -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
......
......@@ -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
......
......@@ -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');
......
--loose-slave-skip-errors=3,100,137,0,643,1752
--old-mode=no_dup_key_warnings_with_ignore,compat_5_1_checksum
......@@ -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
#
......@@ -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 #
......@@ -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
......
......@@ -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);
......
......@@ -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];
......
......@@ -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<<i) & v)
{
if (thd)
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_WARN_DEPRECATED_SYNTAX,
ER_THD(thd, ER_WARN_DEPRECATED_SYNTAX_NO_REPLACEMENT),
old_mode_names[i]);
else
sql_print_warning("--old-mode='%s' is deprecated and will be "
"removed in a future release", old_mode_names[i]);
}
}
static bool old_mode_deprecated(sys_var *self, THD *thd, set_var *var)
{
old_mode_deprecated_warnings(thd, var->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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment