Commit 133cfe39 authored by Eugene Kosov's avatar Eugene Kosov Committed by Sergei Golubchik

MDEV-15645 Assertion `table->insert_values' failed in write_record upon...

MDEV-15645 Assertion `table->insert_values' failed in write_record upon REPLACE into a view with underlying versioned table

Right temporary storage for system versioning operations is table->record[2],
not table->insert_values

Closes #712
parent 7d421359
...@@ -26,3 +26,11 @@ id x current ...@@ -26,3 +26,11 @@ id x current
1 2 0 1 2 0
1 3 1 1 3 1
drop table t; drop table t;
# MDEV-15645 Assertion `table->insert_values' failed in write_record upon REPLACE into a view with underlying versioned table
create or replace table t1 (a int, b int, primary key (a), unique(b)) with system versioning;
insert into t1 values (1,1);
create or replace table t2 (c int);
create or replace view v as select t1.* from t1 join t2;
replace into v (a, b) select a, b from t1;
drop database test;
create database test;
...@@ -29,4 +29,12 @@ replace t values (1, 3); ...@@ -29,4 +29,12 @@ replace t values (1, 3);
select *, current_row(row_end) as current from t for system_time all order by x; select *, current_row(row_end) as current from t for system_time all order by x;
drop table t; drop table t;
--source suite/versioning/common_finish.inc --echo # MDEV-15645 Assertion `table->insert_values' failed in write_record upon REPLACE into a view with underlying versioned table
create or replace table t1 (a int, b int, primary key (a), unique(b)) with system versioning;
insert into t1 values (1,1);
create or replace table t2 (c int);
create or replace view v as select t1.* from t1 join t2;
replace into v (a, b) select a, b from t1;
drop database test;
create database test;
...@@ -1970,13 +1970,12 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info) ...@@ -1970,13 +1970,12 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info)
error= table->file->ha_delete_row(table->record[1]); error= table->file->ha_delete_row(table->record[1]);
else else
{ {
DBUG_ASSERT(table->insert_values); store_record(table, record[2]);
store_record(table,insert_values); restore_record(table, record[1]);
restore_record(table,record[1]);
table->vers_update_end(); table->vers_update_end();
error= table->file->ha_update_row(table->record[1], error= table->file->ha_update_row(table->record[1],
table->record[0]); table->record[0]);
restore_record(table,insert_values); restore_record(table, record[2]);
} }
if (unlikely(error)) if (unlikely(error))
goto err; goto err;
......
...@@ -431,13 +431,6 @@ int mysql_load(THD *thd, const sql_exchange *ex, TABLE_LIST *table_list, ...@@ -431,13 +431,6 @@ int mysql_load(THD *thd, const sql_exchange *ex, TABLE_LIST *table_list,
is_concurrent= (table_list->lock_type == TL_WRITE_CONCURRENT_INSERT); is_concurrent= (table_list->lock_type == TL_WRITE_CONCURRENT_INSERT);
#endif #endif
if (table->versioned(VERS_TIMESTAMP) && handle_duplicates == DUP_REPLACE)
{
// Additional memory may be required to create historical items.
if (table_list->set_insert_values(thd->mem_root))
DBUG_RETURN(TRUE);
}
if (!fields_vars.elements) if (!fields_vars.elements)
{ {
Field_iterator_table_ref field_iterator; Field_iterator_table_ref field_iterator;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment