As of commit
eaa5808e8e, MemoryContextResetAndDeleteChildren() is
just a backwards compatibility macro for MemoryContextReset(). Now
that some time has passed, this macro seems more likely to create
confusion.
This commit removes the macro and replaces all remaining uses with
calls to MemoryContextReset(). Any third-party code that use this
macro will need to be adjusted to call MemoryContextReset()
instead. Since the two have behaved the same way since v9.5, such
adjustments won't produce any behavior changes for all
currently-supported versions of PostgreSQL.
Reviewed-by: Amul Sul, Tom Lane, Alvaro Herrera, Dagfinn Ilmari Mannsåker
Discussion: https://postgr.es/m/
20231113185950.GA1668018%40nathanxps13
samepage))
{
/* no luck; start over */
- MemoryContextResetAndDeleteChildren(tupcxt);
+ MemoryContextReset(tupcxt);
continue;
}
}
CHECK_FOR_INTERRUPTS();
- MemoryContextResetAndDeleteChildren(perRangeCxt);
+ MemoryContextReset(perRangeCxt);
tup = brinGetTupleForHeapBlock(opaque->bo_rmAccess, heapBlk, &buf,
&off, &size, BUFFER_LOCK_SHARE);
tbm_free(entry->matchBitmap);
}
- MemoryContextResetAndDeleteChildren(so->keyCtx);
+ MemoryContextReset(so->keyCtx);
so->keys = NULL;
so->nkeys = 0;
* Clear the special abort context for next time.
*/
if (TransactionAbortContext != NULL)
- MemoryContextResetAndDeleteChildren(TransactionAbortContext);
+ MemoryContextReset(TransactionAbortContext);
/*
* Release all transaction-local memory.
* Clear the special abort context for next time.
*/
if (TransactionAbortContext != NULL)
- MemoryContextResetAndDeleteChildren(TransactionAbortContext);
+ MemoryContextReset(TransactionAbortContext);
/*
* Delete the subxact local memory contexts. Its CurTransactionContext can
stats->stadistinct = n_distinct;
}
- MemoryContextResetAndDeleteChildren(col_context);
+ MemoryContextReset(col_context);
}
if (nindexes > 0)
numindexrows,
totalindexrows);
- MemoryContextResetAndDeleteChildren(col_context);
+ MemoryContextReset(col_context);
}
}
ExecDropSingleTupleTableSlot(slot);
FreeExecutorState(estate);
- MemoryContextResetAndDeleteChildren(ind_context);
+ MemoryContextReset(ind_context);
}
MemoryContextSwitchTo(old_context);
/* Release any hashtable storage */
if (node->tableContext)
- MemoryContextResetAndDeleteChildren(node->tableContext);
+ MemoryContextReset(node->tableContext);
/* Empty hashtable if needed */
if (plan->numCols > 0)
/* Release any hashtable storage */
if (node->tableContext)
- MemoryContextResetAndDeleteChildren(node->tableContext);
+ MemoryContextReset(node->tableContext);
/* And rebuild empty hashtable if needed */
if (((SetOp *) node->ps.plan)->strategy == SETOP_HASHED)
* it, so we must leave it to the caller to reset at an appropriate time.
*/
if (peraggstate->aggcontext != winstate->aggcontext)
- MemoryContextResetAndDeleteChildren(peraggstate->aggcontext);
+ MemoryContextReset(peraggstate->aggcontext);
if (peraggstate->initValueIsNull)
peraggstate->transValue = peraggstate->initValue;
* result for it, else we'll leak memory.
*/
if (numaggs_restart > 0)
- MemoryContextResetAndDeleteChildren(winstate->aggcontext);
+ MemoryContextReset(winstate->aggcontext);
for (i = 0; i < numaggs; i++)
{
peraggstate = &winstate->peragg[i];
* any aggregate temp data). We don't rely on retail pfree because some
* aggregates might have allocated data we don't have direct pointers to.
*/
- MemoryContextResetAndDeleteChildren(winstate->partcontext);
- MemoryContextResetAndDeleteChildren(winstate->aggcontext);
+ MemoryContextReset(winstate->partcontext);
+ MemoryContextReset(winstate->aggcontext);
for (i = 0; i < winstate->numaggs; i++)
{
if (winstate->peragg[i].aggcontext != winstate->aggcontext)
- MemoryContextResetAndDeleteChildren(winstate->peragg[i].aggcontext);
+ MemoryContextReset(winstate->peragg[i].aggcontext);
}
if (winstate->buffer)
if (_SPI_current->execSubid >= mySubid)
{
_SPI_current->execSubid = InvalidSubTransactionId;
- MemoryContextResetAndDeleteChildren(_SPI_current->execCxt);
+ MemoryContextReset(_SPI_current->execCxt);
}
/* throw away any tuple tables created within current subxact */
/* mark Executor context no longer in use */
_SPI_current->execSubid = InvalidSubTransactionId;
/* and free Executor memory */
- MemoryContextResetAndDeleteChildren(_SPI_current->execCxt);
+ MemoryContextReset(_SPI_current->execCxt);
}
return 0;
FlushErrorState();
/* Flush any leaked data in the top-level context */
- MemoryContextResetAndDeleteChildren(AutovacMemCxt);
+ MemoryContextReset(AutovacMemCxt);
/* don't leave dangling pointers to freed memory */
DatabaseListCxt = NULL;
/* clean up memory before each iteration */
- MemoryContextResetAndDeleteChildren(PortalContext);
+ MemoryContextReset(PortalContext);
/*
* Save the relation name for a possible error message, to avoid a
/* this resets ProcGlobal->statusFlags[i] too */
AbortOutOfAnyTransaction();
FlushErrorState();
- MemoryContextResetAndDeleteChildren(PortalContext);
+ MemoryContextReset(PortalContext);
/* restart our transaction for the following operations */
StartTransactionCommand();
autovac_report_workitem(workitem, cur_nspname, cur_relname);
/* clean up memory before each work item */
- MemoryContextResetAndDeleteChildren(PortalContext);
+ MemoryContextReset(PortalContext);
/*
* We will abort the current work item if something errors out, and
/* this resets ProcGlobal->statusFlags[i] too */
AbortOutOfAnyTransaction();
FlushErrorState();
- MemoryContextResetAndDeleteChildren(PortalContext);
+ MemoryContextReset(PortalContext);
/* restart our transaction for the following operations */
StartTransactionCommand();
FlushErrorState();
/* Flush any leaked data in the top-level context */
- MemoryContextResetAndDeleteChildren(bgwriter_context);
+ MemoryContextReset(bgwriter_context);
/* re-initialize to avoid repeated errors causing problems */
WritebackContextInit(&wb_context, &bgwriter_flush_after);
FlushErrorState();
/* Flush any leaked data in the top-level context */
- MemoryContextResetAndDeleteChildren(checkpointer_context);
+ MemoryContextReset(checkpointer_context);
/* Now we can allow interrupts again */
RESUME_INTERRUPTS();
FlushErrorState();
/* Flush any leaked data in the top-level context */
- MemoryContextResetAndDeleteChildren(walwriter_context);
+ MemoryContextReset(walwriter_context);
/* Now we can allow interrupts again */
RESUME_INTERRUPTS();
}
/* Cleanup the memory. */
- MemoryContextResetAndDeleteChildren(ApplyMessageContext);
+ MemoryContextReset(ApplyMessageContext);
MemoryContextSwitchTo(TopMemoryContext);
/* Check if we need to exit the streaming loop. */
ExecDropSingleTupleTableSlot(slot);
FreeExecutorState(estate);
- MemoryContextResetAndDeleteChildren(expr_context);
+ MemoryContextReset(expr_context);
}
MemoryContextSwitchTo(old_context);
* query input buffer in the cleared MessageContext.
*/
MemoryContextSwitchTo(MessageContext);
- MemoryContextResetAndDeleteChildren(MessageContext);
+ MemoryContextReset(MessageContext);
initStringInfo(&input_message);
* This can happen either because a previous rebuild failed, or
* because an invalidation happened before the rebuild was complete.
*/
- MemoryContextResetAndDeleteChildren(EventTriggerCacheContext);
+ MemoryContextReset(EventTriggerCacheContext);
}
else
{
*/
if (EventTriggerCacheState == ETCS_VALID)
{
- MemoryContextResetAndDeleteChildren(EventTriggerCacheContext);
+ MemoryContextReset(EventTriggerCacheContext);
EventTriggerCache = NULL;
}
errordata_stack_depth = -1;
recursion_depth = 0;
/* Delete all data in ErrorContext */
- MemoryContextResetAndDeleteChildren(ErrorContext);
+ MemoryContextReset(ErrorContext);
}
/*
/* This is a transient link to the active portal's memory context: */
extern PGDLLIMPORT MemoryContext PortalContext;
-/* Backwards compatibility macro */
-#define MemoryContextResetAndDeleteChildren(ctx) MemoryContextReset(ctx)
-
/*
* Memory-context-type-independent functions in mcxt.c