MDEV-25684 Crash in THD::find_temporary_table while calling spider_direct_sql UDF without temporary table created

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().
This commit is contained in:
Nayuta Yanagisawa 2021-08-11 10:27:20 +00:00
parent a1b0f23586
commit 1fda0544b9
4 changed files with 44 additions and 0 deletions

View file

@ -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

View file

@ -0,0 +1,3 @@
!include include/default_mysqld.cnf
!include ../my_1_1.cnf
!include ../my_2_1.cnf

View file

@ -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

View file

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