Skip to content

Commit fdcb443

Browse files
committed
Remember first error in Dummy_error_handler
Use Dummy_error_handler in open_stat_tables() to ignore all errors when opening statistics tables.
1 parent 8941bdc commit fdcb443

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

sql/sql_base.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,6 @@ class No_such_table_error_handler : public Internal_error_handler
658658
trapped and no other errors have been seen. FALSE otherwise.
659659
*/
660660
bool safely_trapped_errors();
661-
bool any_error() { return m_handled_errors == 0 || m_unhandled_errors == 0; }
662661
uint got_error() { return first_error; }
663662

664663
private:

sql/sql_class.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1989,25 +1989,33 @@ class Internal_error_handler
19891989
/**
19901990
Implements the trivial error handler which cancels all error states
19911991
and prevents an SQLSTATE to be set.
1992+
Remembers the first error
19921993
*/
19931994

19941995
class Dummy_error_handler : public Internal_error_handler
19951996
{
1997+
uint m_unhandled_errors;
1998+
uint first_error;
19961999
public:
2000+
Dummy_error_handler()
2001+
: m_unhandled_errors(0), first_error(0)
2002+
{}
19972003
bool handle_condition(THD *thd,
19982004
uint sql_errno,
19992005
const char* sqlstate,
20002006
Sql_condition::enum_warning_level *level,
20012007
const char* msg,
20022008
Sql_condition ** cond_hdl)
20032009
{
2004-
/* Ignore error */
2005-
return TRUE;
2010+
m_unhandled_errors++;
2011+
if (!first_error)
2012+
first_error= sql_errno;
2013+
return TRUE; // Ignore error
20062014
}
2007-
Dummy_error_handler() = default; /* Remove gcc warning */
2015+
bool any_error() { return m_unhandled_errors != 0; }
2016+
uint got_error() { return first_error; }
20082017
};
20092018

2010-
20112019
/**
20122020
Implements the trivial error handler which counts errors as they happen.
20132021
*/

sql/sql_statistics.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,17 +293,17 @@ static inline int open_stat_table_for_ddl(THD *thd, TABLE_LIST *table,
293293
const LEX_CSTRING *stat_tab_name)
294294
{
295295
table->init_one_table(&MYSQL_SCHEMA_NAME, stat_tab_name, NULL, TL_WRITE);
296-
No_such_table_error_handler nst_handler;
297-
thd->push_internal_handler(&nst_handler);
296+
Dummy_error_handler error_handler;
297+
thd->push_internal_handler(&error_handler);
298298
int res= open_system_tables_for_read(thd, table);
299299
thd->pop_internal_handler();
300-
if (res && nst_handler.any_error())
300+
if (res && error_handler.any_error())
301301
{
302302
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
303303
ER_CHECK_NO_SUCH_TABLE,
304304
"Got error %d when trying to open statistics "
305305
"table %`s for updating statistics",
306-
nst_handler.got_error(), stat_table_name->str);
306+
error_handler.got_error(), stat_table_name->str);
307307
}
308308
return res;
309309
}

0 commit comments

Comments
 (0)