Skip to content

Commit 6041c66

Browse files
committed
MDEV-39196: SELECT from information schema fails when FederatedX loses underlying table
When a remote table is unavailable, FederatedX was passing a hard error back to the SQL layer, causing INFORMATION_SCHEMA queries to abort entirely. This patch intercepts the remote error in ha_federatedx::info, downgrades it to a warning using push_warning_printf, and includes the local table name in the warning message so the user knows which table is inaccessible. Signed-off-by: Anway Durge <124391429+itzanway@users.noreply.github.com>
1 parent 0bbec68 commit 6041c66

2 files changed

Lines changed: 39 additions & 3 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--source include/have_plugin_auth.inc
2+
--source include/have_federatedx.inc
3+
4+
--disable_warnings
5+
DROP TABLE IF EXISTS t, fed_t;
6+
DROP SERVER IF EXISTS fedlink;
7+
--enable_warnings
8+
9+
--replace_result $MASTER_MYPORT MASTER_MYPORT
10+
--eval create server fedlink foreign data wrapper mysql options (host "127.0.0.1", database "test", user "root", port $MASTER_MYPORT)
11+
12+
CREATE TABLE t AS SELECT 1 AS a;
13+
CREATE TABLE fed_t (a INT) ENGINE=FEDERATED CONNECTION = 'fedlink/t';
14+
15+
--echo # Querying Information Schema before dropping the remote table
16+
SELECT TABLE_NAME, ENGINE FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME IN ('t', 'fed_t');
17+
18+
DROP TABLE t;
19+
20+
--echo # Querying Information Schema AFTER dropping the remote table (this used to crash)
21+
SELECT TABLE_NAME, ENGINE FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME IN ('t', 'fed_t');
22+
23+
--echo # Verify that a warning was pushed
24+
SHOW WARNINGS;
25+
26+
--echo # Cleanup
27+
DROP TABLE fed_t;
28+
DROP SERVER fedlink;

storage/federatedx/ha_federatedx.cc

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3139,13 +3139,21 @@ int ha_federatedx::info(uint flag)
31393139
error:
31403140
if (iop && *iop)
31413141
{
3142-
my_printf_error((*iop)->error_code(), "Received error: %d : %s", MYF(0),
3143-
(*iop)->error_code(), (*iop)->error_str());
3142+
/* Downgrade to warning, include the table name, and continue */
3143+
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
3144+
ER_QUERY_ON_FOREIGN_DATA_SOURCE,
3145+
"Table '%s' is inaccessible. Received error: %d : %s",
3146+
share->table_name, (*iop)->error_code(), (*iop)->error_str());
3147+
error_code= 0;
31443148
}
31453149
else if (remote_error_number != -1 /* error already reported */)
31463150
{
31473151
error_code= remote_error_number;
3148-
my_error(error_code, MYF(0), ER_THD(thd, error_code));
3152+
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
3153+
error_code,
3154+
"Table '%s' is inaccessible. Error: %s",
3155+
share->table_name, ER_THD(thd, error_code));
3156+
error_code= 0;
31493157
}
31503158
fail:
31513159
tmp_txn->release(&tmp_io);

0 commit comments

Comments
 (0)