mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
MDEV-29540 Incorrect sequence values in INSERT SELECT
The population of default values in INSERT SELECT was being performed twice. With sequences, this resulted in every second sequence value being used. With SELECT INSERT we remove the second invokation of table->update_default_fields(). This was already performed in store_values() invoking fill_record_n_invoke_before_triggers() which invoked update_default_fields() previously. We do need to return an error on duplicate values, so the ::store_values is extended to take the ignore option.
This commit is contained in:
@ -3928,9 +3928,7 @@ int select_insert::send_data(List<Item> &values)
|
||||
DBUG_RETURN(0);
|
||||
|
||||
thd->count_cuted_fields= CHECK_FIELD_WARN; // Calculate cuted fields
|
||||
store_values(values);
|
||||
if (table->default_field &&
|
||||
unlikely(table->update_default_fields(info.ignore)))
|
||||
if (store_values(values, info.ignore))
|
||||
DBUG_RETURN(1);
|
||||
thd->count_cuted_fields= CHECK_FIELD_ERROR_FOR_NULL;
|
||||
if (unlikely(thd->is_error()))
|
||||
@ -3988,18 +3986,19 @@ int select_insert::send_data(List<Item> &values)
|
||||
}
|
||||
|
||||
|
||||
void select_insert::store_values(List<Item> &values)
|
||||
bool select_insert::store_values(List<Item> &values, bool ignore_errors)
|
||||
{
|
||||
DBUG_ENTER("select_insert::store_values");
|
||||
bool error;
|
||||
|
||||
if (fields->elements)
|
||||
fill_record_n_invoke_before_triggers(thd, table, *fields, values, 1,
|
||||
TRG_EVENT_INSERT);
|
||||
error= fill_record_n_invoke_before_triggers(thd, table, *fields, values,
|
||||
ignore_errors, TRG_EVENT_INSERT);
|
||||
else
|
||||
fill_record_n_invoke_before_triggers(thd, table, table->field_to_fill(),
|
||||
values, 1, TRG_EVENT_INSERT);
|
||||
error= fill_record_n_invoke_before_triggers(thd, table, table->field_to_fill(),
|
||||
values, ignore_errors, TRG_EVENT_INSERT);
|
||||
|
||||
DBUG_VOID_RETURN;
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
bool select_insert::prepare_eof()
|
||||
@ -4670,10 +4669,10 @@ select_create::binlog_show_create_table(TABLE **tables, uint count)
|
||||
return result;
|
||||
}
|
||||
|
||||
void select_create::store_values(List<Item> &values)
|
||||
bool select_create::store_values(List<Item> &values, bool ignore_errors)
|
||||
{
|
||||
fill_record_n_invoke_before_triggers(thd, table, field, values, 1,
|
||||
TRG_EVENT_INSERT);
|
||||
return fill_record_n_invoke_before_triggers(thd, table, field, values,
|
||||
ignore_errors, TRG_EVENT_INSERT);
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user