[Commits] 4c0014ad595: MDEV-22331: table discovery doesn't work when undoing a rename
revision-id: 4c0014ad595d9b10bd1f70289969d7cee84057a5 (mariadb-10.5.2-441-g4c0014ad595) parent(s): 517e9334f2a0f0d70cb139deb110213536dbb96d author: Sergei Petrunia committer: Sergei Petrunia timestamp: 2020-06-16 20:43:30 +0300 message: MDEV-22331: table discovery doesn't work when undoing a rename In TABLE_SHARE::init_from_sql_statement_string(): - don't check thd->is_error() - instead, install a Turn_errors_to_warnings_handler object for the duration of parsing, and then examine it. in Turn_errors_to_warnings_handler, count the errors caught. --- sql/table.cc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/sql/table.cc b/sql/table.cc index 73c3bd4b3ba..09c7b28d2f2 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -3339,6 +3339,7 @@ int TABLE_SHARE::init_from_sql_statement_string(THD *thd, bool write, handlerton *hton= plugin_hton(db_plugin); LEX_CUSTRING frm= {0,0}; LEX_CSTRING db_backup= thd->db; + Turn_errors_to_warnings_handler silencer; DBUG_ENTER("TABLE_SHARE::init_from_sql_statement_string"); /* @@ -3368,6 +3369,8 @@ int TABLE_SHARE::init_from_sql_statement_string(THD *thd, bool write, thd->reset_db(&db); lex_start(thd); + thd->push_internal_handler(&silencer); + if (unlikely((error= parse_sql(thd, & parser_state, NULL) || sql_unusable_for_discovery(thd, hton, sql_copy)))) goto ret; @@ -3395,6 +3398,7 @@ int TABLE_SHARE::init_from_sql_statement_string(THD *thd, bool write, } ret: + thd->pop_internal_handler(); my_free(const_cast<uchar*>(frm.str)); lex_end(thd->lex); thd->reset_db(&db_backup); @@ -3403,9 +3407,8 @@ int TABLE_SHARE::init_from_sql_statement_string(THD *thd, bool write, thd->restore_active_arena(arena, &backup); reenable_binlog(thd); thd->variables.character_set_client= old_cs; - if (unlikely(thd->is_error() || error)) + if (silencer.errors || error) { - thd->clear_error(); my_error(ER_SQL_DISCOVER_ERROR, MYF(0), plugin_name(db_plugin)->str, db.str, table_name.str, sql_copy); @@ -8421,7 +8424,8 @@ bool is_simple_order(ORDER *order) class Turn_errors_to_warnings_handler : public Internal_error_handler { public: - Turn_errors_to_warnings_handler() {} + int errors; + Turn_errors_to_warnings_handler() : errors(0) {} bool handle_condition(THD *thd, uint sql_errno, const char* sqlstate, @@ -8431,7 +8435,10 @@ class Turn_errors_to_warnings_handler : public Internal_error_handler { *cond_hdl= NULL; if (*level == Sql_condition::WARN_LEVEL_ERROR) + { *level= Sql_condition::WARN_LEVEL_WARN; + errors++; + } return(0); } };
participants (1)
-
Sergei Petrunia