Commit ab503215 authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-29813 REPLACE/IGNORE does not work with historical records in InnoDB

note that replace no longer supports system_versioning_insert_history,
the test case is only for ignore
parent 3b6742a1
......@@ -295,3 +295,27 @@ ERROR 42000: Access denied; you need (at least one of) the SUPER, BINLOG REPLAY
use test;
# restart: --secure-timestamp=NO
drop tables t1, t2, t3;
#
# MDEV-29813 REPLACE/IGNORE does not work with historical records in InnoDB
#
set sql_mode='STRICT_ALL_TABLES';
create or replace table t1 (a int) with system versioning;
set system_versioning_insert_history= on;
insert into t1 (a,row_start,row_end) values (1,'2022-01-01','2023-01-01'),(1,'2022-01-01','2023-01-01');
select a,row_start,row_end into outfile 'mdev29813.txt' from t1 for system_time all;
create or replace table t1 (a int primary key) with system versioning;
load data infile 'mdev29813.txt' ignore into table t1 (a,row_start,row_end);
Warnings:
Warning 1062 Duplicate entry '1' for key 'PRIMARY'
select a,row_start,row_end from t1 for system_time all;
a row_start row_end
1 2022-01-01 00:00:00.000000 2023-01-01 00:00:00.000000
create or replace table t1 (a int primary key) with system versioning;
insert ignore into t1 (a,row_start,row_end) values (1,'2022-01-01','2023-01-01'),(1,'2022-01-01','2023-01-01');
Warnings:
Warning 1062 Duplicate entry '1' for key 'PRIMARY'
select a,row_start,row_end from t1 for system_time all;
a row_start row_end
1 2022-01-01 00:00:00.000000 2023-01-01 00:00:00.000000
drop table t1;
set sql_mode=default;
......@@ -239,4 +239,27 @@ use test;
drop tables t1, t2, t3;
--echo #
--echo # MDEV-29813 REPLACE/IGNORE does not work with historical records in InnoDB
--echo #
set sql_mode='STRICT_ALL_TABLES';
create or replace table t1 (a int) with system versioning;
set system_versioning_insert_history= on;
insert into t1 (a,row_start,row_end) values (1,'2022-01-01','2023-01-01'),(1,'2022-01-01','2023-01-01');
select a,row_start,row_end into outfile 'mdev29813.txt' from t1 for system_time all;
create or replace table t1 (a int primary key) with system versioning;
load data infile 'mdev29813.txt' ignore into table t1 (a,row_start,row_end);
select a,row_start,row_end from t1 for system_time all;
create or replace table t1 (a int primary key) with system versioning;
insert ignore into t1 (a,row_start,row_end) values (1,'2022-01-01','2023-01-01'),(1,'2022-01-01','2023-01-01');
select a,row_start,row_end from t1 for system_time all;
--let $datadir= `select @@datadir`
--remove_file $datadir/test/mdev29813.txt
drop table t1;
set sql_mode=default;
-- source suite/versioning/common_finish.inc
......@@ -284,11 +284,11 @@ int TABLE::delete_row()
vers_update_end();
int err= file->ha_update_row(record[1], record[0]);
/*
MDEV-23644: we get HA_ERR_FOREIGN_DUPLICATE_KEY iff we already got history
MDEV-23644: we get HA_ERR_FOUND_DUPP_KEY iff we already got history
row with same trx_id which is the result of foreign key action, so we
don't need one more history row.
*/
if (err == HA_ERR_FOREIGN_DUPLICATE_KEY)
if (err == HA_ERR_FOUND_DUPP_KEY)
return file->ha_delete_row(record[0]);
return err;
}
......
......@@ -2348,7 +2348,7 @@ row_ins_duplicate_error_in_clust(
&trx_id_len);
ut_ad(trx_id_len == DATA_TRX_ID_LEN);
if (trx->id == trx_read_trx_id(trx_id)) {
err = DB_FOREIGN_DUPLICATE_KEY;
err = DB_DUPLICATE_KEY;
}
}
goto func_exit;
......
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