Commit 162c1505 authored by Nayuta Yanagisawa's avatar Nayuta Yanagisawa

MDEV-29855 Crash with SPIDER_DIRECT_SQL and spider_udf_ds_use_real_table=1

The crash occurs because of the following call of TABLE_LIST::init_one_table():

  table_list.init_one_table(
    &table_list.db, &table_list.table_name, 0, TL_WRITE);

One should not pass table_list.db and table_list.table_name to the function
because it update the very members internally.

The function is called previously, and there is no need to call it again.
So, simply removing the call will resolve the problem.
parent d569e6de
#
# MDEV-29855 Crash with SPIDER_DIRECT_SQL and spider_udf_ds_use_real_table=1
#
for master_1
for child2
child2_1
child2_2
child2_3
for child3
connection child2_1;
CREATE DATABASE auto_test_remote;
USE auto_test_remote;
CREATE TABLE tbl_a (
a INT
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
connection master_1;
CREATE DATABASE auto_test_local;
USE auto_test_local;
CREATE TABLE tbl_a (
a INT
) ENGINE=Spider DEFAULT CHARSET=utf8 COMMENT='table "tbl_a", srv "s_2_1"';
SET spider_udf_ds_use_real_table=1;
SELECT SPIDER_DIRECT_SQL('select 1 as 1', 'tbl_a', 'srv "s_2_1"');
ERROR 3D000: No database selected
connection master_1;
DROP DATABASE IF EXISTS auto_test_local;
connection child2_1;
DROP DATABASE IF EXISTS auto_test_remote;
for master_1
for child2
child2_1
child2_2
child2_3
for child3
!include include/default_mysqld.cnf
!include ../my_1_1.cnf
!include ../my_2_1.cnf
--echo #
--echo # MDEV-29855 Crash with SPIDER_DIRECT_SQL and spider_udf_ds_use_real_table=1
--echo #
--disable_query_log
--disable_result_log
--source ../../t/test_init.inc
--enable_result_log
--enable_query_log
--connection child2_1
CREATE DATABASE auto_test_remote;
USE auto_test_remote;
eval CREATE TABLE tbl_a (
a INT
) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;
--connection master_1
CREATE DATABASE auto_test_local;
USE auto_test_local;
eval CREATE TABLE tbl_a (
a INT
) $MASTER_1_ENGINE $MASTER_1_CHARSET COMMENT='table "tbl_a", srv "s_2_1"';
SET spider_udf_ds_use_real_table=1;
--error ER_NO_DB_ERROR
SELECT SPIDER_DIRECT_SQL('select 1 as 1', 'tbl_a', 'srv "s_2_1"');
--connection master_1
DROP DATABASE IF EXISTS auto_test_local;
--connection child2_1
DROP DATABASE IF EXISTS auto_test_remote;
--disable_query_log
--disable_result_log
--source ../t/test_deinit.inc
--enable_query_log
--enable_result_log
......@@ -1738,17 +1738,6 @@ long long spider_direct_sql_body(
#else
}
TABLE_LIST *tables = &direct_sql->table_list[roop_count];
#ifdef SPIDER_use_LEX_CSTRING_for_database_tablename_alias
table_list.init_one_table(
&table_list.db, &table_list.table_name, 0, TL_WRITE);
#else
tables->init_one_table(
SPIDER_TABLE_LIST_db_str(&table_list),
SPIDER_TABLE_LIST_db_length(&table_list),
SPIDER_TABLE_LIST_table_name_str(&table_list),
SPIDER_TABLE_LIST_table_name_length(&table_list),
SPIDER_TABLE_LIST_table_name_str(&table_list), TL_WRITE);
#endif
tables->mdl_request.init(MDL_key::TABLE,
SPIDER_TABLE_LIST_db_str(&table_list),
SPIDER_TABLE_LIST_table_name_str(&table_list),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment