1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

MDEV-15413 Unexpected errors upon CREATE TABLE .. WITH SYSTEM VERSIONING AS SELECT ...

numerous fixes for CREATE ... SELECT with system versioning:
In CREATE ... SELECT the table is created based on the result set,
field properties do not count. That is
* field invisibility is *not* copied over
* AS ROW START/END is *not* copied over
* the history is *not* copied over
* system row_start/row_end fields can *not* be created from the SELECT part
This commit is contained in:
Sergei Golubchik
2018-04-02 19:35:27 +02:00
parent 72dd813f7e
commit 9bd3af97df
10 changed files with 114 additions and 191 deletions

View File

@ -3591,8 +3591,7 @@ select_insert::select_insert(THD *thd_arg, TABLE_LIST *table_list_par,
select_result_interceptor(thd_arg),
table_list(table_list_par), table(table_par), fields(fields_par),
autoinc_value_of_last_inserted_row(0),
insert_into_view(table_list_par && table_list_par->view != 0),
versioned_write(false)
insert_into_view(table_list_par && table_list_par->view != 0)
{
bzero((char*) &info,sizeof(info));
info.handle_duplicates= duplic;
@ -3627,8 +3626,6 @@ select_insert::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
check_insert_fields(thd, table_list, *fields, values,
!insert_into_view, 1, &map));
versioned_write= table_list->table->versioned();
if (!res && fields->elements)
{
bool saved_abort_on_warning= thd->abort_on_warning;
@ -3841,7 +3838,8 @@ int select_insert::send_data(List<Item> &values)
table->auto_increment_field_not_null= FALSE;
DBUG_RETURN(1);
}
table->vers_write= versioned_write;
table->vers_write= table->versioned();
if (table_list) // Not CREATE ... SELECT
{
switch (table_list->view_check_option(thd, info.ignore)) {
@ -4139,7 +4137,7 @@ TABLE *select_create::create_table_from_items(THD *thd,
/* Add selected items to field list */
List_iterator_fast<Item> it(*items);
Item *item;
DBUG_ENTER("create_table_from_items");
DBUG_ENTER("select_create::create_table_from_items");
tmp_table.s= &share;
init_tmp_table_share(thd, &share, "", 0, "", "");
@ -4152,6 +4150,10 @@ TABLE *select_create::create_table_from_items(THD *thd,
if (!opt_explicit_defaults_for_timestamp)
promote_first_timestamp_column(&alter_info->create_list);
if (create_info->vers_fix_system_fields(thd, alter_info, *create_table,
true))
DBUG_RETURN(NULL);
while ((item=it++))
{
Field *tmp_field= item->create_field_for_create_select(&tmp_table);
@ -4188,11 +4190,8 @@ TABLE *select_create::create_table_from_items(THD *thd,
alter_info->create_list.push_back(cr_field, thd->mem_root);
}
if (create_info->vers_fix_system_fields(thd, alter_info, *create_table,
select_tables, items, &versioned_write))
{
if (create_info->vers_check_system_fields(thd, alter_info, *create_table))
DBUG_RETURN(NULL);
}
DEBUG_SYNC(thd,"create_table_select_before_create");
@ -4436,11 +4435,16 @@ select_create::prepare(List<Item> &_values, SELECT_LEX_UNIT *u)
}
/* First field to copy */
field= table->field+table->s->fields - values.elements;
field= table->field+table->s->fields;
/* Mark all fields that are given values */
for (Field **f= field ; *f ; f++)
bitmap_set_bit(table->write_set, (*f)->field_index);
for (uint n= values.elements; n; )
{
if ((*--field)->invisible >= INVISIBLE_SYSTEM)
continue;
n--;
bitmap_set_bit(table->write_set, (*field)->field_index);
}
table->next_number_field=table->found_next_number_field;