Skip to content

Commit 1fda054

Browse files
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().
1 parent a1b0f23 commit 1fda054

File tree

4 files changed

+44
-0
lines changed

4 files changed

+44
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
for master_1
2+
for child2
3+
child2_1
4+
child2_2
5+
child2_3
6+
for child3
7+
8+
MDEV-25684 Crash in THD::find_temporary_table while calling spider_direct_sql UDF without temporary table created
9+
10+
connection master_1;
11+
SELECT SPIDER_DIRECT_SQL('SELECT * FROM s', 'non_existing_temporary_table', 'srv "s_2_1"');
12+
ERROR HY000: Temporary table 'test.non_existing_temporary_table' is not found
13+
for master_1
14+
for child2
15+
child2_1
16+
child2_2
17+
child2_3
18+
for child3
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
!include include/default_mysqld.cnf
2+
!include ../my_1_1.cnf
3+
!include ../my_2_1.cnf
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--disable_query_log
2+
--disable_result_log
3+
--source ../../t/test_init.inc
4+
--enable_result_log
5+
--enable_query_log
6+
7+
--echo
8+
--echo MDEV-25684 Crash in THD::find_temporary_table while calling spider_direct_sql UDF without temporary table created
9+
--echo
10+
11+
--connection master_1
12+
--error 12703
13+
SELECT SPIDER_DIRECT_SQL('SELECT * FROM s', 'non_existing_temporary_table', 'srv "s_2_1"');
14+
15+
--disable_query_log
16+
--disable_result_log
17+
--source ../../t/test_deinit.inc
18+
--enable_result_log
19+
--enable_query_log

storage/spider/spd_sys_table.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3818,6 +3818,10 @@ TABLE *spider_find_temporary_table(
38183818
) {
38193819
DBUG_ENTER("spider_find_temporary_table");
38203820
#ifdef SPIDER_open_temporary_table
3821+
if (!thd->has_temporary_tables())
3822+
{
3823+
DBUG_RETURN(NULL);
3824+
}
38213825
if (thd->open_temporary_table(table_list))
38223826
{
38233827
DBUG_RETURN(NULL);

0 commit comments

Comments
 (0)