mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Give warnings if open_stat_table_for_ddl() fails
The warning is given in case of table not found or if there is a lock timeout. The warning is needed as in case of a lock timeout then the persistent table stats are going to be wrong.
This commit is contained in:
@ -2,6 +2,9 @@ create table t1 (a int);
|
||||
alter table mysql.column_stats rename to mysql.column_stats1;
|
||||
flush tables;
|
||||
alter table t1 change a b varchar(100);
|
||||
Warnings:
|
||||
Warning 1177 Got error 1146 when trying to open statistics table `table_stats` for updating statistics
|
||||
Warning 1177 Got error 1146 when trying to open statistics table `table_stats` for updating statistics
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
|
@ -73,6 +73,8 @@ No_such_table_error_handler::handle_condition(THD *,
|
||||
Sql_condition ** cond_hdl)
|
||||
{
|
||||
*cond_hdl= NULL;
|
||||
if (!first_error)
|
||||
first_error= sql_errno;
|
||||
if (sql_errno == ER_NO_SUCH_TABLE || sql_errno == ER_NO_SUCH_TABLE_IN_ENGINE)
|
||||
{
|
||||
m_handled_errors++;
|
||||
@ -95,7 +97,6 @@ bool No_such_table_error_handler::safely_trapped_errors()
|
||||
return ((m_handled_errors > 0) && (m_unhandled_errors == 0));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
This internal handler is used to trap ER_NO_SUCH_TABLE and
|
||||
ER_WRONG_MRG_TABLE errors during CHECK/REPAIR TABLE for MERGE
|
||||
|
@ -643,7 +643,7 @@ class No_such_table_error_handler : public Internal_error_handler
|
||||
{
|
||||
public:
|
||||
No_such_table_error_handler()
|
||||
: m_handled_errors(0), m_unhandled_errors(0)
|
||||
: m_handled_errors(0), m_unhandled_errors(0), first_error(0)
|
||||
{}
|
||||
|
||||
bool handle_condition(THD *thd,
|
||||
@ -658,11 +658,12 @@ public:
|
||||
trapped and no other errors have been seen. FALSE otherwise.
|
||||
*/
|
||||
bool safely_trapped_errors();
|
||||
bool any_error() { return m_handled_errors == 0 || m_unhandled_errors == 0; }
|
||||
uint got_error() { return first_error; }
|
||||
|
||||
private:
|
||||
int m_handled_errors;
|
||||
int m_unhandled_errors;
|
||||
uint first_error;
|
||||
};
|
||||
|
||||
|
||||
#endif /* SQL_BASE_INCLUDED */
|
||||
|
@ -284,6 +284,10 @@ static int open_stat_tables(THD *thd, TABLE_LIST *tables, bool for_write)
|
||||
@details
|
||||
This is used by DDLs. When a column or index is dropped or renamed,
|
||||
stat tables need to be adjusted accordingly.
|
||||
|
||||
This function should not generate any errors as the callers are not checking
|
||||
the result of delete_statistics_for_table()
|
||||
|
||||
*/
|
||||
static inline int open_stat_table_for_ddl(THD *thd, TABLE_LIST *table,
|
||||
const LEX_CSTRING *stat_tab_name)
|
||||
@ -293,6 +297,14 @@ static inline int open_stat_table_for_ddl(THD *thd, TABLE_LIST *table,
|
||||
thd->push_internal_handler(&nst_handler);
|
||||
int res= open_system_tables_for_read(thd, table);
|
||||
thd->pop_internal_handler();
|
||||
if (res && nst_handler.any_error())
|
||||
{
|
||||
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
|
||||
ER_CHECK_NO_SUCH_TABLE,
|
||||
"Got error %d when trying to open statistics "
|
||||
"table %`s for updating statistics",
|
||||
nst_handler.got_error(), stat_table_name->str);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user