1
0
mirror of https://github.com/MariaDB/server.git synced 2025-11-06 13:10:12 +03:00

Fix for BUG#38018 INSERT SELECT ON DUPLICATE KEY UPDATE and LOAD DATA CONCURRENT REPLACE

used TL_WRITE_CONCURRENT_INSERT though they may update/delete a row. This could cause concurrent SELECTs
to see a changing table while the SELECT happens, or if the query was made of a group of SELECTs,
some SELECTs would see different versions of the table. And anyway versioning in Maria was so far coded
to support only insertions. REPLACE SELECT, INSERT VALUES ON DUPLICATE KEY UPDATE, LOAD DATA REPLACE
were ok.

mysql-test/r/maria2.result:
  result. Without the code fix, the assertion added to ha_maria::update_row() would fire twice.
mysql-test/t/maria2.test:
  test when INSERT ON DUPLICATE KEY UPDATE and LOAD DATA CONCURRENT REPLACE do update rows
storage/maria/ha_maria.cc:
  Assert that update_row and delete_row never see TL_WRITE_CONCURRENT_INSERT.
  INSERT SELECT ON DUPLICATE KEY UPDATE and LOAD DATA CONCURRENT REPLACE
  must upgrade TL_WRITE_CONCURRENT_INSERT to TL_WRITE because they may update/delete a row.
This commit is contained in:
Guilhem Bichot
2008-07-11 16:33:47 +02:00
parent dddc6fd2ef
commit 6f8b889ae5
3 changed files with 64 additions and 6 deletions

View File

@@ -16,3 +16,29 @@ check table t1 extended;
Table Op Msg_type Msg_text
test.t1 check status OK
drop table t1;
create table t1(id int, s char(1), unique(s)) engine=maria;
insert into t1 values(1,"a") on duplicate key update t1.id=t1.id+1;
insert into t1 values(1,"a") on duplicate key update t1.id=t1.id+1;
insert into t1 select 1,"a" on duplicate key update t1.id=t1.id+1;
select * from t1;
id s
3 a
replace into t1 select 1,"a";
select * from t1;
id s
1 a
drop table t1;
create table t1 (pk int primary key, apk int unique, data int) engine=maria;
insert into t1 values (1, 1, 1), (4, 4, 4), (6, 6, 6);
load data concurrent infile '../std_data_ln/loaddata5.dat' replace into table t1 fields terminated by '' enclosed by '' ignore 1 lines (pk, apk);
select * from t1 order by pk;
pk apk data
1 1 1
3 4 NULL
5 6 NULL
load data infile '../std_data_ln/loaddata5.dat' replace into table t1 fields terminated by '' enclosed by '' ignore 1 lines (pk, apk);
select * from t1 order by pk;
pk apk data
1 1 1
3 4 NULL
5 6 NULL

View File

@@ -64,3 +64,23 @@ select count(*) from t1;
select name from t1;
check table t1 extended;
drop table t1;
# test INSERT ON DUPLICATE KEY UPDATE
create table t1(id int, s char(1), unique(s)) engine=maria;
insert into t1 values(1,"a") on duplicate key update t1.id=t1.id+1;
insert into t1 values(1,"a") on duplicate key update t1.id=t1.id+1;
insert into t1 select 1,"a" on duplicate key update t1.id=t1.id+1;
select * from t1;
# test REPLACE SELECT
replace into t1 select 1,"a";
select * from t1;
drop table t1;
# test LOAD DATA INFILE REPLACE
create table t1 (pk int primary key, apk int unique, data int) engine=maria;
insert into t1 values (1, 1, 1), (4, 4, 4), (6, 6, 6);
load data concurrent infile '../std_data_ln/loaddata5.dat' replace into table t1 fields terminated by '' enclosed by '' ignore 1 lines (pk, apk);
select * from t1 order by pk;
load data infile '../std_data_ln/loaddata5.dat' replace into table t1 fields terminated by '' enclosed by '' ignore 1 lines (pk, apk);
select * from t1 order by pk;