MySQL 8.4.3
Source Code Documentation
|
#include "sql/dd_sql_view.h"
#include <string.h>
#include <sys/types.h>
#include <set>
#include <vector>
#include "lex_string.h"
#include "my_dbug.h"
#include "my_inttypes.h"
#include "my_sqlcommand.h"
#include "my_sys.h"
#include "mysql/components/services/log_builtins.h"
#include "mysql/strings/m_ctype.h"
#include "mysqld_error.h"
#include "sql/auth/auth_common.h"
#include "sql/dd/cache/dictionary_client.h"
#include "sql/dd/dd.h"
#include "sql/dd/dd_view.h"
#include "sql/dd/dictionary.h"
#include "sql/dd/object_id.h"
#include "sql/dd/string_type.h"
#include "sql/dd/types/schema.h"
#include "sql/dd/types/view.h"
#include "sql/debug_sync.h"
#include "sql/derror.h"
#include "sql/error_handler.h"
#include "sql/handler.h"
#include "sql/mdl.h"
#include "sql/mysqld.h"
#include "sql/set_var.h"
#include "sql/sp_head.h"
#include "sql/sql_alter.h"
#include "sql/sql_base.h"
#include "sql/sql_class.h"
#include "sql/sql_const.h"
#include "sql/sql_db.h"
#include "sql/sql_error.h"
#include "sql/sql_lex.h"
#include "sql/sql_view.h"
#include "sql/strfunc.h"
#include "sql/system_variables.h"
#include "sql/table.h"
#include "sql/thd_raii.h"
#include "sql/transaction.h"
#include "thr_lock.h"
Classes | |
class | View_metadata_updater_context |
RAII class to set the context for View_metadata_updater. More... | |
class | View_metadata_updater_error_handler |
A error handler to convert all the errors except deadlock, lock wait timeout and stack overrun to ER_VIEW_INVALID while updating views metadata. More... | |
Namespaces | |
namespace | dd |
The version of the current data dictionary table definitions. | |
Functions | |
template<typename T > | |
static bool | prepare_view_tables_list (THD *thd, const char *db, const char *tbl_or_sf_name, bool skip_same_db, MEM_ROOT *mem_root, std::vector< Table_ref * > *views) |
Prepare Table_ref object for views referencing Base Table/ View/ Stored routine "db.tbl_or_sf_name". More... | |
template<typename T > | |
static bool | mark_all_views_invalid (THD *thd, const char *db, const char *tbl_or_sf_name, const std::vector< Table_ref * > *views_list, bool skip_same_db, bool commit_dd_changes, MEM_ROOT *mem_root) |
Helper method to mark all views state as invalid. More... | |
static bool | open_views_and_update_metadata (THD *thd, const std::vector< Table_ref * > *views, bool commit_dd_changes, Uncommitted_tables_guard *uncommitted_tables) |
Helper method to. More... | |
static bool | is_view_metadata_update_needed (THD *thd, const char *db, const char *name) |
Helper method to check if view metadata update is required for the DDL operation. More... | |
template<typename T > | |
static bool | update_view_metadata (THD *thd, const char *db, const char *tbl_or_sf_name, bool commit_dd_changes, Uncommitted_tables_guard *uncommitted_tables) |
Helper method to update referencing view's metadata. More... | |
static bool | update_referencing_views_metadata (THD *thd, const char *db, const char *table_name, const char *new_db, const char *new_table_name, bool commit_dd_changes, Uncommitted_tables_guard *uncommitted_tables) |
bool | update_referencing_views_metadata (THD *thd, const Table_ref *table, const char *new_db, const char *new_table_name, bool commit_dd_changes, Uncommitted_tables_guard *uncommitted_tables) |
Update metadata of views referencing "table" being renamed and views referencing (if there any) new table name "new_db.new_table_name". More... | |
bool | update_referencing_views_metadata (THD *thd, const Table_ref *table, bool commit_dd_changes, Uncommitted_tables_guard *uncommitted_tables) |
Update metadata of views referencing the table. More... | |
bool | update_referencing_views_metadata (THD *thd, const char *db_name, const char *table_name, bool commit_dd_changes, Uncommitted_tables_guard *uncommitted_tables) |
Update metadata of views referencing the table. More... | |
bool | update_referencing_views_metadata (THD *thd, const sp_name *spname) |
Method to update metadata of views using stored function. More... | |
template<typename T > | |
static bool | mark_referencing_views_invalid (THD *thd, const char *db, const char *tbl_or_sf_name, bool skip_same_db, bool commit_dd_changes, MEM_ROOT *mem_root) |
Helper method to mark referencing views as invalid. More... | |
bool | mark_referencing_views_invalid (THD *thd, const Table_ref *table, bool skip_same_db, bool commit_dd_changes, MEM_ROOT *mem_root) |
Mark views referencing the table as invalid. More... | |
bool | mark_referencing_views_invalid (THD *thd, const sp_name *spname, MEM_ROOT *mem_root) |
Mark views using stored function as invalid. More... | |
std::string | push_view_warning_or_error (THD *thd, const char *db, const char *view_name) |
Push error or warnings in case a view is invalid and return the error message to the caller. More... | |
|
static |
Helper method to check if view metadata update is required for the DDL operation.
thd | Thread handle. |
db | Database name. |
name | Base table/ View/ Stored routine name. |
true | if view metadata update is required. |
false | if view metadata update is NOT required. |
|
static |
Helper method to mark all views state as invalid.
If operation is drop operation then view referencing it becomes invalid. This method is called to mark state of all the referencing views as invalid in such case.
T | Type of object (View_table/View_routine) to fetch view names from. |
thd | Current thread. |
db | Database name. |
tbl_or_sf_name | Base table/ View/ Stored function name. |
views_list | Table_ref objects of the referencing views. |
skip_same_db | Indicates whether it is OK to skip views belonging to the same database as table (as they will be dropped anyway). |
commit_dd_changes | Indicates whether changes to DD need to be committed. |
mem_root | Memory root for allocation of temporary objects which will be cleared after processing referenced table/view/routine. |
false | Success. |
true | Failure. |
|
static |
Helper method to mark referencing views as invalid.
T | Type of object (View_table/View_routine) to fetch referencing view names. |
thd | Current thread. |
db | Database name. |
tbl_or_sf_name | Base table/ View/ Stored function name. |
skip_same_db | Indicates whether it is OK to skip views belonging to the same database as table (as they will be dropped anyway). |
commit_dd_changes | Indicates whether changes to DD need to be committed. |
mem_root | Memory root for allocation of temporary objects which will be cleared after each call to this function. |
false | Success. |
true | Failure. |
Mark views using stored function as invalid.
thd | Thread handle. |
spname | Name of the stored function. |
mem_root | Memory root for allocation of temporary objects which will be cleared after each call to this function. |
false | Success. |
true | Failure. |
bool mark_referencing_views_invalid | ( | THD * | thd, |
const Table_ref * | table, | ||
bool | skip_same_db, | ||
bool | commit_dd_changes, | ||
MEM_ROOT * | mem_root | ||
) |
Mark views referencing the table as invalid.
thd | Thread handle. |
table | Views referencing this table need to be marked as invalid. |
skip_same_db | Indicates whether it is OK to skip views belonging to the same database as table (as they will be dropped anyway). |
commit_dd_changes | Indicates whether changes to DD need to be committed. |
mem_root | Memory root for allocation of temporary objects which will be cleared after each call to this function. |
false | Success. |
true | Failure. |
|
static |
Helper method to.
thd | Thread handle. | |
views | Table_ref objects of the views. | |
commit_dd_changes | Indicates whether changes to DD need to be committed. | |
[in,out] | uncommitted_tables | Helper class to store list of views which shares need to be removed from TDC if we fail to commit changes to DD. Only used if commit_dd_changes is false. |
false | Success. |
true | Failure. |
|
static |
Prepare Table_ref object for views referencing Base Table/ View/ Stored routine "db.tbl_or_sf_name".
T | Type of object (View_table/View_routine) to fetch view names from. |
thd | Current thread. | |
db | Database name. | |
tbl_or_sf_name | Base table/ View/ Stored function name. | |
skip_same_db | Indicates whether it is OK to skip views belonging to the same database as table (as they will be dropped anyway). | |
mem_root | Memory root for allocation of temporary objects which will be cleared after processing this table/view/routine. | |
[out] | views | Table_ref objects for views. |
false | Success. |
true | Failure. |
std::string push_view_warning_or_error | ( | THD * | thd, |
const char * | db, | ||
const char * | view_name | ||
) |
Push error or warnings in case a view is invalid and return the error message to the caller.
thd | Thread handle. |
db | Database name. |
view_name | View name. |
returns The error/warning message string.
|
static |
bool update_referencing_views_metadata | ( | THD * | thd, |
const char * | db_name, | ||
const char * | table_name, | ||
bool | commit_dd_changes, | ||
Uncommitted_tables_guard * | uncommitted_tables | ||
) |
Update metadata of views referencing the table.
thd | Thread handle. | |
db_name | Database name. | |
table_name | Update metadata of views referencing this table. | |
commit_dd_changes | Indicates whether changes to DD need to be committed. | |
[in,out] | uncommitted_tables | Helper class to store list of views which shares need to be removed from TDC if we fail to commit changes to DD. Only used if commit_dd_changes is false. |
false | Success. |
true | Failure. |
Method to update metadata of views using stored function.
thd | Thread handle. |
spname | Name of the stored function. |
false | Success. |
true | Failure. |
bool update_referencing_views_metadata | ( | THD * | thd, |
const Table_ref * | table, | ||
bool | commit_dd_changes, | ||
Uncommitted_tables_guard * | uncommitted_tables | ||
) |
Update metadata of views referencing the table.
thd | Thread handle. | |
table | Update metadata of views referencing this table. | |
commit_dd_changes | Indicates whether changes to DD need to be committed. | |
[in,out] | uncommitted_tables | Helper class to store list of views which shares need to be removed from TDC if we fail to commit changes to DD. Only used if commit_dd_changes is false. |
false | Success. |
true | Failure. |
bool update_referencing_views_metadata | ( | THD * | thd, |
const Table_ref * | table, | ||
const char * | new_db, | ||
const char * | new_table_name, | ||
bool | commit_dd_changes, | ||
Uncommitted_tables_guard * | uncommitted_tables | ||
) |
Update metadata of views referencing "table" being renamed and views referencing (if there any) new table name "new_db.new_table_name".
thd | Thread handle. | |
table | Update metadata of views referencing this table. | |
new_db | New db name set in the rename operation. | |
new_table_name | New table name set in the rename | |
commit_dd_changes | Indicates whether changes to DD need to be committed. | |
[in,out] | uncommitted_tables | Helper class to store list of views which shares need to be removed from TDC if we fail to commit changes to DD. Only used if commit_dd_changes is false. |
false | Success. |
true | Failure. |
|
static |
Helper method to update referencing view's metadata.
T | Type of object (View_table/View_routine) to fetch referencing view names. |
thd | Current thread. | |
db | Database name. | |
tbl_or_sf_name | Base table/ View/ Stored function name. | |
commit_dd_changes | Indicates whether changes to DD need to be committed. | |
[in,out] | uncommitted_tables | Helper class to store list of views which shares need to be removed from TDC if we fail to commit changes to DD. Only used if commit_dd_changes is false. |
false | Success. |
true | Failure. |