summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNayuta Yanagisawa <nayuta.yanagisawa@hey.com>2021-08-11 10:27:20 +0000
committerNayuta Yanagisawa <nayuta.yanagisawa@hey.com>2021-09-06 05:00:22 +0000
commit1fda0544b9146ed608a59974c783ab1350b1dcfd (patch)
tree8b5caae0b0cd51de95ba5a9e8ba727a4823659c6
parenta1b0f2358620335e9495242270cf47a1366c9a6a (diff)
downloadmariadb-git-1fda0544b9146ed608a59974c783ab1350b1dcfd.tar.gz
MDEV-25684 Crash in THD::find_temporary_table while calling spider_direct_sql UDF without temporary table createdbb-10.5-mdev-25684
The server crashed when SPIDER_DIRECT_SQL UDF was called with non-existing temporary table. The bug has been introduced by 91ffdc8. The commit removed the check, from THD::open_temporary_table(), which ensure that the target temporary tables exist. We can fix the bug by adding the check before the call of THD::open_temporary_table().
-rw-r--r--storage/spider/mysql-test/spider/bugfix/r/mdev_25684.result18
-rw-r--r--storage/spider/mysql-test/spider/bugfix/t/mdev_25684.cnf3
-rw-r--r--storage/spider/mysql-test/spider/bugfix/t/mdev_25684.test19
-rw-r--r--storage/spider/spd_sys_table.cc4
4 files changed, 44 insertions, 0 deletions
diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_25684.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_25684.result
new file mode 100644
index 00000000000..8d4bea79476
--- /dev/null
+++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_25684.result
@@ -0,0 +1,18 @@
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+
+MDEV-25684 Crash in THD::find_temporary_table while calling spider_direct_sql UDF without temporary table created
+
+connection master_1;
+SELECT SPIDER_DIRECT_SQL('SELECT * FROM s', 'non_existing_temporary_table', 'srv "s_2_1"');
+ERROR HY000: Temporary table 'test.non_existing_temporary_table' is not found
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_25684.cnf b/storage/spider/mysql-test/spider/bugfix/t/mdev_25684.cnf
new file mode 100644
index 00000000000..05dfd8a0bce
--- /dev/null
+++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_25684.cnf
@@ -0,0 +1,3 @@
+!include include/default_mysqld.cnf
+!include ../my_1_1.cnf
+!include ../my_2_1.cnf
diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_25684.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_25684.test
new file mode 100644
index 00000000000..243031e52dd
--- /dev/null
+++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_25684.test
@@ -0,0 +1,19 @@
+--disable_query_log
+--disable_result_log
+--source ../../t/test_init.inc
+--enable_result_log
+--enable_query_log
+
+--echo
+--echo MDEV-25684 Crash in THD::find_temporary_table while calling spider_direct_sql UDF without temporary table created
+--echo
+
+--connection master_1
+--error 12703
+SELECT SPIDER_DIRECT_SQL('SELECT * FROM s', 'non_existing_temporary_table', 'srv "s_2_1"');
+
+--disable_query_log
+--disable_result_log
+--source ../../t/test_deinit.inc
+--enable_result_log
+--enable_query_log
diff --git a/storage/spider/spd_sys_table.cc b/storage/spider/spd_sys_table.cc
index 0ed8640eb48..a467c2c00fa 100644
--- a/storage/spider/spd_sys_table.cc
+++ b/storage/spider/spd_sys_table.cc
@@ -3818,6 +3818,10 @@ TABLE *spider_find_temporary_table(
) {
DBUG_ENTER("spider_find_temporary_table");
#ifdef SPIDER_open_temporary_table
+ if (!thd->has_temporary_tables())
+ {
+ DBUG_RETURN(NULL);
+ }
if (thd->open_temporary_table(table_list))
{
DBUG_RETURN(NULL);