Commit 470c1b8d authored by Kentoku's avatar Kentoku Committed by Sergei Golubchik

Fix an error at using spider_direct_sql with temporary table

parent ea347fcb
--disable_warnings
--disable_query_log
--disable_result_log
--source ../t/test_deinit.inc
--enable_result_log
--enable_query_log
--enable_warnings
--disable_warnings
--disable_query_log
--disable_result_log
--source ../t/test_init.inc
--enable_result_log
--enable_query_log
--enable_warnings
let $DIRECT_SQL_COMMAND=
SELECT spider_direct_sql('SELECT 22', 'tmp_a', 'srv "s_2_1", database "test"');
for master_1
for child2
child2_1
child2_2
child2_3
for child3
drop and create databases
connection master_1;
CREATE DATABASE auto_test_local;
USE auto_test_local;
CREATE TEMPORARY TABLE tmp_a (
pkey int NOT NULL,
PRIMARY KEY (pkey)
) MASTER_1_ENGINE2
SELECT spider_direct_sql('SELECT 22', 'tmp_a', 'srv "s_2_1", database "test"');
spider_direct_sql('SELECT 22', 'tmp_a', 'srv "s_2_1", database "test"')
1
SELECT pkey FROM tmp_a;
pkey
22
deinit
connection master_1;
DROP DATABASE IF EXISTS auto_test_local;
for master_1
for child2
child2_1
child2_2
child2_3
for child3
end of test
!include include/default_mysqld.cnf
!include ../my_1_1.cnf
!include ../my_2_1.cnf
--source ../include/direct_sql_with_tmp_table_init.inc
--echo
--echo drop and create databases
--connection master_1
--disable_warnings
CREATE DATABASE auto_test_local;
USE auto_test_local;
--enable_warnings
--disable_query_log
echo CREATE TEMPORARY TABLE tmp_a (
pkey int NOT NULL,
PRIMARY KEY (pkey)
) MASTER_1_ENGINE2;
eval CREATE TEMPORARY TABLE tmp_a (
pkey int NOT NULL,
PRIMARY KEY (pkey)
) $MASTER_1_ENGINE2;
--enable_query_log
eval $DIRECT_SQL_COMMAND;
SELECT pkey FROM tmp_a;
--echo
--echo deinit
--disable_warnings
--connection master_1
DROP DATABASE IF EXISTS auto_test_local;
--enable_warnings
--source ../include/direct_sql_with_tmp_table_deinit.inc
--echo
--echo end of test
......@@ -1721,7 +1721,7 @@ long long spider_direct_sql_body(
direct_sql->table_names[roop_count];
#endif
if (!(direct_sql->tables[roop_count] =
SPIDER_find_temporary_table(thd, &table_list)))
spider_find_temporary_table(thd, &table_list)))
{
#if MYSQL_VERSION_ID < 50500
#else
......
......@@ -160,9 +160,7 @@
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100201
#define SPIDER_HAS_MY_CHARLEN
#define SPIDER_find_temporary_table(A,B) A->find_temporary_table(B)
#else
#define SPIDER_find_temporary_table(A,B) find_temporary_table(A,B)
#define SPIDER_open_temporary_table
#endif
#if defined(MARIADB_BASE_VERSION)
......
......@@ -3489,3 +3489,20 @@ void spider_rm_sys_tmp_table_for_result(
tmp_tbl_prm->field_count = 3;
DBUG_VOID_RETURN;
}
TABLE *spider_find_temporary_table(
THD *thd,
TABLE_LIST *table_list
) {
DBUG_ENTER("spider_find_temporary_table");
#ifdef SPIDER_open_temporary_table
if (thd->open_temporary_table(table_list))
{
DBUG_RETURN(NULL);
} else {
DBUG_RETURN(table_list->table);
}
#else
DBUG_RETURN(find_temporary_table(A,B));
#endif
}
......@@ -678,3 +678,8 @@ void spider_rm_sys_tmp_table_for_result(
TABLE *tmp_table,
TMP_TABLE_PARAM *tmp_tbl_prm
);
TABLE *spider_find_temporary_table(
THD *thd,
TABLE_LIST *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