diff --git a/spatial/include/spatial/core/util/managed_collection.hpp b/spatial/include/spatial/core/util/managed_collection.hpp index dbf21f1..472e6e2 100644 --- a/spatial/include/spatial/core/util/managed_collection.hpp +++ b/spatial/include/spatial/core/util/managed_collection.hpp @@ -95,7 +95,7 @@ void ManagedCollection::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(); } } @@ -109,7 +109,7 @@ void ManagedCollection::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(); } diff --git a/spatial/src/spatial/core/index/rtree/rtree_index_create_physical.cpp b/spatial/src/spatial/core/index/rtree/rtree_index_create_physical.cpp index 9b729a6..ed2455f 100644 --- a/spatial/src/spatial/core/index/rtree/rtree_index_create_physical.cpp +++ b/spatial/src/spatial/core/index/rtree/rtree_index_create_physical.cpp @@ -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(); diff --git a/test/sql/index/rtree_conflict.test b/test/sql/index/rtree_conflict.test new file mode 100644 index 0000000..232c2d2 --- /dev/null +++ b/test/sql/index/rtree_conflict.test @@ -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);