summaryrefslogtreecommitdiff
path: root/sql/sql_show.cc
diff options
context:
space:
mode:
authorChristopher Powers <chris.powers@oracle.com>2010-11-29 22:46:43 -0600
committerChristopher Powers <chris.powers@oracle.com>2010-11-29 22:46:43 -0600
commit4edea18f8daa9b1c1e5614560753a03cfdcb1adb (patch)
treed472c0aee0680365a374ca57af050b09d1bb3738 /sql/sql_show.cc
parentc5276a75023920bdcb7da0624727ec5c24e863e2 (diff)
downloadmariadb-git-4edea18f8daa9b1c1e5614560753a03cfdcb1adb.tar.gz
Bug#35333, "If Federated table can't connect to remote host, can't retrieve
metadata" Improved error handling such that queries against Information_Schema.Tables won't fail if a federated table can't make a remote connection. mysql-test/r/merge.result: Updated with warnings that were previously masked. mysql-test/r/show_check.result: Updated with warnings that were previously masked. mysql-test/r/view.result: Updated with warnings that were previously masked. sql/sql_show.cc: If get_schema_tables_record() encounters an error, push a warning, set the TABLE COMMENT column with the error text, and clear the error so that the operation can continue.
Diffstat (limited to 'sql/sql_show.cc')
-rw-r--r--sql/sql_show.cc43
1 files changed, 34 insertions, 9 deletions
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 9b344204d64..ee0e2bf5ce7 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -3636,28 +3636,28 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables,
{
const char *tmp_buff;
MYSQL_TIME time;
+ int info_error= 0;
CHARSET_INFO *cs= system_charset_info;
DBUG_ENTER("get_schema_tables_record");
restore_record(table, s->default_values);
table->field[1]->store(db_name->str, db_name->length, cs);
table->field[2]->store(table_name->str, table_name->length, cs);
+
if (res)
{
- /*
- there was errors during opening tables
- */
- const char *error= thd->is_error() ? thd->main_da.message() : "";
+ /* There was a table open error, so set the table type and return */
if (tables->view)
table->field[3]->store(STRING_WITH_LEN("VIEW"), cs);
else if (tables->schema_table)
table->field[3]->store(STRING_WITH_LEN("SYSTEM VIEW"), cs);
else
table->field[3]->store(STRING_WITH_LEN("BASE TABLE"), cs);
- table->field[20]->store(error, strlen(error), cs);
- thd->clear_error();
+
+ goto err;
}
- else if (tables->view)
+
+ if (tables->view)
{
table->field[3]->store(STRING_WITH_LEN("VIEW"), cs);
table->field[20]->store(STRING_WITH_LEN("VIEW"), cs);
@@ -3746,9 +3746,14 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables,
if (share->comment.str)
table->field[20]->store(share->comment.str, share->comment.length, cs);
- if(file)
+ if (file)
{
- file->info(HA_STATUS_VARIABLE | HA_STATUS_TIME | HA_STATUS_AUTO);
+ /* If info() fails, then there's nothing else to do */
+ if ((info_error= file->info(HA_STATUS_VARIABLE |
+ HA_STATUS_TIME |
+ HA_STATUS_AUTO)) != 0)
+ goto err;
+
enum row_type row_type = file->get_row_type();
switch (row_type) {
case ROW_TYPE_NOT_USED:
@@ -3826,6 +3831,26 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables,
}
}
}
+
+err:
+ if (res || info_error)
+ {
+ /*
+ If an error was encountered, push a warning, set the TABLE COMMENT
+ column with the error text, and clear the error so that the operation
+ can continue.
+ */
+ const char *error= thd->is_error() ? thd->main_da.message() : "";
+ table->field[20]->store(error, strlen(error), cs);
+
+ if (thd->is_error())
+ {
+ push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+ thd->main_da.sql_errno(), thd->main_da.message());
+ thd->clear_error();
+ }
+ }
+
DBUG_RETURN(schema_table_store_record(thd, table));
}