mirror of
https://github.com/MariaDB/server.git
synced 2025-07-27 18:02:13 +03:00
MDEV-10201 Bad results for CREATE TABLE t1 (a INT DEFAULT b, b INT DEFAULT 4)
Optionally do table->update_default_fields() even for INSERT that supposedly provides values for all column. Because these "values" might be DEFAULT, which would need table->update_default_fields() at the end. Also set Item_default_value::used_tables() from the default expression. Non-zero used_field() means that mysql_insert() will initialize all fields to their default values (with restore_record()) even if all columns are later provided with values. Because default expressions may refer to other columns and they must be initialized.
This commit is contained in:
@ -8102,6 +8102,7 @@ fill_record(THD *thd, TABLE *table, Field **ptr, List<Item> &values,
|
||||
{
|
||||
List_iterator_fast<Item> v(values);
|
||||
List<TABLE> tbl_list;
|
||||
bool all_fields_have_values= true;
|
||||
Item *value;
|
||||
Field *field;
|
||||
bool abort_on_warning_saved= thd->abort_on_warning;
|
||||
@ -8154,9 +8155,11 @@ fill_record(THD *thd, TABLE *table, Field **ptr, List<Item> &values,
|
||||
else
|
||||
if (value->save_in_field(field, 0) < 0)
|
||||
goto err;
|
||||
field->set_explicit_default(value);
|
||||
all_fields_have_values &= field->set_explicit_default(value);
|
||||
}
|
||||
/* There is no default fields to update, as all fields are updated */
|
||||
if (!all_fields_have_values && table->default_field &&
|
||||
table->update_default_fields(0, ignore_errors))
|
||||
goto err;
|
||||
/* Update virtual fields */
|
||||
thd->abort_on_warning= FALSE;
|
||||
if (table->vfield &&
|
||||
|
Reference in New Issue
Block a user