1
0
mirror of https://github.com/MariaDB/server.git synced 2025-12-24 11:21:21 +03:00

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.
This commit is contained in:
Christopher Powers
2010-11-29 22:46:43 -06:00
parent c5276a7502
commit 4edea18f8d
6 changed files with 188 additions and 16 deletions

View File

@@ -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));
}