Skip to content

Commit

Permalink
BplusTreeIndex::insert_entry独立性检验
Browse files Browse the repository at this point in the history
  • Loading branch information
HuXin0817 committed Oct 3, 2024
1 parent f4f156f commit 3da8111
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/observer/storage/index/bplus_tree_index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,19 @@ RC BplusTreeIndex::close()
RC BplusTreeIndex::insert_entry(const char *record, const RID *rid)
{
char *entry = index_meta_.make_entry_from_record(record);
if (index_meta_.unique()) {
IndexScanner *scanner = create_scanner(entry, index_meta_.fields_total_len(), true, entry, index_meta_.fields_total_len(), true);
if (scanner != nullptr) {
RID existing_rid;
if (scanner->next_entry(&existing_rid) == RC::SUCCESS) {
delete scanner;
LOG_WARN("Key already exists, duplicate entry is not allowed.");
return RC::RECORD_DUPLICATE_KEY;
}
delete scanner;
}
}

return index_handler_.insert_entry(entry, rid);
}

Expand Down

0 comments on commit 3da8111

Please sign in to comment.