Browse Source

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().
pull/1905/head
Nayuta Yanagisawa 4 years ago
parent
commit
1fda0544b9
  1. 18
      storage/spider/mysql-test/spider/bugfix/r/mdev_25684.result
  2. 3
      storage/spider/mysql-test/spider/bugfix/t/mdev_25684.cnf
  3. 19
      storage/spider/mysql-test/spider/bugfix/t/mdev_25684.test
  4. 4
      storage/spider/spd_sys_table.cc

18
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

3
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

19
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

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

Loading…
Cancel
Save