1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

create a reusable function that tells what FK actions can write

and few indentation changes
This commit is contained in:
Sergei Golubchik
2018-02-23 13:41:46 +01:00
parent 17f8e0ecdf
commit 794f71cbc4
5 changed files with 21 additions and 19 deletions

View File

@ -4370,12 +4370,11 @@ handle_table(THD *thd, Query_tables_list *prelocking_ctx,
while ((fk= fk_list_it++))
{
// FK_OPTION_RESTRICT and FK_OPTION_NO_ACTION only need read access
static bool can_write[]= { true, false, true, true, false, true };
uint8 op= table_list->trg_event_map;
thr_lock_type lock_type;
if ((op & (1 << TRG_EVENT_DELETE) && can_write[fk->delete_method])
|| (op & (1 << TRG_EVENT_UPDATE) && can_write[fk->update_method]))
if ((op & (1 << TRG_EVENT_DELETE) && fk_modifies_child(fk->delete_method))
|| (op & (1 << TRG_EVENT_UPDATE) && fk_modifies_child(fk->update_method)))
lock_type= TL_WRITE_ALLOW_WRITE;
else
lock_type= TL_READ;