Skip to content

Commit

Permalink
fix(tianmu): Insert ignore can insert duplicate values.(stoneatom#1699)
Browse files Browse the repository at this point in the history
  • Loading branch information
konghaiya committed May 8, 2023
1 parent c95d263 commit 08b3ab5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions mysql-test/suite/tianmu/r/issue1637.result
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ create table ttt(id int primary key,name varchar(10));
insert into ttt values(1,'aaa');
insert into ttt values(2,'bbb');
insert ignore into ttt values(2,'ccc');
select * from ttt;
id name
1 aaa
2 bbb
DROP DATABASE issue1637_test;
3 changes: 2 additions & 1 deletion mysql-test/suite/tianmu/t/issue1637.test
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ insert into ttt values(2,'bbb');
--disable_warnings
insert ignore into ttt values(2,'ccc');
--enable_warnings

sleep 1;
select * from ttt;

DROP DATABASE issue1637_test;
3 changes: 2 additions & 1 deletion storage/tianmu/core/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1707,7 +1707,8 @@ int Engine::InsertToDelta(const std::string &table_path, std::shared_ptr<TableSh
uint64_t row_id = tm_table->NextRowId();
// Insert primary key first
int ret = tm_table->InsertIndexForDelta(table, row_id);

if (ret != 0)
return ret;
// check & encode
uint32_t buf_sz = 0;
std::unique_ptr<char[]> buf;
Expand Down

0 comments on commit 08b3ab5

Please sign in to comment.