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);