summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRucha Deodhar <rucha.deodhar@mariadb.com>2021-08-13 15:49:16 +0530
committerRucha Deodhar <rucha.deodhar@mariadb.com>2022-01-11 15:05:40 +0530
commitcea4f7439532e1892561a07f7f4e6228eebc0672 (patch)
tree0591442cdd1d76cf8e4a568ea253c90834af8dbb
parenta81c75f5a96697de560325c440e15b909cac113c (diff)
downloadmariadb-git-bb-10.8-MDEV-24920.tar.gz
MDEV-24920: Merge "old" SQL variable to "old_mode" sql variablebb-10.8-MDEV-24920
Analysis: There are 2 server variables- "old_mode" and "old". "old" is no longer needed as "old_mode" has replaced it (however still used in some places in the code). "old_mode" and "old" has same purpose- emulate behavior from previous MariaDB versions. So they can be merged to avoid confusion. Fix: Deprecate "old" variable and create another mode for @@old_mode to mimic behavior of previous "old" variable. Create specific modes for specifix task that --old sql variable was doing earlier and use the new modes instead.
-rw-r--r--mysql-test/main/mysqld--help.result3
-rw-r--r--mysql-test/suite/sys_vars/r/old_basic.result6
-rw-r--r--mysql-test/suite/sys_vars/r/old_mode_basic.result43
-rw-r--r--mysql-test/suite/sys_vars/r/sysvars_server_embedded.result2
-rw-r--r--mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result2
-rw-r--r--mysql-test/suite/sys_vars/t/old_mode_basic.test35
-rw-r--r--sql/handler.cc3
-rw-r--r--sql/mysqld.cc8
-rw-r--r--sql/sql_class.h2
-rw-r--r--sql/sql_show.cc6
-rw-r--r--sql/sql_table.cc6
-rw-r--r--sql/sql_yacc.yy3
-rw-r--r--sql/sys_vars.cc23
13 files changed, 127 insertions, 15 deletions
diff --git a/mysql-test/main/mysqld--help.result b/mysql-test/main/mysqld--help.result
index a8aa461c863..febbb6a34b6 100644
--- a/mysql-test/main/mysqld--help.result
+++ b/mysql-test/main/mysqld--help.result
@@ -679,7 +679,8 @@ The following specify which files/extra groups are read (specified before remain
--old-mode=name Used to emulate old behavior from earlier MariaDB or
MySQL versions. Any combination of:
NO_DUP_KEY_WARNINGS_WITH_IGNORE, NO_PROGRESS_INFO,
- ZERO_DATE_TIME_CAST, UTF8_IS_UTF8MB3
+ ZERO_DATE_TIME_CAST, UTF8_IS_UTF8MB3,
+ INDEX_HINT_MASK_JOIN, CHECKSUM_SLOW_NULLS
--old-passwords Use old password encryption method (needed for 4.0 and
older clients)
--old-style-user-limits
diff --git a/mysql-test/suite/sys_vars/r/old_basic.result b/mysql-test/suite/sys_vars/r/old_basic.result
index bafe7128821..1eba60ed4a7 100644
--- a/mysql-test/suite/sys_vars/r/old_basic.result
+++ b/mysql-test/suite/sys_vars/r/old_basic.result
@@ -17,7 +17,11 @@ select * from information_schema.session_variables where variable_name='old';
VARIABLE_NAME VARIABLE_VALUE
OLD OFF
set global old=1;
+Warnings:
+Warning 1287 '@@old' is deprecated and will be removed in a future release. Please use '@@old_mode' instead
set session old=1;
+Warnings:
+Warning 1287 '@@old' is deprecated and will be removed in a future release. Please use '@@old_mode' instead
select @@global.old;
@@global.old
1
@@ -25,3 +29,5 @@ select @@session.old;
@@session.old
1
set @@global.old=DEFAULT;
+Warnings:
+Warning 1287 '@@old' is deprecated and will be removed in a future release. Please use '@@old_mode' instead
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 a6b95f1c60c..4caaf7ce664 100644
--- a/mysql-test/suite/sys_vars/r/old_mode_basic.result
+++ b/mysql-test/suite/sys_vars/r/old_mode_basic.result
@@ -114,8 +114,8 @@ SET @@global.old_mode = 4;
SELECT @@global.old_mode;
@@global.old_mode
ZERO_DATE_TIME_CAST
-SET @@global.old_mode = 16;
-ERROR 42000: Variable 'old_mode' can't be set to the value of '16'
+SET @@global.old_mode = 64;
+ERROR 42000: Variable 'old_mode' can't be set to the value of '64'
SELECT @@global.old_mode;
@@global.old_mode
ZERO_DATE_TIME_CAST
@@ -264,3 +264,42 @@ SET @@collation_database = @save_collation_database;
#
# End of 10.6 test
#
+#
+# Beginning of 10.9 test
+#
+#
+# MDEV-24920: Merge "old" SQL variable to "old_mode" sql variable
+#
+# Checking that setting old will also set old_mode
+SELECT @@OLD_MODE;
+@@OLD_MODE
+UTF8_IS_UTF8MB3
+SET old= 1;
+Warnings:
+Warning 1287 '@@old' is deprecated and will be removed in a future release. Please use '@@old_mode' instead
+SELECT @@OLD_MODE;
+@@OLD_MODE
+NO_PROGRESS_INFO,UTF8_IS_UTF8MB3,INDEX_HINT_MASK_JOIN,CHECKSUM_SLOW_NULLS
+SET old= DEFAULT;
+Warnings:
+Warning 1287 '@@old' is deprecated and will be removed in a future release. Please use '@@old_mode' instead
+SELECT @@OLD_MODE;
+@@OLD_MODE
+UTF8_IS_UTF8MB3
+# Checking that old_mode can be set independently as well
+SELECT @@OLD_MODE;
+@@OLD_MODE
+UTF8_IS_UTF8MB3
+SET @save_old_mode = @@OLD_MODE;
+SET @@OLD_MODE= INDEX_HINT_MASK_JOIN;
+SELECT @@OLD_MODE;
+@@OLD_MODE
+INDEX_HINT_MASK_JOIN
+SET @@OLD_MODE= CHECKSUM_SLOW_NULLS;
+SELECT @@OLD_MODE;
+@@OLD_MODE
+CHECKSUM_SLOW_NULLS
+SET @@OLD_MODE= @save_old_mode;
+#
+# End of 10.9 test
+#
diff --git a/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result b/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result
index b1d2a6595b3..2609b3ec1e2 100644
--- a/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result
+++ b/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result
@@ -2219,7 +2219,7 @@ VARIABLE_COMMENT Used to emulate old behavior from earlier MariaDB or MySQL vers
NUMERIC_MIN_VALUE NULL
NUMERIC_MAX_VALUE NULL
NUMERIC_BLOCK_SIZE NULL
-ENUM_VALUE_LIST NO_DUP_KEY_WARNINGS_WITH_IGNORE,NO_PROGRESS_INFO,ZERO_DATE_TIME_CAST,UTF8_IS_UTF8MB3
+ENUM_VALUE_LIST NO_DUP_KEY_WARNINGS_WITH_IGNORE,NO_PROGRESS_INFO,ZERO_DATE_TIME_CAST,UTF8_IS_UTF8MB3,INDEX_HINT_MASK_JOIN,CHECKSUM_SLOW_NULLS
READ_ONLY NO
COMMAND_LINE_ARGUMENT REQUIRED
VARIABLE_NAME OLD_PASSWORDS
diff --git a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result
index 7b811a011ff..53068a2c52e 100644
--- a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result
+++ b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result
@@ -2379,7 +2379,7 @@ VARIABLE_COMMENT Used to emulate old behavior from earlier MariaDB or MySQL vers
NUMERIC_MIN_VALUE NULL
NUMERIC_MAX_VALUE NULL
NUMERIC_BLOCK_SIZE NULL
-ENUM_VALUE_LIST NO_DUP_KEY_WARNINGS_WITH_IGNORE,NO_PROGRESS_INFO,ZERO_DATE_TIME_CAST,UTF8_IS_UTF8MB3
+ENUM_VALUE_LIST NO_DUP_KEY_WARNINGS_WITH_IGNORE,NO_PROGRESS_INFO,ZERO_DATE_TIME_CAST,UTF8_IS_UTF8MB3,INDEX_HINT_MASK_JOIN,CHECKSUM_SLOW_NULLS
READ_ONLY NO
COMMAND_LINE_ARGUMENT REQUIRED
VARIABLE_NAME OLD_PASSWORDS
diff --git a/mysql-test/suite/sys_vars/t/old_mode_basic.test b/mysql-test/suite/sys_vars/t/old_mode_basic.test
index f2fba791859..aa8e97588cb 100644
--- a/mysql-test/suite/sys_vars/t/old_mode_basic.test
+++ b/mysql-test/suite/sys_vars/t/old_mode_basic.test
@@ -172,7 +172,7 @@ SET @@global.old_mode = 4;
SELECT @@global.old_mode;
--Error ER_WRONG_VALUE_FOR_VAR
-SET @@global.old_mode = 16;
+SET @@global.old_mode = 64;
SELECT @@global.old_mode;
# use of decimal values
@@ -314,6 +314,39 @@ SET @@collation_database = @save_collation_database;
--echo # End of 10.6 test
--echo #
+--echo #
+--echo # Beginning of 10.9 test
+--echo #
+--echo #
+--echo # MDEV-24920: Merge "old" SQL variable to "old_mode" sql variable
+--echo #
+
+--echo # Checking that setting old will also set old_mode
+SELECT @@OLD_MODE;
+
+SET old= 1;
+SELECT @@OLD_MODE;
+
+SET old= DEFAULT;
+SELECT @@OLD_MODE;
+
+--echo # Checking that old_mode can be set independently as well
+
+SELECT @@OLD_MODE;
+
+SET @save_old_mode = @@OLD_MODE;
+
+SET @@OLD_MODE= INDEX_HINT_MASK_JOIN;
+SELECT @@OLD_MODE;
+
+SET @@OLD_MODE= CHECKSUM_SLOW_NULLS;
+SELECT @@OLD_MODE;
+
+SET @@OLD_MODE= @save_old_mode;
+
+--echo #
+--echo # End of 10.9 test
+--echo #
################################################################
# END OF old_mode TESTS #
################################################################
diff --git a/sql/handler.cc b/sql/handler.cc
index 9c4c6287950..aea8f38d71a 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -5783,7 +5783,8 @@ int handler::calculate_checksum()
{
Field *f= table->field[i];
- if (! thd->variables.old_mode && f->is_real_null(0))
+ if (! (thd->variables.old_behavior & OLD_MODE_CHECKSUM_SLOW_NULLS) &&
+ f->is_real_null(0))
{
flush_checksum(&row_crc, &checksum_start, &checksum_length);
continue;
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index e7e5af8a2c8..f6c6c1effd7 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -8471,6 +8471,14 @@ static int get_options(int *argc_ptr, char ***argv_ptr)
between options, setting of multiple variables, etc.
Do them here.
*/
+
+ if (global_system_variables.old_mode)
+ {
+ global_system_variables.old_behavior|= (OLD_MODE_NO_PROGRESS_INFO |
+ OLD_MODE_INDEX_HINT_MASK_JOIN |
+ OLD_MODE_CHECKSUM_SLOW_NULLS);
+ }
+
if (global_system_variables.net_buffer_length >
global_system_variables.max_allowed_packet)
{
diff --git a/sql/sql_class.h b/sql/sql_class.h
index df9d89b5aff..ab3f3b3af4b 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -191,6 +191,8 @@ enum enum_binlog_row_image {
#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_INDEX_HINT_MASK_JOIN (1 << 4)
+#define OLD_MODE_CHECKSUM_SLOW_NULLS (1 << 5)
extern char internal_table_name[2];
extern char empty_c_string[1];
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index d01f84fe7d1..a4e7c69d089 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -2918,8 +2918,7 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose)
Item_empty_string(thd, "Info", arg.max_query_length),
mem_root);
field->set_maybe_null();;
- if (!thd->variables.old_mode &&
- !(thd->variables.old_behavior & OLD_MODE_NO_PROGRESS_INFO))
+ if (!(thd->variables.old_behavior & OLD_MODE_NO_PROGRESS_INFO))
{
field_list.push_back(field= new (mem_root)
Item_float(thd, "Progress", 0.0, 3, 7),
@@ -2961,8 +2960,7 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose)
thd_info->query_string.charset());
else
protocol->store_null();
- if (!thd->variables.old_mode &&
- !(thd->variables.old_behavior & OLD_MODE_NO_PROGRESS_INFO))
+ if (!(thd->variables.old_behavior & OLD_MODE_NO_PROGRESS_INFO))
protocol->store_double(thd_info->progress, 3);
if (protocol->write())
break; /* purecov: inspected */
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index a9ad8b7720d..331dea5acd5 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -11487,8 +11487,10 @@ bool mysql_checksum_table(THD *thd, TABLE_LIST *tables,
{
/* Call ->checksum() if the table checksum matches 'old_mode' settings */
if (!(check_opt->flags & T_EXTEND) &&
- (((t->file->ha_table_flags() & HA_HAS_OLD_CHECKSUM) && thd->variables.old_mode) ||
- ((t->file->ha_table_flags() & HA_HAS_NEW_CHECKSUM) && !thd->variables.old_mode)))
+ (((t->file->ha_table_flags() & HA_HAS_OLD_CHECKSUM) &&
+ (thd->variables.old_behavior & OLD_MODE_CHECKSUM_SLOW_NULLS)) ||
+ ((t->file->ha_table_flags() & HA_HAS_NEW_CHECKSUM) &&
+ !(thd->variables.old_behavior & OLD_MODE_CHECKSUM_SLOW_NULLS))))
{
if (t->file->info(HA_STATUS_VARIABLE) || t->file->stats.checksum_null)
protocol->store_null();
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 8ebefbb3d82..d605c4e89b4 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -11769,7 +11769,8 @@ opt_outer:
index_hint_clause:
/* empty */
{
- $$= thd->variables.old_mode ? INDEX_HINT_MASK_JOIN : INDEX_HINT_MASK_ALL;
+ $$= (thd->variables.old_behavior & OLD_MODE_INDEX_HINT_MASK_JOIN) ?
+ INDEX_HINT_MASK_JOIN : INDEX_HINT_MASK_ALL;
}
| FOR_SYM JOIN_SYM { $$= INDEX_HINT_MASK_JOIN; }
| FOR_SYM ORDER_SYM BY { $$= INDEX_HINT_MASK_ORDER; }
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc
index 7127cbc00f6..a7f27930123 100644
--- a/sql/sys_vars.cc
+++ b/sql/sys_vars.cc
@@ -2648,9 +2648,28 @@ static Sys_var_ulong Sys_net_retry_count(
BLOCK_SIZE(1), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0),
ON_UPDATE(fix_net_retry_count));
+static bool set_old_mode (sys_var *self, THD *thd, enum_var_type type)
+{
+ if (thd->variables.old_mode)
+ {
+ thd->variables.old_behavior|= (OLD_MODE_NO_PROGRESS_INFO |
+ OLD_MODE_INDEX_HINT_MASK_JOIN |
+ OLD_MODE_CHECKSUM_SLOW_NULLS);
+ }
+ else
+ {
+ thd->variables.old_behavior&= ~(OLD_MODE_NO_PROGRESS_INFO|
+ OLD_MODE_INDEX_HINT_MASK_JOIN |
+ OLD_MODE_CHECKSUM_SLOW_NULLS);
+ }
+
+ return false;
+}
+
static Sys_var_mybool Sys_old_mode(
"old", "Use compatible behavior from previous MariaDB version. See also --old-mode",
- SESSION_VAR(old_mode), CMD_LINE(OPT_ARG), DEFAULT(FALSE));
+ SESSION_VAR(old_mode), CMD_LINE(OPT_ARG), DEFAULT(FALSE), 0, NOT_IN_BINLOG, ON_CHECK(0),
+ ON_UPDATE(set_old_mode), DEPRECATED("'@@old_mode'"));
static const char *alter_algorithm_modes[]= {"DEFAULT", "COPY", "INPLACE",
"NOCOPY", "INSTANT", NULL};
@@ -3751,6 +3770,8 @@ static const char *old_mode_names[]=
"NO_PROGRESS_INFO",
"ZERO_DATE_TIME_CAST",
"UTF8_IS_UTF8MB3",
+ "INDEX_HINT_MASK_JOIN",
+ "CHECKSUM_SLOW_NULLS",
0
};