diff --git a/src/include/storage/index/hash_index.h b/src/include/storage/index/hash_index.h index 8bb2a69b9..7b28a94ed 100644 --- a/src/include/storage/index/hash_index.h +++ b/src/include/storage/index/hash_index.h @@ -458,7 +458,7 @@ class PrimaryKeyIndex final : public Index { } void delete_(common::ValueVector* keyVector); - void discardPrimaryKey(common::ValueVector* keyVector) override { delete_(keyVector); } + void discardPrimaryKey(common::ValueVector* keyVector) override; void checkpointInMemory() override; void checkpoint(main::ClientContext*, storage::PageAllocator& pageAllocator) override; diff --git a/src/storage/index/hash_index.cpp b/src/storage/index/hash_index.cpp index 5ba16b013..8f19f3082 100644 --- a/src/storage/index/hash_index.cpp +++ b/src/storage/index/hash_index.cpp @@ -603,6 +603,23 @@ void PrimaryKeyIndex::delete_(ValueVector* keyVector) { [](auto) { UNREACHABLE_CODE; }); } +void PrimaryKeyIndex::discardPrimaryKey(ValueVector* keyVector) { + DASSERT(indexInfo.keyDataTypes.size() == 1); + TypeUtils::visit( + indexInfo.keyDataTypes[0], + [&](T) { + for (auto i = 0u; i < keyVector->state->getSelVector().getSelSize(); i++) { + auto pos = keyVector->state->getSelVector()[i]; + if (keyVector->isNull(pos)) { + continue; + } + auto key = keyVector->getValue(pos); + discardLocal(key); + } + }, + [](auto) { UNREACHABLE_CODE; }); +} + void PrimaryKeyIndex::checkpointInMemory() { bool indexChanged = false; for (auto i = 0u; i < NUM_HASH_INDEXES; i++) {