MySQL 9.7.0
Source Code Documentation
sql_foreign_key_constraint.h File Reference

Go to the source code of this file.

Enumerations

enum class  enum_fk_dml_type { FK_INSERT , FK_UPDATE , FK_DELETE , FK_DELETE_REPLACE }
 

Functions

bool is_foreign_key_table_opened (THD *thd, const char *db_name, const char *table_name, const char *fk_name, bool *is_unused_table)
 Check if TABLE instance for foreign key is already opened. More...
 
bool check_all_parent_fk_ref (THD *thd, const TABLE *table_c, enum_fk_dml_type dml_type, const Table_share_foreign_key_info *ignore_fk=nullptr)
 Check all foreign key constraints on parent tables for DML operation on a child table. More...
 
bool check_all_child_fk_ref (THD *thd, const TABLE *table_p, enum_fk_dml_type dml_type)
 Check all foreign key constraints on child tables for DML operation on a parent table. More...
 

Enumeration Type Documentation

◆ enum_fk_dml_type

enum class enum_fk_dml_type
strong
Enumerator
FK_INSERT 
FK_UPDATE 
FK_DELETE 
FK_DELETE_REPLACE 

Function Documentation

◆ check_all_child_fk_ref()

bool check_all_child_fk_ref ( THD thd,
const TABLE table_p,
enum_fk_dml_type  dml_type 
)

Check all foreign key constraints on child tables for DML operation on a parent table.

Parameters
thdThread handle.
table_pTABLE instance of a parent table.
dml_typeDML operation type.
Returns
true On error.
false On Success.

◆ check_all_parent_fk_ref()

bool check_all_parent_fk_ref ( THD thd,
const TABLE table_c,
enum_fk_dml_type  dml_type,
const Table_share_foreign_key_info ignore_fk = nullptr 
)

Check all foreign key constraints on parent tables for DML operation on a child table.

Parameters
thdThread handle.
table_cTABLE instance of a child table.
dml_typeDML operation type.
ignore_fkSkip FK check for this foreign key info
Returns
true On error.
false On Success.

During FK cascade, skip parent table foreign key value check because parent row is updated after updating the child row.

◆ is_foreign_key_table_opened()

bool is_foreign_key_table_opened ( THD thd,
const char *  db_name,
const char *  table_name,
const char *  fk_name,
bool *  is_unused_table 
)

Check if TABLE instance for foreign key is already opened.

Parameters
thdThread handle.
db_nameDB name.
table_nameTable name.
fk_nameForeign key name.
[out]is_unused_tableIs set true if table exists in open table list but not in use. For instance tables locked under lock table, exists in open table list but not used. query_id for such tables is reset to 0 after statement execution.
Returns
true If table for foreign key is already opened.
false If table is not opened.