diff options
author | unknown <gkodinov/kgeorge@macbook.gmz> | 2006-07-31 20:56:06 +0300 |
---|---|---|
committer | unknown <gkodinov/kgeorge@macbook.gmz> | 2006-07-31 20:56:06 +0300 |
commit | b74cb62348c2815c63452dd4d6c50c2510302a6e (patch) | |
tree | 28158b0884d43248238a4a64cea03976bb1963ee /sql | |
parent | 667c73be65bc1c1a6f77d6e2bb140cdddae9ec73 (diff) | |
download | mariadb-git-b74cb62348c2815c63452dd4d6c50c2510302a6e.tar.gz |
Bug #11551: Asymmetric + undocumented behaviour of DROP VIEW and DROP TABLE
made DROP VIEW to continue on error and report an aggregated error
at its end. This makes it similar to DROP TABLE.
mysql-test/r/view.result:
Bug #11551: Asymmetric + undocumented behaviour of DROP VIEW and DROP TABLE
- test case
- changed error message
mysql-test/t/view.test:
Bug #11551: Asymmetric + undocumented behaviour of DROP VIEW and DROP TABLE
- test case
sql/sql_view.cc:
Bug #11551: Asymmetric + undocumented behaviour of DROP VIEW and DROP TABLE
- made DROP VIEW to continue on error and report an aggregated error
Diffstat (limited to 'sql')
-rw-r--r-- | sql/sql_view.cc | 51 |
1 files changed, 38 insertions, 13 deletions
diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 1561ade78af..3c3d50605aa 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -1226,8 +1226,11 @@ bool mysql_drop_view(THD *thd, TABLE_LIST *views, enum_drop_mode drop_mode) DBUG_ENTER("mysql_drop_view"); char path[FN_REFLEN]; TABLE_LIST *view; - bool type= 0; + frm_type_enum type; db_type not_used; + String non_existant_views; + char *wrong_object_db= NULL, *wrong_object_name= NULL; + bool error= FALSE; for (view= views; view; view= view->next_local) { @@ -1235,8 +1238,9 @@ bool mysql_drop_view(THD *thd, TABLE_LIST *views, enum_drop_mode drop_mode) view->table_name, reg_ext, NullS); (void) unpack_filename(path, path); VOID(pthread_mutex_lock(&LOCK_open)); - if (access(path, F_OK) || - (type= (mysql_frm_type(thd, path, ¬_used) != FRMTYPE_VIEW))) + type= FRMTYPE_ERROR; + if (access(path, F_OK) || + FRMTYPE_VIEW != (type= mysql_frm_type(thd, path, ¬_used))) { char name[FN_REFLEN]; my_snprintf(name, sizeof(name), "%s.%s", view->db, view->table_name); @@ -1248,25 +1252,46 @@ bool mysql_drop_view(THD *thd, TABLE_LIST *views, enum_drop_mode drop_mode) VOID(pthread_mutex_unlock(&LOCK_open)); continue; } - if (type) - my_error(ER_WRONG_OBJECT, MYF(0), view->db, view->table_name, "VIEW"); + if (type == FRMTYPE_TABLE) + { + if (!wrong_object_name) + { + wrong_object_db= view->db; + wrong_object_name= view->table_name; + } + } else - my_error(ER_BAD_TABLE_ERROR, MYF(0), name); - goto err; + { + if (non_existant_views.length()) + non_existant_views.append(','); + non_existant_views.append(String(view->table_name,system_charset_info)); + } + VOID(pthread_mutex_unlock(&LOCK_open)); + continue; } if (my_delete(path, MYF(MY_WME))) - goto err; + error= TRUE; query_cache_invalidate3(thd, view, 0); sp_cache_invalidate(); VOID(pthread_mutex_unlock(&LOCK_open)); } + if (error) + { + DBUG_RETURN(TRUE); + } + if (wrong_object_name) + { + my_error(ER_WRONG_OBJECT, MYF(0), wrong_object_db, wrong_object_name, + "VIEW"); + DBUG_RETURN(TRUE); + } + if (non_existant_views.length()) + { + my_error(ER_BAD_TABLE_ERROR, MYF(0), non_existant_views.c_ptr()); + DBUG_RETURN(TRUE); + } send_ok(thd); DBUG_RETURN(FALSE); - -err: - VOID(pthread_mutex_unlock(&LOCK_open)); - DBUG_RETURN(TRUE); - } |