summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNayuta Yanagisawa <nayuta.yanagisawa@hey.com>2021-08-16 14:45:28 +0000
committerNayuta Yanagisawa <nayuta.yanagisawa@hey.com>2021-08-24 00:31:31 +0000
commit43bbe5286358d54b3f46227509969e2586e8fa4a (patch)
tree991f2381de2b78d679c77d3e1abe6766d50f6f0d
parentc0a84fb9b0367b4cbd0a8e36d7cb219eb5f919e9 (diff)
downloadmariadb-git-bb-10.3-mdev-26364.tar.gz
MDEV-26364 Add Spider server variable for disabling GROUP BY handlerbb-10.3-mdev-26364
Add a server variable, to the Spider storage engine, that disables the use of the GROUP BY handler. This provides users with a unified workaround for the bugs like MDEV-26013. It is also useful for testing purposes because one can specify the execution path that he want to test. The default value of the variable should be 1 for the compatibility.
-rw-r--r--storage/spider/mysql-test/spider/include/server_variables.deinit5
-rw-r--r--storage/spider/mysql-test/spider/include/server_variables.init5
-rw-r--r--storage/spider/mysql-test/spider/r/server_variables.result34
-rw-r--r--storage/spider/mysql-test/spider/t/server_variables.test37
-rw-r--r--storage/spider/spd_group_by_handler.cc3
-rw-r--r--storage/spider/spd_param.cc21
-rw-r--r--storage/spider/spd_param.h3
7 files changed, 108 insertions, 0 deletions
diff --git a/storage/spider/mysql-test/spider/include/server_variables.deinit b/storage/spider/mysql-test/spider/include/server_variables.deinit
new file mode 100644
index 00000000000..d955a84f755
--- /dev/null
+++ b/storage/spider/mysql-test/spider/include/server_variables.deinit
@@ -0,0 +1,5 @@
+--disable_query_log
+--disable_result_log
+--source ../t/test_deinit.inc
+--enable_result_log
+--enable_query_log
diff --git a/storage/spider/mysql-test/spider/include/server_variables.init b/storage/spider/mysql-test/spider/include/server_variables.init
new file mode 100644
index 00000000000..40fe28a937a
--- /dev/null
+++ b/storage/spider/mysql-test/spider/include/server_variables.init
@@ -0,0 +1,5 @@
+--disable_query_log
+--disable_result_log
+--source ../t/test_init.inc
+--enable_result_log
+--enable_query_log
diff --git a/storage/spider/mysql-test/spider/r/server_variables.result b/storage/spider/mysql-test/spider/r/server_variables.result
new file mode 100644
index 00000000000..2d927e78ed8
--- /dev/null
+++ b/storage/spider/mysql-test/spider/r/server_variables.result
@@ -0,0 +1,34 @@
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+child3_1
+child3_2
+child3_3
+#
+# MDEV-26364 Add Spider server variable for disabling GROUP BY handler
+#
+connection master_1;
+SET SESSION spider_enable_group_by_handler=0;
+EXPLAIN SELECT * FROM ta_l;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE ta_l index NULL PRIMARY 4 NULL 2 Using index
+SET SESSION spider_enable_group_by_handler=1;
+EXPLAIN SELECT * FROM ta_l;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Storage engine handles GROUP BY
+connection master_1;
+DROP DATABASE auto_test_local;
+connection child2_1;
+DROP DATABASE auto_test_remote;
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+child3_1
+child3_2
+child3_3
diff --git a/storage/spider/mysql-test/spider/t/server_variables.test b/storage/spider/mysql-test/spider/t/server_variables.test
new file mode 100644
index 00000000000..4361de46162
--- /dev/null
+++ b/storage/spider/mysql-test/spider/t/server_variables.test
@@ -0,0 +1,37 @@
+--source ../include/server_variables.init
+
+--disable_query_log
+--connection master_1
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+
+eval CREATE TABLE ta_l (
+ pkey int NOT NULL,
+ PRIMARY KEY (pkey)
+) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1;
+
+--connection child2_1
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+
+eval CREATE TABLE ta_r (
+ pkey int NOT NULL,
+ PRIMARY KEY (pkey)
+) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;
+--enable_query_log
+
+--echo #
+--echo # MDEV-26364 Add Spider server variable for disabling GROUP BY handler
+--echo #
+--connection master_1
+SET SESSION spider_enable_group_by_handler=0;
+EXPLAIN SELECT * FROM ta_l;
+SET SESSION spider_enable_group_by_handler=1;
+EXPLAIN SELECT * FROM ta_l;
+
+--connection master_1
+DROP DATABASE auto_test_local;
+--connection child2_1
+DROP DATABASE auto_test_remote;
+
+--source ../include/server_variables.deinit
diff --git a/storage/spider/spd_group_by_handler.cc b/storage/spider/spd_group_by_handler.cc
index 8bd0eca507f..07c2333911c 100644
--- a/storage/spider/spd_group_by_handler.cc
+++ b/storage/spider/spd_group_by_handler.cc
@@ -1645,6 +1645,9 @@ group_by_handler *spider_create_group_by_handler(
break;
}
+ if (!spider_param_enable_group_by_handler(thd))
+ DBUG_RETURN(NULL);
+
#ifdef WITH_PARTITION_STORAGE_ENGINE
from = query->from;
do {
diff --git a/storage/spider/spd_param.cc b/storage/spider/spd_param.cc
index 61fd4339ca5..ef951b98101 100644
--- a/storage/spider/spd_param.cc
+++ b/storage/spider/spd_param.cc
@@ -3349,6 +3349,26 @@ static MYSQL_SYSVAR_INT(
0 /* blk */
);
+/*
+ FALSE: Direct SELECT is disabled
+ TRUE: Direct SELECT is enabled
+ */
+static MYSQL_THDVAR_BOOL(
+ enable_group_by_handler, /* name */
+ PLUGIN_VAR_OPCMDARG, /* opt */
+ "Enable direct SELECT, i.e., enable the use of the GROUP BY handler", /* comment */
+ NULL, /* check */
+ NULL, /* update */
+ TRUE /* def */
+);
+
+bool spider_param_enable_group_by_handler(
+ THD *thd
+) {
+ DBUG_ENTER("spider_param_enable_group_by_handler");
+ DBUG_RETURN(THDVAR(thd, enable_group_by_handler));
+}
+
int spider_param_slave_trx_isolation()
{
DBUG_ENTER("spider_param_slave_trx_isolation");
@@ -3505,6 +3525,7 @@ static struct st_mysql_sys_var* spider_system_variables[] = {
MYSQL_SYSVAR(table_crd_thread_count),
#endif
MYSQL_SYSVAR(slave_trx_isolation),
+ MYSQL_SYSVAR(enable_group_by_handler),
NULL
};
diff --git a/storage/spider/spd_param.h b/storage/spider/spd_param.h
index 4318515dd72..26262b37499 100644
--- a/storage/spider/spd_param.h
+++ b/storage/spider/spd_param.h
@@ -421,3 +421,6 @@ uint spider_param_table_sts_thread_count();
uint spider_param_table_crd_thread_count();
#endif
int spider_param_slave_trx_isolation();
+bool spider_param_enable_group_by_handler(
+ THD *thd
+);