diff options
Diffstat (limited to 'sql/sql_view.cc')
-rw-r--r-- | sql/sql_view.cc | 47 |
1 files changed, 18 insertions, 29 deletions
diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 30fadcc63d2..d4f6613f2f0 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -1809,10 +1809,10 @@ bool mysql_drop_view(THD *thd, TABLE_LIST *views, enum_drop_mode drop_mode) char path[FN_REFLEN + 1]; TABLE_LIST *view; String non_existant_views; - const char *wrong_object_db= NULL, *wrong_object_name= NULL; - bool error= FALSE; + bool delete_error= FALSE, wrong_object_name= FALSE; bool some_views_deleted= FALSE; bool something_wrong= FALSE; + uint not_exists_count= 0; DBUG_ENTER("mysql_drop_view"); /* @@ -1842,32 +1842,22 @@ bool mysql_drop_view(THD *thd, TABLE_LIST *views, enum_drop_mode drop_mode) char name[FN_REFLEN]; my_snprintf(name, sizeof(name), "%s.%s", view->db.str, view->table_name.str); - if (thd->lex->if_exists()) - { - push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE, - ER_UNKNOWN_VIEW, - ER_THD(thd, ER_UNKNOWN_VIEW), - name); - continue; - } - if (not_exist) + if (non_existant_views.length()) + non_existant_views.append(','); + non_existant_views.append(name); + + if (!not_exist) { - if (non_existant_views.length()) - non_existant_views.append(','); - non_existant_views.append(name); + wrong_object_name= 1; + my_error(ER_WRONG_OBJECT, MYF(ME_WARNING), view->db.str, + view->table_name.str, "VIEW"); } else - { - if (!wrong_object_name) - { - wrong_object_db= view->db.str; - wrong_object_name= view->table_name.str; - } - } + not_exists_count++; continue; } if (unlikely(mysql_file_delete(key_file_frm, path, MYF(MY_WME)))) - error= TRUE; + delete_error= TRUE; some_views_deleted= TRUE; @@ -1880,17 +1870,16 @@ bool mysql_drop_view(THD *thd, TABLE_LIST *views, enum_drop_mode drop_mode) sp_cache_invalidate(); } - if (unlikely(wrong_object_name)) - { - my_error(ER_WRONG_OBJECT, MYF(0), wrong_object_db, wrong_object_name, - "VIEW"); - } + something_wrong= (delete_error || + (!thd->lex->if_exists() && (not_exists_count || + wrong_object_name))); + if (unlikely(non_existant_views.length())) { - my_error(ER_UNKNOWN_VIEW, MYF(0), non_existant_views.c_ptr_safe()); + my_error(ER_UNKNOWN_VIEW, MYF(something_wrong ? 0 : ME_NOTE), + non_existant_views.c_ptr_safe()); } - something_wrong= error || wrong_object_name || non_existant_views.length(); if (some_views_deleted || !something_wrong) { /* if something goes wrong, bin-log with possible error code, |