aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Bossart <nathan@postgresql.org>2023-11-15 13:42:30 -0600
committerNathan Bossart <nathan@postgresql.org>2023-11-15 13:42:30 -0600
commit6a72c42fd5af7ada49584694f543eb06dddb4a87 (patch)
treec2f566a161756b8aca8a58d58d4b0a0b6ee08da7
parent83267b15bf0dffa6e1096608bda95b8488048bb9 (diff)
downloadpostgresql-6a72c42fd5af7ada49584694f543eb06dddb4a87.tar.gz
postgresql-6a72c42fd5af7ada49584694f543eb06dddb4a87.zip
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
-rw-r--r--src/backend/access/brin/brin.c4
-rw-r--r--src/backend/access/gin/ginscan.c2
-rw-r--r--src/backend/access/transam/xact.c4
-rw-r--r--src/backend/commands/analyze.c6
-rw-r--r--src/backend/executor/nodeRecursiveunion.c2
-rw-r--r--src/backend/executor/nodeSetOp.c2
-rw-r--r--src/backend/executor/nodeWindowAgg.c10
-rw-r--r--src/backend/executor/spi.c4
-rw-r--r--src/backend/postmaster/autovacuum.c10
-rw-r--r--src/backend/postmaster/bgwriter.c2
-rw-r--r--src/backend/postmaster/checkpointer.c2
-rw-r--r--src/backend/postmaster/walwriter.c2
-rw-r--r--src/backend/replication/logical/worker.c2
-rw-r--r--src/backend/statistics/extended_stats.c2
-rw-r--r--src/backend/tcop/postgres.c2
-rw-r--r--src/backend/utils/cache/evtcache.c4
-rw-r--r--src/backend/utils/error/elog.c2
-rw-r--r--src/include/utils/memutils.h3
18 files changed, 31 insertions, 34 deletions
diff --git a/src/backend/access/brin/brin.c b/src/backend/access/brin/brin.c
index 25338a90e29..f0eac078e0b 100644
--- a/src/backend/access/brin/brin.c
+++ b/src/backend/access/brin/brin.c
@@ -297,7 +297,7 @@ brininsert(Relation idxRel, Datum *values, bool *nulls,
samepage))
{
/* no luck; start over */
- MemoryContextResetAndDeleteChildren(tupcxt);
+ MemoryContextReset(tupcxt);
continue;
}
}
@@ -533,7 +533,7 @@ bringetbitmap(IndexScanDesc scan, TIDBitmap *tbm)
CHECK_FOR_INTERRUPTS();
- MemoryContextResetAndDeleteChildren(perRangeCxt);
+ MemoryContextReset(perRangeCxt);
tup = brinGetTupleForHeapBlock(opaque->bo_rmAccess, heapBlk, &buf,
&off, &size, BUFFER_LOCK_SHARE);
diff --git a/src/backend/access/gin/ginscan.c b/src/backend/access/gin/ginscan.c
index ae7b0e9bb87..f719577695a 100644
--- a/src/backend/access/gin/ginscan.c
+++ b/src/backend/access/gin/ginscan.c
@@ -251,7 +251,7 @@ ginFreeScanKeys(GinScanOpaque so)
tbm_free(entry->matchBitmap);
}
- MemoryContextResetAndDeleteChildren(so->keyCtx);
+ MemoryContextReset(so->keyCtx);
so->keys = NULL;
so->nkeys = 0;
diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c
index 8fad8ffa1eb..536edb3792f 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -1933,7 +1933,7 @@ AtCleanup_Memory(void)
* Clear the special abort context for next time.
*/
if (TransactionAbortContext != NULL)
- MemoryContextResetAndDeleteChildren(TransactionAbortContext);
+ MemoryContextReset(TransactionAbortContext);
/*
* Release all transaction-local memory.
@@ -1969,7 +1969,7 @@ AtSubCleanup_Memory(void)
* Clear the special abort context for next time.
*/
if (TransactionAbortContext != NULL)
- MemoryContextResetAndDeleteChildren(TransactionAbortContext);
+ MemoryContextReset(TransactionAbortContext);
/*
* Delete the subxact local memory contexts. Its CurTransactionContext can
diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c
index 206d1689ef9..e264ffdcf28 100644
--- a/src/backend/commands/analyze.c
+++ b/src/backend/commands/analyze.c
@@ -583,7 +583,7 @@ do_analyze_rel(Relation onerel, VacuumParams *params,
stats->stadistinct = n_distinct;
}
- MemoryContextResetAndDeleteChildren(col_context);
+ MemoryContextReset(col_context);
}
if (nindexes > 0)
@@ -972,7 +972,7 @@ compute_index_stats(Relation onerel, double totalrows,
numindexrows,
totalindexrows);
- MemoryContextResetAndDeleteChildren(col_context);
+ MemoryContextReset(col_context);
}
}
@@ -981,7 +981,7 @@ compute_index_stats(Relation onerel, double totalrows,
ExecDropSingleTupleTableSlot(slot);
FreeExecutorState(estate);
- MemoryContextResetAndDeleteChildren(ind_context);
+ MemoryContextReset(ind_context);
}
MemoryContextSwitchTo(old_context);
diff --git a/src/backend/executor/nodeRecursiveunion.c b/src/backend/executor/nodeRecursiveunion.c
index e7810039341..3207643156e 100644
--- a/src/backend/executor/nodeRecursiveunion.c
+++ b/src/backend/executor/nodeRecursiveunion.c
@@ -317,7 +317,7 @@ ExecReScanRecursiveUnion(RecursiveUnionState *node)
/* Release any hashtable storage */
if (node->tableContext)
- MemoryContextResetAndDeleteChildren(node->tableContext);
+ MemoryContextReset(node->tableContext);
/* Empty hashtable if needed */
if (plan->numCols > 0)
diff --git a/src/backend/executor/nodeSetOp.c b/src/backend/executor/nodeSetOp.c
index 98c1b84d436..5a84969cf81 100644
--- a/src/backend/executor/nodeSetOp.c
+++ b/src/backend/executor/nodeSetOp.c
@@ -631,7 +631,7 @@ ExecReScanSetOp(SetOpState *node)
/* 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)
diff --git a/src/backend/executor/nodeWindowAgg.c b/src/backend/executor/nodeWindowAgg.c
index 77724a6daaf..3258305f57f 100644
--- a/src/backend/executor/nodeWindowAgg.c
+++ b/src/backend/executor/nodeWindowAgg.c
@@ -216,7 +216,7 @@ initialize_windowaggregate(WindowAggState *winstate,
* 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;
@@ -875,7 +875,7 @@ eval_windowaggregates(WindowAggState *winstate)
* 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];
@@ -1351,12 +1351,12 @@ release_partition(WindowAggState *winstate)
* 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)
diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c
index 33975687b38..0e46c59d25d 100644
--- a/src/backend/executor/spi.c
+++ b/src/backend/executor/spi.c
@@ -547,7 +547,7 @@ AtEOSubXact_SPI(bool isCommit, SubTransactionId mySubid)
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 */
@@ -3083,7 +3083,7 @@ _SPI_end_call(bool use_exec)
/* 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;
diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c
index 3a6f24a0237..86a3b3d8be2 100644
--- a/src/backend/postmaster/autovacuum.c
+++ b/src/backend/postmaster/autovacuum.c
@@ -555,7 +555,7 @@ AutoVacLauncherMain(int argc, char *argv[])
FlushErrorState();
/* Flush any leaked data in the top-level context */
- MemoryContextResetAndDeleteChildren(AutovacMemCxt);
+ MemoryContextReset(AutovacMemCxt);
/* don't leave dangling pointers to freed memory */
DatabaseListCxt = NULL;
@@ -2521,7 +2521,7 @@ do_autovacuum(void)
/* clean up memory before each iteration */
- MemoryContextResetAndDeleteChildren(PortalContext);
+ MemoryContextReset(PortalContext);
/*
* 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 */
AbortOutOfAnyTransaction();
FlushErrorState();
- MemoryContextResetAndDeleteChildren(PortalContext);
+ MemoryContextReset(PortalContext);
/* restart our transaction for the following operations */
StartTransactionCommand();
@@ -2718,7 +2718,7 @@ perform_work_item(AutoVacuumWorkItem *workitem)
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
@@ -2770,7 +2770,7 @@ perform_work_item(AutoVacuumWorkItem *workitem)
/* this resets ProcGlobal->statusFlags[i] too */
AbortOutOfAnyTransaction();
FlushErrorState();
- MemoryContextResetAndDeleteChildren(PortalContext);
+ MemoryContextReset(PortalContext);
/* restart our transaction for the following operations */
StartTransactionCommand();
diff --git a/src/backend/postmaster/bgwriter.c b/src/backend/postmaster/bgwriter.c
index f2e4f23d9fc..d02dc17b9c1 100644
--- a/src/backend/postmaster/bgwriter.c
+++ b/src/backend/postmaster/bgwriter.c
@@ -182,7 +182,7 @@ BackgroundWriterMain(void)
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);
diff --git a/src/backend/postmaster/checkpointer.c b/src/backend/postmaster/checkpointer.c
index a3c1aba24ea..42c807d3528 100644
--- a/src/backend/postmaster/checkpointer.c
+++ b/src/backend/postmaster/checkpointer.c
@@ -290,7 +290,7 @@ CheckpointerMain(void)
FlushErrorState();
/* Flush any leaked data in the top-level context */
- MemoryContextResetAndDeleteChildren(checkpointer_context);
+ MemoryContextReset(checkpointer_context);
/* Now we can allow interrupts again */
RESUME_INTERRUPTS();
diff --git a/src/backend/postmaster/walwriter.c b/src/backend/postmaster/walwriter.c
index 266fbc23399..48bc92205b5 100644
--- a/src/backend/postmaster/walwriter.c
+++ b/src/backend/postmaster/walwriter.c
@@ -178,7 +178,7 @@ WalWriterMain(void)
FlushErrorState();
/* Flush any leaked data in the top-level context */
- MemoryContextResetAndDeleteChildren(walwriter_context);
+ MemoryContextReset(walwriter_context);
/* Now we can allow interrupts again */
RESUME_INTERRUPTS();
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index 52a9f136ab9..21abf34ef7a 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -3647,7 +3647,7 @@ LogicalRepApplyLoop(XLogRecPtr last_received)
}
/* Cleanup the memory. */
- MemoryContextResetAndDeleteChildren(ApplyMessageContext);
+ MemoryContextReset(ApplyMessageContext);
MemoryContextSwitchTo(TopMemoryContext);
/* Check if we need to exit the streaming loop. */
diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c
index 9f67a577244..7f014a0cbba 100644
--- a/src/backend/statistics/extended_stats.c
+++ b/src/backend/statistics/extended_stats.c
@@ -2237,7 +2237,7 @@ compute_expr_stats(Relation onerel, double totalrows,
ExecDropSingleTupleTableSlot(slot);
FreeExecutorState(estate);
- MemoryContextResetAndDeleteChildren(expr_context);
+ MemoryContextReset(expr_context);
}
MemoryContextSwitchTo(old_context);
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index 6a070b5d8cb..e415cf1f34a 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -4457,7 +4457,7 @@ PostgresMain(const char *dbname, const char *username)
* query input buffer in the cleared MessageContext.
*/
MemoryContextSwitchTo(MessageContext);
- MemoryContextResetAndDeleteChildren(MessageContext);
+ MemoryContextReset(MessageContext);
initStringInfo(&input_message);
diff --git a/src/backend/utils/cache/evtcache.c b/src/backend/utils/cache/evtcache.c
index 5a721a4046d..879c6d87c32 100644
--- a/src/backend/utils/cache/evtcache.c
+++ b/src/backend/utils/cache/evtcache.c
@@ -91,7 +91,7 @@ BuildEventTriggerCache(void)
* This can happen either because a previous rebuild failed, or
* because an invalidation happened before the rebuild was complete.
*/
- MemoryContextResetAndDeleteChildren(EventTriggerCacheContext);
+ MemoryContextReset(EventTriggerCacheContext);
}
else
{
@@ -262,7 +262,7 @@ InvalidateEventCacheCallback(Datum arg, int cacheid, uint32 hashvalue)
*/
if (EventTriggerCacheState == ETCS_VALID)
{
- MemoryContextResetAndDeleteChildren(EventTriggerCacheContext);
+ MemoryContextReset(EventTriggerCacheContext);
EventTriggerCache = NULL;
}
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index eeb238331e4..6aeb855e491 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -1833,7 +1833,7 @@ FlushErrorState(void)
errordata_stack_depth = -1;
recursion_depth = 0;
/* Delete all data in ErrorContext */
- MemoryContextResetAndDeleteChildren(ErrorContext);
+ MemoryContextReset(ErrorContext);
}
/*
diff --git a/src/include/utils/memutils.h b/src/include/utils/memutils.h
index 21640d62a64..d14e8546a60 100644
--- a/src/include/utils/memutils.h
+++ b/src/include/utils/memutils.h
@@ -66,9 +66,6 @@ extern PGDLLIMPORT MemoryContext CurTransactionContext;
/* 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