mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
MDEV-11842 Fail to insert on a table where a field has no default
has_no_default_value() should only fail the insert in the strict mode. Additionally, don't check for "all fields are given values" twice, it'll produce duplicate warnings.
This commit is contained in:
@ -325,7 +325,7 @@ static bool has_no_default_value(THD *thd, Field *field, TABLE_LIST *table_list)
|
||||
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, ER_NO_DEFAULT_FOR_FIELD,
|
||||
ER_THD(thd, ER_NO_DEFAULT_FOR_FIELD), field->field_name);
|
||||
}
|
||||
return true;
|
||||
return thd->really_abort_on_warning();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -891,7 +891,12 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
|
||||
|
||||
if (fields.elements || !value_count || table_list->view != 0)
|
||||
{
|
||||
if (check_that_all_fields_are_given_values(thd, table, table_list))
|
||||
if (table->triggers &&
|
||||
table->triggers->has_triggers(TRG_EVENT_INSERT, TRG_ACTION_BEFORE))
|
||||
{
|
||||
/* BEFORE INSERT triggers exist, the check will be done later, per row */
|
||||
}
|
||||
else if (check_that_all_fields_are_given_values(thd, table, table_list))
|
||||
{
|
||||
error= 1;
|
||||
goto values_loop_end;
|
||||
|
Reference in New Issue
Block a user