Commit 9e9e0b99 authored by Yuchen Pei's avatar Yuchen Pei

MDEV-30170 ha_spider::delete_table() should report table not exist

All Spider tables are recorded in the system table
mysql.spider_tables. Deleting a spider table removes the corresponding
rows from the system table, among other things. This patch makes it so
that if spider could not find any record in the system table to delete
for a given table, it should correctly report that no such Spider
table exists.
parent 7801c6d2
......@@ -11371,7 +11371,10 @@ int ha_spider::create(
if (
thd->lex->create_info.or_replace() &&
(error_num = spider_delete_tables(
table_tables, tmp_share.table_name, &dummy))
table_tables, tmp_share.table_name, &dummy)) &&
/* In this context, no key found in mysql.spider_tables means
the Spider table does not exist */
error_num != HA_ERR_KEY_NOT_FOUND
) {
goto error;
}
......@@ -11842,6 +11845,10 @@ int ha_spider::delete_table(
(error_num = spider_delete_tables(
table_tables, name, &old_link_count))
) {
/* In this context, no key found in mysql.spider_tables means
the Spider table does not exist */
if (error_num == HA_ERR_KEY_NOT_FOUND)
error_num= HA_ERR_NO_SUCH_TABLE;
goto error;
}
spider_close_sys_table(current_thd, table_tables,
......
install soname 'ha_spider';
DROP TABLE non_existing_table;
ERROR 42S02: Unknown table 'test.non_existing_table'
create or replace table non_existing_table (c int) engine=Spider;
drop table non_existing_table;
Warnings:
Warning 1620 Plugin is busy and will be uninstalled on shutdown
install soname 'ha_spider';
--error ER_BAD_TABLE_ERROR
DROP TABLE non_existing_table;
# Test that create or replace a non existing spider table work
create or replace table non_existing_table (c int) engine=Spider;
drop table non_existing_table;
--disable_query_log
--source ../../include/clean_up_spider.inc
......@@ -1865,6 +1865,16 @@ int spider_delete_xa_member(
DBUG_RETURN(0);
}
/**
Delete a Spider table from mysql.spider_tables.
@param table The table mysql.spider_tables
@param name The name of the Spider table to delete
@param old_link_count The number of links in the deleted table
@retval 0 Success
@retval nonzero Failure
*/
int spider_delete_tables(
TABLE *table,
const char *name,
......@@ -1880,10 +1890,20 @@ int spider_delete_tables(
{
spider_store_tables_link_idx(table, roop_count);
if ((error_num = spider_check_sys_table(table, table_key)))
break;
{
/* There's a problem with finding the first record for the
spider table, likely because it does not exist. Fail */
if (roop_count == 0)
DBUG_RETURN(error_num);
/* At least one row has been deleted for the Spider table.
Success */
else
break;
}
else {
if ((error_num = spider_delete_sys_table_row(table)))
{
/* There's a problem deleting the row. Fail */
DBUG_RETURN(error_num);
}
}
......
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