Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CREATE IF NOT EXISTS for r-tree indexes, don't destroy buffers when evicted during bulk-loading. #420

Merged
merged 2 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions spatial/include/spatial/core/util/managed_collection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void ManagedCollection<T>::InitializeAppend(ManagedCollectionAppendState &state,
state.block = &blocks.back();
state.block->item_count = 0;
state.block->item_capacity = block_capacity;
state.handle = manager.Allocate(MemoryTag::EXTENSION, block_size, true);
state.handle = manager.Allocate(MemoryTag::EXTENSION, block_size, false);
state.block->handle = state.handle.GetBlockHandle();
}
}
Expand All @@ -109,7 +109,7 @@ void ManagedCollection<T>::Append(ManagedCollectionAppendState &state, const T *
state.block = &blocks.back();
state.block->item_count = 0;
state.block->item_capacity = block_capacity;
state.handle = manager.Allocate(MemoryTag::EXTENSION, block_size, true);
state.handle = manager.Allocate(MemoryTag::EXTENSION, block_size, false);
state.block->handle = state.handle.GetBlockHandle();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,9 @@ static void AddIndexToCatalog(ClientContext &context, CreateRTreeIndexGlobalStat
if (info.on_conflict != OnCreateConflict::IGNORE_ON_CONFLICT) {
throw CatalogException("Index with name \"%s\" already exists", info.index_name);
}
// IF NOT EXISTS on existing index. We are done.
// TODO: Early out before this.
return;
}

const auto index_entry = schema.CreateIndex(schema.GetCatalogTransaction(context), info, table).get();
Expand Down
18 changes: 18 additions & 0 deletions test/sql/index/rtree_conflict.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
require spatial

statement ok
create table nodes (name varchar, pt geometry);

statement ok
create index if not exists nodes_pt_idx on nodes using rtree(pt);

statement ok
create index if not exists nodes_pt_idx on nodes using rtree(pt);

statement error
create index nodes_pt_idx on nodes using rtree(pt);
----
Catalog Error: Index with name "nodes_pt_idx" already exists

statement ok
create index if not exists nodes_pt_idx on nodes using rtree(pt);
Loading