Retire MemoryContextResetAndDeleteChildren() macro.
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
This commit is contained in:
parent
83267b15bf
commit
6a72c42fd5
@ -297,7 +297,7 @@ brininsert(Relation idxRel, Datum *values, bool *nulls,
|
|||||||
samepage))
|
samepage))
|
||||||
{
|
{
|
||||||
/* no luck; start over */
|
/* no luck; start over */
|
||||||
MemoryContextResetAndDeleteChildren(tupcxt);
|
MemoryContextReset(tupcxt);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -533,7 +533,7 @@ bringetbitmap(IndexScanDesc scan, TIDBitmap *tbm)
|
|||||||
|
|
||||||
CHECK_FOR_INTERRUPTS();
|
CHECK_FOR_INTERRUPTS();
|
||||||
|
|
||||||
MemoryContextResetAndDeleteChildren(perRangeCxt);
|
MemoryContextReset(perRangeCxt);
|
||||||
|
|
||||||
tup = brinGetTupleForHeapBlock(opaque->bo_rmAccess, heapBlk, &buf,
|
tup = brinGetTupleForHeapBlock(opaque->bo_rmAccess, heapBlk, &buf,
|
||||||
&off, &size, BUFFER_LOCK_SHARE);
|
&off, &size, BUFFER_LOCK_SHARE);
|
||||||
|
@ -251,7 +251,7 @@ ginFreeScanKeys(GinScanOpaque so)
|
|||||||
tbm_free(entry->matchBitmap);
|
tbm_free(entry->matchBitmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
MemoryContextResetAndDeleteChildren(so->keyCtx);
|
MemoryContextReset(so->keyCtx);
|
||||||
|
|
||||||
so->keys = NULL;
|
so->keys = NULL;
|
||||||
so->nkeys = 0;
|
so->nkeys = 0;
|
||||||
|
@ -1933,7 +1933,7 @@ AtCleanup_Memory(void)
|
|||||||
* Clear the special abort context for next time.
|
* Clear the special abort context for next time.
|
||||||
*/
|
*/
|
||||||
if (TransactionAbortContext != NULL)
|
if (TransactionAbortContext != NULL)
|
||||||
MemoryContextResetAndDeleteChildren(TransactionAbortContext);
|
MemoryContextReset(TransactionAbortContext);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Release all transaction-local memory.
|
* Release all transaction-local memory.
|
||||||
@ -1969,7 +1969,7 @@ AtSubCleanup_Memory(void)
|
|||||||
* Clear the special abort context for next time.
|
* Clear the special abort context for next time.
|
||||||
*/
|
*/
|
||||||
if (TransactionAbortContext != NULL)
|
if (TransactionAbortContext != NULL)
|
||||||
MemoryContextResetAndDeleteChildren(TransactionAbortContext);
|
MemoryContextReset(TransactionAbortContext);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Delete the subxact local memory contexts. Its CurTransactionContext can
|
* Delete the subxact local memory contexts. Its CurTransactionContext can
|
||||||
|
@ -583,7 +583,7 @@ do_analyze_rel(Relation onerel, VacuumParams *params,
|
|||||||
stats->stadistinct = n_distinct;
|
stats->stadistinct = n_distinct;
|
||||||
}
|
}
|
||||||
|
|
||||||
MemoryContextResetAndDeleteChildren(col_context);
|
MemoryContextReset(col_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nindexes > 0)
|
if (nindexes > 0)
|
||||||
@ -972,7 +972,7 @@ compute_index_stats(Relation onerel, double totalrows,
|
|||||||
numindexrows,
|
numindexrows,
|
||||||
totalindexrows);
|
totalindexrows);
|
||||||
|
|
||||||
MemoryContextResetAndDeleteChildren(col_context);
|
MemoryContextReset(col_context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -981,7 +981,7 @@ compute_index_stats(Relation onerel, double totalrows,
|
|||||||
|
|
||||||
ExecDropSingleTupleTableSlot(slot);
|
ExecDropSingleTupleTableSlot(slot);
|
||||||
FreeExecutorState(estate);
|
FreeExecutorState(estate);
|
||||||
MemoryContextResetAndDeleteChildren(ind_context);
|
MemoryContextReset(ind_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
MemoryContextSwitchTo(old_context);
|
MemoryContextSwitchTo(old_context);
|
||||||
|
@ -317,7 +317,7 @@ ExecReScanRecursiveUnion(RecursiveUnionState *node)
|
|||||||
|
|
||||||
/* Release any hashtable storage */
|
/* Release any hashtable storage */
|
||||||
if (node->tableContext)
|
if (node->tableContext)
|
||||||
MemoryContextResetAndDeleteChildren(node->tableContext);
|
MemoryContextReset(node->tableContext);
|
||||||
|
|
||||||
/* Empty hashtable if needed */
|
/* Empty hashtable if needed */
|
||||||
if (plan->numCols > 0)
|
if (plan->numCols > 0)
|
||||||
|
@ -631,7 +631,7 @@ ExecReScanSetOp(SetOpState *node)
|
|||||||
|
|
||||||
/* Release any hashtable storage */
|
/* Release any hashtable storage */
|
||||||
if (node->tableContext)
|
if (node->tableContext)
|
||||||
MemoryContextResetAndDeleteChildren(node->tableContext);
|
MemoryContextReset(node->tableContext);
|
||||||
|
|
||||||
/* And rebuild empty hashtable if needed */
|
/* And rebuild empty hashtable if needed */
|
||||||
if (((SetOp *) node->ps.plan)->strategy == SETOP_HASHED)
|
if (((SetOp *) node->ps.plan)->strategy == SETOP_HASHED)
|
||||||
|
@ -216,7 +216,7 @@ initialize_windowaggregate(WindowAggState *winstate,
|
|||||||
* it, so we must leave it to the caller to reset at an appropriate time.
|
* it, so we must leave it to the caller to reset at an appropriate time.
|
||||||
*/
|
*/
|
||||||
if (peraggstate->aggcontext != winstate->aggcontext)
|
if (peraggstate->aggcontext != winstate->aggcontext)
|
||||||
MemoryContextResetAndDeleteChildren(peraggstate->aggcontext);
|
MemoryContextReset(peraggstate->aggcontext);
|
||||||
|
|
||||||
if (peraggstate->initValueIsNull)
|
if (peraggstate->initValueIsNull)
|
||||||
peraggstate->transValue = peraggstate->initValue;
|
peraggstate->transValue = peraggstate->initValue;
|
||||||
@ -875,7 +875,7 @@ eval_windowaggregates(WindowAggState *winstate)
|
|||||||
* result for it, else we'll leak memory.
|
* result for it, else we'll leak memory.
|
||||||
*/
|
*/
|
||||||
if (numaggs_restart > 0)
|
if (numaggs_restart > 0)
|
||||||
MemoryContextResetAndDeleteChildren(winstate->aggcontext);
|
MemoryContextReset(winstate->aggcontext);
|
||||||
for (i = 0; i < numaggs; i++)
|
for (i = 0; i < numaggs; i++)
|
||||||
{
|
{
|
||||||
peraggstate = &winstate->peragg[i];
|
peraggstate = &winstate->peragg[i];
|
||||||
@ -1351,12 +1351,12 @@ release_partition(WindowAggState *winstate)
|
|||||||
* any aggregate temp data). We don't rely on retail pfree because some
|
* 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.
|
* aggregates might have allocated data we don't have direct pointers to.
|
||||||
*/
|
*/
|
||||||
MemoryContextResetAndDeleteChildren(winstate->partcontext);
|
MemoryContextReset(winstate->partcontext);
|
||||||
MemoryContextResetAndDeleteChildren(winstate->aggcontext);
|
MemoryContextReset(winstate->aggcontext);
|
||||||
for (i = 0; i < winstate->numaggs; i++)
|
for (i = 0; i < winstate->numaggs; i++)
|
||||||
{
|
{
|
||||||
if (winstate->peragg[i].aggcontext != winstate->aggcontext)
|
if (winstate->peragg[i].aggcontext != winstate->aggcontext)
|
||||||
MemoryContextResetAndDeleteChildren(winstate->peragg[i].aggcontext);
|
MemoryContextReset(winstate->peragg[i].aggcontext);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (winstate->buffer)
|
if (winstate->buffer)
|
||||||
|
@ -547,7 +547,7 @@ AtEOSubXact_SPI(bool isCommit, SubTransactionId mySubid)
|
|||||||
if (_SPI_current->execSubid >= mySubid)
|
if (_SPI_current->execSubid >= mySubid)
|
||||||
{
|
{
|
||||||
_SPI_current->execSubid = InvalidSubTransactionId;
|
_SPI_current->execSubid = InvalidSubTransactionId;
|
||||||
MemoryContextResetAndDeleteChildren(_SPI_current->execCxt);
|
MemoryContextReset(_SPI_current->execCxt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* throw away any tuple tables created within current subxact */
|
/* throw away any tuple tables created within current subxact */
|
||||||
@ -3083,7 +3083,7 @@ _SPI_end_call(bool use_exec)
|
|||||||
/* mark Executor context no longer in use */
|
/* mark Executor context no longer in use */
|
||||||
_SPI_current->execSubid = InvalidSubTransactionId;
|
_SPI_current->execSubid = InvalidSubTransactionId;
|
||||||
/* and free Executor memory */
|
/* and free Executor memory */
|
||||||
MemoryContextResetAndDeleteChildren(_SPI_current->execCxt);
|
MemoryContextReset(_SPI_current->execCxt);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -555,7 +555,7 @@ AutoVacLauncherMain(int argc, char *argv[])
|
|||||||
FlushErrorState();
|
FlushErrorState();
|
||||||
|
|
||||||
/* Flush any leaked data in the top-level context */
|
/* Flush any leaked data in the top-level context */
|
||||||
MemoryContextResetAndDeleteChildren(AutovacMemCxt);
|
MemoryContextReset(AutovacMemCxt);
|
||||||
|
|
||||||
/* don't leave dangling pointers to freed memory */
|
/* don't leave dangling pointers to freed memory */
|
||||||
DatabaseListCxt = NULL;
|
DatabaseListCxt = NULL;
|
||||||
@ -2521,7 +2521,7 @@ do_autovacuum(void)
|
|||||||
|
|
||||||
|
|
||||||
/* clean up memory before each iteration */
|
/* clean up memory before each iteration */
|
||||||
MemoryContextResetAndDeleteChildren(PortalContext);
|
MemoryContextReset(PortalContext);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Save the relation name for a possible error message, to avoid a
|
* Save the relation name for a possible error message, to avoid a
|
||||||
@ -2576,7 +2576,7 @@ do_autovacuum(void)
|
|||||||
/* this resets ProcGlobal->statusFlags[i] too */
|
/* this resets ProcGlobal->statusFlags[i] too */
|
||||||
AbortOutOfAnyTransaction();
|
AbortOutOfAnyTransaction();
|
||||||
FlushErrorState();
|
FlushErrorState();
|
||||||
MemoryContextResetAndDeleteChildren(PortalContext);
|
MemoryContextReset(PortalContext);
|
||||||
|
|
||||||
/* restart our transaction for the following operations */
|
/* restart our transaction for the following operations */
|
||||||
StartTransactionCommand();
|
StartTransactionCommand();
|
||||||
@ -2718,7 +2718,7 @@ perform_work_item(AutoVacuumWorkItem *workitem)
|
|||||||
autovac_report_workitem(workitem, cur_nspname, cur_relname);
|
autovac_report_workitem(workitem, cur_nspname, cur_relname);
|
||||||
|
|
||||||
/* clean up memory before each work item */
|
/* clean up memory before each work item */
|
||||||
MemoryContextResetAndDeleteChildren(PortalContext);
|
MemoryContextReset(PortalContext);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We will abort the current work item if something errors out, and
|
* We will abort the current work item if something errors out, and
|
||||||
@ -2770,7 +2770,7 @@ perform_work_item(AutoVacuumWorkItem *workitem)
|
|||||||
/* this resets ProcGlobal->statusFlags[i] too */
|
/* this resets ProcGlobal->statusFlags[i] too */
|
||||||
AbortOutOfAnyTransaction();
|
AbortOutOfAnyTransaction();
|
||||||
FlushErrorState();
|
FlushErrorState();
|
||||||
MemoryContextResetAndDeleteChildren(PortalContext);
|
MemoryContextReset(PortalContext);
|
||||||
|
|
||||||
/* restart our transaction for the following operations */
|
/* restart our transaction for the following operations */
|
||||||
StartTransactionCommand();
|
StartTransactionCommand();
|
||||||
|
@ -182,7 +182,7 @@ BackgroundWriterMain(void)
|
|||||||
FlushErrorState();
|
FlushErrorState();
|
||||||
|
|
||||||
/* Flush any leaked data in the top-level context */
|
/* Flush any leaked data in the top-level context */
|
||||||
MemoryContextResetAndDeleteChildren(bgwriter_context);
|
MemoryContextReset(bgwriter_context);
|
||||||
|
|
||||||
/* re-initialize to avoid repeated errors causing problems */
|
/* re-initialize to avoid repeated errors causing problems */
|
||||||
WritebackContextInit(&wb_context, &bgwriter_flush_after);
|
WritebackContextInit(&wb_context, &bgwriter_flush_after);
|
||||||
|
@ -290,7 +290,7 @@ CheckpointerMain(void)
|
|||||||
FlushErrorState();
|
FlushErrorState();
|
||||||
|
|
||||||
/* Flush any leaked data in the top-level context */
|
/* Flush any leaked data in the top-level context */
|
||||||
MemoryContextResetAndDeleteChildren(checkpointer_context);
|
MemoryContextReset(checkpointer_context);
|
||||||
|
|
||||||
/* Now we can allow interrupts again */
|
/* Now we can allow interrupts again */
|
||||||
RESUME_INTERRUPTS();
|
RESUME_INTERRUPTS();
|
||||||
|
@ -178,7 +178,7 @@ WalWriterMain(void)
|
|||||||
FlushErrorState();
|
FlushErrorState();
|
||||||
|
|
||||||
/* Flush any leaked data in the top-level context */
|
/* Flush any leaked data in the top-level context */
|
||||||
MemoryContextResetAndDeleteChildren(walwriter_context);
|
MemoryContextReset(walwriter_context);
|
||||||
|
|
||||||
/* Now we can allow interrupts again */
|
/* Now we can allow interrupts again */
|
||||||
RESUME_INTERRUPTS();
|
RESUME_INTERRUPTS();
|
||||||
|
@ -3647,7 +3647,7 @@ LogicalRepApplyLoop(XLogRecPtr last_received)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Cleanup the memory. */
|
/* Cleanup the memory. */
|
||||||
MemoryContextResetAndDeleteChildren(ApplyMessageContext);
|
MemoryContextReset(ApplyMessageContext);
|
||||||
MemoryContextSwitchTo(TopMemoryContext);
|
MemoryContextSwitchTo(TopMemoryContext);
|
||||||
|
|
||||||
/* Check if we need to exit the streaming loop. */
|
/* Check if we need to exit the streaming loop. */
|
||||||
|
@ -2237,7 +2237,7 @@ compute_expr_stats(Relation onerel, double totalrows,
|
|||||||
|
|
||||||
ExecDropSingleTupleTableSlot(slot);
|
ExecDropSingleTupleTableSlot(slot);
|
||||||
FreeExecutorState(estate);
|
FreeExecutorState(estate);
|
||||||
MemoryContextResetAndDeleteChildren(expr_context);
|
MemoryContextReset(expr_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
MemoryContextSwitchTo(old_context);
|
MemoryContextSwitchTo(old_context);
|
||||||
|
@ -4457,7 +4457,7 @@ PostgresMain(const char *dbname, const char *username)
|
|||||||
* query input buffer in the cleared MessageContext.
|
* query input buffer in the cleared MessageContext.
|
||||||
*/
|
*/
|
||||||
MemoryContextSwitchTo(MessageContext);
|
MemoryContextSwitchTo(MessageContext);
|
||||||
MemoryContextResetAndDeleteChildren(MessageContext);
|
MemoryContextReset(MessageContext);
|
||||||
|
|
||||||
initStringInfo(&input_message);
|
initStringInfo(&input_message);
|
||||||
|
|
||||||
|
4
src/backend/utils/cache/evtcache.c
vendored
4
src/backend/utils/cache/evtcache.c
vendored
@ -91,7 +91,7 @@ BuildEventTriggerCache(void)
|
|||||||
* This can happen either because a previous rebuild failed, or
|
* This can happen either because a previous rebuild failed, or
|
||||||
* because an invalidation happened before the rebuild was complete.
|
* because an invalidation happened before the rebuild was complete.
|
||||||
*/
|
*/
|
||||||
MemoryContextResetAndDeleteChildren(EventTriggerCacheContext);
|
MemoryContextReset(EventTriggerCacheContext);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -262,7 +262,7 @@ InvalidateEventCacheCallback(Datum arg, int cacheid, uint32 hashvalue)
|
|||||||
*/
|
*/
|
||||||
if (EventTriggerCacheState == ETCS_VALID)
|
if (EventTriggerCacheState == ETCS_VALID)
|
||||||
{
|
{
|
||||||
MemoryContextResetAndDeleteChildren(EventTriggerCacheContext);
|
MemoryContextReset(EventTriggerCacheContext);
|
||||||
EventTriggerCache = NULL;
|
EventTriggerCache = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1833,7 +1833,7 @@ FlushErrorState(void)
|
|||||||
errordata_stack_depth = -1;
|
errordata_stack_depth = -1;
|
||||||
recursion_depth = 0;
|
recursion_depth = 0;
|
||||||
/* Delete all data in ErrorContext */
|
/* Delete all data in ErrorContext */
|
||||||
MemoryContextResetAndDeleteChildren(ErrorContext);
|
MemoryContextReset(ErrorContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -66,9 +66,6 @@ extern PGDLLIMPORT MemoryContext CurTransactionContext;
|
|||||||
/* This is a transient link to the active portal's memory context: */
|
/* This is a transient link to the active portal's memory context: */
|
||||||
extern PGDLLIMPORT MemoryContext PortalContext;
|
extern PGDLLIMPORT MemoryContext PortalContext;
|
||||||
|
|
||||||
/* Backwards compatibility macro */
|
|
||||||
#define MemoryContextResetAndDeleteChildren(ctx) MemoryContextReset(ctx)
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Memory-context-type-independent functions in mcxt.c
|
* Memory-context-type-independent functions in mcxt.c
|
||||||
|
Loading…
x
Reference in New Issue
Block a user