MySQL 8.3.0
Source Code Documentation
dd_sql_view.h File Reference

Go to the source code of this file.

Classes

class  Uncommitted_tables_guard
 Guard class which allows to invalidate TDC entries for specific tables/views. More...
 

Functions

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 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 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 sp_name *spname)
 Method to update metadata of views using stored function. 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...
 

Function Documentation

◆ mark_referencing_views_invalid() [1/2]

bool mark_referencing_views_invalid ( THD thd,
const sp_name spname,
MEM_ROOT mem_root 
)

Mark views using stored function as invalid.

Parameters
thdThread handle.
spnameName of the stored function.
mem_rootMemory root for allocation of temporary objects which will be cleared after each call to this function.
Note
This call is a version of update_referencing_views_metadata(), which is optimized for DROP DATABASE case.
Return values
falseSuccess.
trueFailure.

◆ mark_referencing_views_invalid() [2/2]

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.

Parameters
thdThread handle.
tableViews referencing this table need to be marked as invalid.
skip_same_dbIndicates whether it is OK to skip views belonging to the same database as table (as they will be dropped anyway).
commit_dd_changesIndicates whether changes to DD need to be committed.
mem_rootMemory root for allocation of temporary objects which will be cleared after each call to this function.
Note
In case when commit_dd_changes is false, the caller must rollback both statement and transaction on failure, before any further accesses to DD. This is because such a failure might be caused by a deadlock, which requires rollback before any other operations on SE (including reads using attachable transactions) can be done. If case when commit_dd_changes is true this function will handle transaction rollback itself.
This call is a version of update_referencing_views_metadata(), which is optimized for DROP DATABASE case.
Return values
falseSuccess.
trueFailure.

◆ push_view_warning_or_error()

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.

Parameters
thdThread handle.
dbDatabase name.
view_nameView name.

returns The error/warning message string.

◆ update_referencing_views_metadata() [1/4]

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.

Parameters
thdThread handle.
db_nameDatabase name.
table_nameUpdate metadata of views referencing this table.
commit_dd_changesIndicates whether changes to DD need to be committed.
[in,out]uncommitted_tablesHelper 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.
Note
In case when commit_dd_changes is false, the caller must rollback both statement and transaction on failure, before any further accesses to DD. This is because such a failure might be caused by a deadlock, which requires rollback before any other operations on SE (including reads using attachable transactions) can be done. If case when commit_dd_changes is true this function will handle transaction rollback itself.
Return values
falseSuccess.
trueFailure.

◆ update_referencing_views_metadata() [2/4]

bool update_referencing_views_metadata ( THD thd,
const sp_name spname 
)

Method to update metadata of views using stored function.

Parameters
thdThread handle.
spnameName of the stored function.
Return values
falseSuccess.
trueFailure.

◆ update_referencing_views_metadata() [3/4]

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.

Parameters
thdThread handle.
tableUpdate metadata of views referencing this table.
commit_dd_changesIndicates whether changes to DD need to be committed.
[in,out]uncommitted_tablesHelper 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.
Note
In case when commit_dd_changes is false, the caller must rollback both statement and transaction on failure, before any further accesses to DD. This is because such a failure might be caused by a deadlock, which requires rollback before any other operations on SE (including reads using attachable transactions) can be done. If case when commit_dd_changes is true this function will handle transaction rollback itself.
Return values
falseSuccess.
trueFailure.

◆ update_referencing_views_metadata() [4/4]

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".

Parameters
thdThread handle.
tableUpdate metadata of views referencing this table.
new_dbNew db name set in the rename operation.
new_table_nameNew table name set in the rename
commit_dd_changesIndicates whether changes to DD need to be committed.
[in,out]uncommitted_tablesHelper 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.
Note
In case when commit_dd_changes is false, the caller must rollback both statement and transaction on failure, before any further accesses to DD. This is because such a failure might be caused by a deadlock, which requires rollback before any other operations on SE (including reads using attachable transactions) can be done. If case when commit_dd_changes is true this function will handle transaction rollback itself. operation.
Return values
falseSuccess.
trueFailure.