mirror of
https://github.com/MariaDB/server.git
synced 2025-07-20 10:24:14 +03:00
create a reusable function that tells what FK actions can write
and few indentation changes
This commit is contained in:
@ -4370,12 +4370,11 @@ handle_table(THD *thd, Query_tables_list *prelocking_ctx,
|
|||||||
while ((fk= fk_list_it++))
|
while ((fk= fk_list_it++))
|
||||||
{
|
{
|
||||||
// FK_OPTION_RESTRICT and FK_OPTION_NO_ACTION only need read access
|
// 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;
|
uint8 op= table_list->trg_event_map;
|
||||||
thr_lock_type lock_type;
|
thr_lock_type lock_type;
|
||||||
|
|
||||||
if ((op & (1 << TRG_EVENT_DELETE) && can_write[fk->delete_method])
|
if ((op & (1 << TRG_EVENT_DELETE) && fk_modifies_child(fk->delete_method))
|
||||||
|| (op & (1 << TRG_EVENT_UPDATE) && can_write[fk->update_method]))
|
|| (op & (1 << TRG_EVENT_UPDATE) && fk_modifies_child(fk->update_method)))
|
||||||
lock_type= TL_WRITE_ALLOW_WRITE;
|
lock_type= TL_WRITE_ALLOW_WRITE;
|
||||||
else
|
else
|
||||||
lock_type= TL_READ;
|
lock_type= TL_READ;
|
||||||
|
@ -912,12 +912,12 @@ got_error:
|
|||||||
wild_num - number of wildcards used in optional SELECT clause
|
wild_num - number of wildcards used in optional SELECT clause
|
||||||
field_list - list of items in optional SELECT clause
|
field_list - list of items in optional SELECT clause
|
||||||
conds - conditions
|
conds - conditions
|
||||||
l
|
|
||||||
RETURN VALUE
|
RETURN VALUE
|
||||||
FALSE OK
|
FALSE OK
|
||||||
TRUE error
|
TRUE error
|
||||||
*/
|
*/
|
||||||
int mysql_prepare_delete(THD *thd, TABLE_LIST *table_list,
|
int mysql_prepare_delete(THD *thd, TABLE_LIST *table_list,
|
||||||
uint wild_num, List<Item> &field_list, Item **conds,
|
uint wild_num, List<Item> &field_list, Item **conds,
|
||||||
bool *delete_while_scanning)
|
bool *delete_while_scanning)
|
||||||
{
|
{
|
||||||
|
@ -3656,9 +3656,9 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
|
|||||||
if (key->type == Key::FOREIGN_KEY)
|
if (key->type == Key::FOREIGN_KEY)
|
||||||
{
|
{
|
||||||
fk_key_count++;
|
fk_key_count++;
|
||||||
if (((Foreign_key *)key)->validate(alter_info->create_list))
|
|
||||||
DBUG_RETURN(TRUE);
|
|
||||||
Foreign_key *fk_key= (Foreign_key*) key;
|
Foreign_key *fk_key= (Foreign_key*) key;
|
||||||
|
if (fk_key->validate(alter_info->create_list))
|
||||||
|
DBUG_RETURN(TRUE);
|
||||||
if (fk_key->ref_columns.elements &&
|
if (fk_key->ref_columns.elements &&
|
||||||
fk_key->ref_columns.elements != fk_key->columns.elements)
|
fk_key->ref_columns.elements != fk_key->columns.elements)
|
||||||
{
|
{
|
||||||
@ -4455,12 +4455,8 @@ bool Column_definition::sp_prepare_create_field(THD *thd, MEM_ROOT *mem_root)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool
|
static bool vers_prepare_keys(THD *thd, HA_CREATE_INFO *create_info,
|
||||||
vers_prepare_keys(THD *thd,
|
Alter_info *alter_info, KEY **key_info, uint key_count)
|
||||||
HA_CREATE_INFO *create_info,
|
|
||||||
Alter_info *alter_info,
|
|
||||||
KEY **key_info,
|
|
||||||
uint key_count)
|
|
||||||
{
|
{
|
||||||
DBUG_ASSERT(create_info->versioned());
|
DBUG_ASSERT(create_info->versioned());
|
||||||
|
|
||||||
|
@ -8554,6 +8554,12 @@ LEX_CSTRING *fk_option_name(enum_fk_option opt)
|
|||||||
return names + opt;
|
return names + opt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool fk_modifies_child(enum_fk_option opt)
|
||||||
|
{
|
||||||
|
static bool can_write[]= { false, false, true, true, false, true };
|
||||||
|
return can_write[opt];
|
||||||
|
}
|
||||||
|
|
||||||
enum TR_table::enabled TR_table::use_transaction_registry= TR_table::MAYBE;
|
enum TR_table::enabled TR_table::use_transaction_registry= TR_table::MAYBE;
|
||||||
|
|
||||||
TR_table::TR_table(THD* _thd, bool rw) :
|
TR_table::TR_table(THD* _thd, bool rw) :
|
||||||
|
@ -1620,6 +1620,7 @@ typedef struct st_foreign_key_info
|
|||||||
} FOREIGN_KEY_INFO;
|
} FOREIGN_KEY_INFO;
|
||||||
|
|
||||||
LEX_CSTRING *fk_option_name(enum_fk_option opt);
|
LEX_CSTRING *fk_option_name(enum_fk_option opt);
|
||||||
|
bool fk_modifies_child(enum_fk_option opt);
|
||||||
|
|
||||||
#define MY_I_S_MAYBE_NULL 1U
|
#define MY_I_S_MAYBE_NULL 1U
|
||||||
#define MY_I_S_UNSIGNED 2U
|
#define MY_I_S_UNSIGNED 2U
|
||||||
@ -1943,7 +1944,7 @@ struct TABLE_LIST
|
|||||||
Prepare TABLE_LIST that consists of one table instance to use in
|
Prepare TABLE_LIST that consists of one table instance to use in
|
||||||
open_and_lock_tables
|
open_and_lock_tables
|
||||||
*/
|
*/
|
||||||
inline void init_one_table(const LEX_CSTRING *db_arg,
|
inline void init_one_table(const LEX_CSTRING *db_arg,
|
||||||
const LEX_CSTRING *table_name_arg,
|
const LEX_CSTRING *table_name_arg,
|
||||||
const LEX_CSTRING *alias_arg,
|
const LEX_CSTRING *alias_arg,
|
||||||
enum thr_lock_type lock_type_arg)
|
enum thr_lock_type lock_type_arg)
|
||||||
|
Reference in New Issue
Block a user