MCPcopy Create free account
hub / github.com/MariaDB/server / mysql_drop_view

Function mysql_drop_view

sql/sql_view.cc:1954–2074  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1952*/
1953
1954bool mysql_drop_view(THD *thd, TABLE_LIST *views, enum_drop_mode drop_mode)
1955{
1956 char path[FN_REFLEN + 1];
1957 TABLE_LIST *view;
1958 String non_existant_views;
1959 bool delete_error= FALSE, wrong_object_name= FALSE;
1960 bool some_views_deleted= FALSE;
1961 bool something_wrong= FALSE;
1962 uint not_exists_count= 0, view_count= 0;
1963 DDL_LOG_STATE ddl_log_state;
1964 DBUG_ENTER("mysql_drop_view");
1965
1966 bzero(&ddl_log_state, sizeof(ddl_log_state));
1967
1968 /*
1969 We can't allow dropping of unlocked view under LOCK TABLES since this
1970 might lead to deadlock. But since we can't really lock view with LOCK
1971 TABLES we have to simply prohibit dropping of views.
1972 */
1973
1974 if (unlikely(thd->locked_tables_mode))
1975 {
1976 my_error(ER_LOCK_OR_ACTIVE_TRANSACTION, MYF(0));
1977 DBUG_RETURN(TRUE);
1978 }
1979
1980 if (unlikely(lock_table_names(thd, views, 0,
1981 thd->variables.lock_wait_timeout, 0)))
1982 DBUG_RETURN(TRUE);
1983
1984 for (view= views; view; view= view->next_local)
1985 {
1986 bool not_exist;
1987 size_t length= build_table_filename(path, sizeof(path) - 1, view->db.str,
1988 view->table_name.str, reg_ext, 0);
1989 LEX_CSTRING cpath= { path, length };
1990
1991 if ((not_exist= my_access(path, F_OK)) || !dd_frm_is_view(thd, path))
1992 {
1993 char name[FN_REFLEN];
1994 size_t length= my_snprintf(name, sizeof(name), "%s.%s", view->db.str,
1995 view->table_name.str);
1996 if (non_existant_views.length())
1997 non_existant_views.append(',');
1998 non_existant_views.append(name, length);
1999
2000 if (!not_exist)
2001 {
2002 wrong_object_name= 1;
2003 my_error(ER_WRONG_OBJECT, MYF(ME_WARNING), view->db.str,
2004 view->table_name.str, "VIEW");
2005 }
2006 else
2007 not_exists_count++;
2008 continue;
2009 }
2010 if (!view_count++)
2011 {

Callers 1

sql_parse.ccFile · 0.85

Calls 15

my_errorFunction · 0.85
build_table_filenameFunction · 0.85
my_accessFunction · 0.85
dd_frm_is_viewFunction · 0.85
my_snprintfFunction · 0.85
ddl_log_drop_view_initFunction · 0.85
ddl_log_drop_viewFunction · 0.85
debug_crash_hereFunction · 0.85
tdc_remove_tableFunction · 0.85
sp_cache_invalidateFunction · 0.85
backup_log_ddlFunction · 0.85
ddl_log_update_xidFunction · 0.85

Tested by

no test coverage detected