From 14522b0ca2bf74bfe61178cd4b4d48a85e7491dd Mon Sep 17 00:00:00 2001 From: Benjamin Winger Date: Wed, 20 Nov 2024 14:15:04 -0500 Subject: [PATCH] Fix VersionInfo SelVector creation One branch of the code was setting the existing SelectionVector to filtered and then appending to it Existing unfiltered elements would be discarded and replaced with whatever happened to be in the SelectionVector's mutable buffer --- src/include/common/data_chunk/sel_vector.h | 9 +++++++++ src/storage/store/version_info.cpp | 5 +++++ test/test_files/dml_rel/delete/delete_ldbc_sf01.test | 2 -- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/include/common/data_chunk/sel_vector.h b/src/include/common/data_chunk/sel_vector.h index d84302ebe42..a4b94e6eaef 100644 --- a/src/include/common/data_chunk/sel_vector.h +++ b/src/include/common/data_chunk/sel_vector.h @@ -1,5 +1,7 @@ #pragma once +#include + #include #include "common/constants.h" @@ -58,6 +60,13 @@ class SelectionVector { selectedSize = size; } + // Copies the data in selectedPositions into selectedPositionsBuffer + void makeDynamic() { + memcpy(selectedPositionsBuffer.get(), selectedPositions, selectedSize * sizeof(sel_t)); + state = State::DYNAMIC; + selectedPositions = selectedPositionsBuffer.get(); + } + std::span getMutableBuffer() const { return std::span(selectedPositionsBuffer.get(), capacity); } diff --git a/src/storage/store/version_info.cpp b/src/storage/store/version_info.cpp index 4b3a9c4b5a6..42e12ba26cd 100644 --- a/src/storage/store/version_info.cpp +++ b/src/storage/store/version_info.cpp @@ -100,6 +100,11 @@ void VectorVersionInfo::getSelVectorForScan(const transaction_t startTS, selVector.setToFiltered(numSelected); } } else if (insertionStatus != InsertionStatus::NO_INSERTED) { + // If there were no deleted values up to this point the selVector may be unfiltered but have + // non-zero size, and the mutable buffer may have arbitrary contents + if (selVector.isUnfiltered()) { + selVector.makeDynamic(); + } for (auto i = 0u; i < numRows; i++) { if (const auto rowIdx = startRow + i; isInserted(startTS, transactionID, rowIdx) && !isDeleted(startTS, transactionID, rowIdx)) { diff --git a/test/test_files/dml_rel/delete/delete_ldbc_sf01.test b/test/test_files/dml_rel/delete/delete_ldbc_sf01.test index 7dfb36986b3..ef13ff0e7e5 100644 --- a/test/test_files/dml_rel/delete/delete_ldbc_sf01.test +++ b/test/test_files/dml_rel/delete/delete_ldbc_sf01.test @@ -1,9 +1,7 @@ -DATASET CSV ldbc-sf01 -- -# FIX-ME(Guodong): https://github.com/kuzudb/kuzu/issues/4271 -CASE DeleteLikeComment1 --SKIP -STATEMENT MATCH (n:Person)-[e:likes_Comment]->(m:Comment) WHERE n.id=6597069767457 RETURN COUNT(*); ---- 1 66