* by TidStoreMemoryUsage().
*/
TidStore *
-TidStoreCreateLocal(size_t max_bytes)
+TidStoreCreateLocal(size_t max_bytes, bool insert_only)
{
TidStore *ts;
size_t initBlockSize = ALLOCSET_DEFAULT_INITSIZE;
maxBlockSize = ALLOCSET_DEFAULT_INITSIZE;
/* Create a memory context for the TID storage */
- ts->rt_context = AllocSetContextCreate(CurrentMemoryContext,
+ if (insert_only)
+ {
+ ts->rt_context = BumpContextCreate(CurrentMemoryContext,
"TID storage",
minContextSize,
initBlockSize,
maxBlockSize);
+ }
+ else
+ {
+ ts->rt_context = AllocSetContextCreate(CurrentMemoryContext,
+ "TID storage",
+ minContextSize,
+ initBlockSize,
+ maxBlockSize);
+ }
ts->tree.local = local_ts_create(ts->rt_context);
dead_items_info->num_items = 0;
vacrel->dead_items_info = dead_items_info;
- vacrel->dead_items = TidStoreCreateLocal(dead_items_info->max_bytes);
+ vacrel->dead_items = TidStoreCreateLocal(dead_items_info->max_bytes, true);
}
/*
/* Recreate the tidstore with the same max_bytes limitation */
TidStoreDestroy(dead_items);
- vacrel->dead_items = TidStoreCreateLocal(vacrel->dead_items_info->max_bytes);
+ vacrel->dead_items = TidStoreCreateLocal(vacrel->dead_items_info->max_bytes, true);
/* Reset the counter */
vacrel->dead_items_info->num_items = 0;
OffsetNumber *offsets;
} TidStoreIterResult;
-extern TidStore *TidStoreCreateLocal(size_t max_bytes);
+extern TidStore *TidStoreCreateLocal(size_t max_bytes, bool insert_only);
extern TidStore *TidStoreCreateShared(size_t max_bytes, int tranche_id);
extern TidStore *TidStoreAttach(dsa_handle area_handle, dsa_pointer handle);
extern void TidStoreDetach(TidStore *ts);
/* leaf_context is used only for single-value leaves */
MemoryContextData *leaf_context;
#endif
+ MemoryContextData *iter_context;
};
/*
tree = (RT_RADIX_TREE *) palloc0(sizeof(RT_RADIX_TREE));
tree->context = ctx;
+ /*
+ * Separate context for iteration in case the tree context doesn't support
+ * pfree
+ */
+ tree->iter_context = AllocSetContextCreate(ctx,
+ RT_STR(RT_PREFIX) "radix_tree iter context",
+ ALLOCSET_SMALL_SIZES);
+
#ifdef RT_SHMEM
tree->dsa = dsa;
dp = dsa_allocate0(dsa, sizeof(RT_RADIX_TREE_CONTROL));
RT_ITER *iter;
RT_CHILD_PTR root;
- iter = (RT_ITER *) MemoryContextAllocZero(tree->context,
+ iter = (RT_ITER *) MemoryContextAllocZero(tree->iter_context,
sizeof(RT_ITER));
iter->tree = tree;
dsa_pin_mapping(TidStoreGetDSA(tidstore));
}
else
- tidstore = TidStoreCreateLocal(tidstore_max_size);
+ /* VACUUM uses insert only, so we test the other option. */
+ tidstore = TidStoreCreateLocal(tidstore_max_size, false);
tidstore_empty_size = TidStoreMemoryUsage(tidstore);