Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 6a72c42

Browse files
Retire MemoryContextResetAndDeleteChildren() macro.
As of commit eaa5808, 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
1 parent 83267b1 commit 6a72c42

File tree

18 files changed

+31
-34
lines changed

18 files changed

+31
-34
lines changed

src/backend/access/brin/brin.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ brininsert(Relation idxRel, Datum *values, bool *nulls,
297297
samepage))
298298
{
299299
/* no luck; start over */
300-
MemoryContextResetAndDeleteChildren(tupcxt);
300+
MemoryContextReset(tupcxt);
301301
continue;
302302
}
303303
}
@@ -533,7 +533,7 @@ bringetbitmap(IndexScanDesc scan, TIDBitmap *tbm)
533533

534534
CHECK_FOR_INTERRUPTS();
535535

536-
MemoryContextResetAndDeleteChildren(perRangeCxt);
536+
MemoryContextReset(perRangeCxt);
537537

538538
tup = brinGetTupleForHeapBlock(opaque->bo_rmAccess, heapBlk, &buf,
539539
&off, &size, BUFFER_LOCK_SHARE);

src/backend/access/gin/ginscan.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ ginFreeScanKeys(GinScanOpaque so)
251251
tbm_free(entry->matchBitmap);
252252
}
253253

254-
MemoryContextResetAndDeleteChildren(so->keyCtx);
254+
MemoryContextReset(so->keyCtx);
255255

256256
so->keys = NULL;
257257
so->nkeys = 0;

src/backend/access/transam/xact.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1933,7 +1933,7 @@ AtCleanup_Memory(void)
19331933
* Clear the special abort context for next time.
19341934
*/
19351935
if (TransactionAbortContext != NULL)
1936-
MemoryContextResetAndDeleteChildren(TransactionAbortContext);
1936+
MemoryContextReset(TransactionAbortContext);
19371937

19381938
/*
19391939
* Release all transaction-local memory.
@@ -1969,7 +1969,7 @@ AtSubCleanup_Memory(void)
19691969
* Clear the special abort context for next time.
19701970
*/
19711971
if (TransactionAbortContext != NULL)
1972-
MemoryContextResetAndDeleteChildren(TransactionAbortContext);
1972+
MemoryContextReset(TransactionAbortContext);
19731973

19741974
/*
19751975
* Delete the subxact local memory contexts. Its CurTransactionContext can

src/backend/commands/analyze.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ do_analyze_rel(Relation onerel, VacuumParams *params,
583583
stats->stadistinct = n_distinct;
584584
}
585585

586-
MemoryContextResetAndDeleteChildren(col_context);
586+
MemoryContextReset(col_context);
587587
}
588588

589589
if (nindexes > 0)
@@ -972,7 +972,7 @@ compute_index_stats(Relation onerel, double totalrows,
972972
numindexrows,
973973
totalindexrows);
974974

975-
MemoryContextResetAndDeleteChildren(col_context);
975+
MemoryContextReset(col_context);
976976
}
977977
}
978978

@@ -981,7 +981,7 @@ compute_index_stats(Relation onerel, double totalrows,
981981

982982
ExecDropSingleTupleTableSlot(slot);
983983
FreeExecutorState(estate);
984-
MemoryContextResetAndDeleteChildren(ind_context);
984+
MemoryContextReset(ind_context);
985985
}
986986

987987
MemoryContextSwitchTo(old_context);

src/backend/executor/nodeRecursiveunion.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ ExecReScanRecursiveUnion(RecursiveUnionState *node)
317317

318318
/* Release any hashtable storage */
319319
if (node->tableContext)
320-
MemoryContextResetAndDeleteChildren(node->tableContext);
320+
MemoryContextReset(node->tableContext);
321321

322322
/* Empty hashtable if needed */
323323
if (plan->numCols > 0)

src/backend/executor/nodeSetOp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ ExecReScanSetOp(SetOpState *node)
631631

632632
/* Release any hashtable storage */
633633
if (node->tableContext)
634-
MemoryContextResetAndDeleteChildren(node->tableContext);
634+
MemoryContextReset(node->tableContext);
635635

636636
/* And rebuild empty hashtable if needed */
637637
if (((SetOp *) node->ps.plan)->strategy == SETOP_HASHED)

src/backend/executor/nodeWindowAgg.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ initialize_windowaggregate(WindowAggState *winstate,
216216
* it, so we must leave it to the caller to reset at an appropriate time.
217217
*/
218218
if (peraggstate->aggcontext != winstate->aggcontext)
219-
MemoryContextResetAndDeleteChildren(peraggstate->aggcontext);
219+
MemoryContextReset(peraggstate->aggcontext);
220220

221221
if (peraggstate->initValueIsNull)
222222
peraggstate->transValue = peraggstate->initValue;
@@ -875,7 +875,7 @@ eval_windowaggregates(WindowAggState *winstate)
875875
* result for it, else we'll leak memory.
876876
*/
877877
if (numaggs_restart > 0)
878-
MemoryContextResetAndDeleteChildren(winstate->aggcontext);
878+
MemoryContextReset(winstate->aggcontext);
879879
for (i = 0; i < numaggs; i++)
880880
{
881881
peraggstate = &winstate->peragg[i];
@@ -1351,12 +1351,12 @@ release_partition(WindowAggState *winstate)
13511351
* any aggregate temp data). We don't rely on retail pfree because some
13521352
* aggregates might have allocated data we don't have direct pointers to.
13531353
*/
1354-
MemoryContextResetAndDeleteChildren(winstate->partcontext);
1355-
MemoryContextResetAndDeleteChildren(winstate->aggcontext);
1354+
MemoryContextReset(winstate->partcontext);
1355+
MemoryContextReset(winstate->aggcontext);
13561356
for (i = 0; i < winstate->numaggs; i++)
13571357
{
13581358
if (winstate->peragg[i].aggcontext != winstate->aggcontext)
1359-
MemoryContextResetAndDeleteChildren(winstate->peragg[i].aggcontext);
1359+
MemoryContextReset(winstate->peragg[i].aggcontext);
13601360
}
13611361

13621362
if (winstate->buffer)

src/backend/executor/spi.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ AtEOSubXact_SPI(bool isCommit, SubTransactionId mySubid)
547547
if (_SPI_current->execSubid >= mySubid)
548548
{
549549
_SPI_current->execSubid = InvalidSubTransactionId;
550-
MemoryContextResetAndDeleteChildren(_SPI_current->execCxt);
550+
MemoryContextReset(_SPI_current->execCxt);
551551
}
552552

553553
/* throw away any tuple tables created within current subxact */
@@ -3083,7 +3083,7 @@ _SPI_end_call(bool use_exec)
30833083
/* mark Executor context no longer in use */
30843084
_SPI_current->execSubid = InvalidSubTransactionId;
30853085
/* and free Executor memory */
3086-
MemoryContextResetAndDeleteChildren(_SPI_current->execCxt);
3086+
MemoryContextReset(_SPI_current->execCxt);
30873087
}
30883088

30893089
return 0;

src/backend/postmaster/autovacuum.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ AutoVacLauncherMain(int argc, char *argv[])
555555
FlushErrorState();
556556

557557
/* Flush any leaked data in the top-level context */
558-
MemoryContextResetAndDeleteChildren(AutovacMemCxt);
558+
MemoryContextReset(AutovacMemCxt);
559559

560560
/* don't leave dangling pointers to freed memory */
561561
DatabaseListCxt = NULL;
@@ -2521,7 +2521,7 @@ do_autovacuum(void)
25212521

25222522

25232523
/* clean up memory before each iteration */
2524-
MemoryContextResetAndDeleteChildren(PortalContext);
2524+
MemoryContextReset(PortalContext);
25252525

25262526
/*
25272527
* Save the relation name for a possible error message, to avoid a
@@ -2576,7 +2576,7 @@ do_autovacuum(void)
25762576
/* this resets ProcGlobal->statusFlags[i] too */
25772577
AbortOutOfAnyTransaction();
25782578
FlushErrorState();
2579-
MemoryContextResetAndDeleteChildren(PortalContext);
2579+
MemoryContextReset(PortalContext);
25802580

25812581
/* restart our transaction for the following operations */
25822582
StartTransactionCommand();
@@ -2718,7 +2718,7 @@ perform_work_item(AutoVacuumWorkItem *workitem)
27182718
autovac_report_workitem(workitem, cur_nspname, cur_relname);
27192719

27202720
/* clean up memory before each work item */
2721-
MemoryContextResetAndDeleteChildren(PortalContext);
2721+
MemoryContextReset(PortalContext);
27222722

27232723
/*
27242724
* We will abort the current work item if something errors out, and
@@ -2770,7 +2770,7 @@ perform_work_item(AutoVacuumWorkItem *workitem)
27702770
/* this resets ProcGlobal->statusFlags[i] too */
27712771
AbortOutOfAnyTransaction();
27722772
FlushErrorState();
2773-
MemoryContextResetAndDeleteChildren(PortalContext);
2773+
MemoryContextReset(PortalContext);
27742774

27752775
/* restart our transaction for the following operations */
27762776
StartTransactionCommand();

src/backend/postmaster/bgwriter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ BackgroundWriterMain(void)
182182
FlushErrorState();
183183

184184
/* Flush any leaked data in the top-level context */
185-
MemoryContextResetAndDeleteChildren(bgwriter_context);
185+
MemoryContextReset(bgwriter_context);
186186

187187
/* re-initialize to avoid repeated errors causing problems */
188188
WritebackContextInit(&wb_context, &bgwriter_flush_after);

src/backend/postmaster/checkpointer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ CheckpointerMain(void)
290290
FlushErrorState();
291291

292292
/* Flush any leaked data in the top-level context */
293-
MemoryContextResetAndDeleteChildren(checkpointer_context);
293+
MemoryContextReset(checkpointer_context);
294294

295295
/* Now we can allow interrupts again */
296296
RESUME_INTERRUPTS();

src/backend/postmaster/walwriter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ WalWriterMain(void)
178178
FlushErrorState();
179179

180180
/* Flush any leaked data in the top-level context */
181-
MemoryContextResetAndDeleteChildren(walwriter_context);
181+
MemoryContextReset(walwriter_context);
182182

183183
/* Now we can allow interrupts again */
184184
RESUME_INTERRUPTS();

src/backend/replication/logical/worker.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3647,7 +3647,7 @@ LogicalRepApplyLoop(XLogRecPtr last_received)
36473647
}
36483648

36493649
/* Cleanup the memory. */
3650-
MemoryContextResetAndDeleteChildren(ApplyMessageContext);
3650+
MemoryContextReset(ApplyMessageContext);
36513651
MemoryContextSwitchTo(TopMemoryContext);
36523652

36533653
/* Check if we need to exit the streaming loop. */

src/backend/statistics/extended_stats.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2237,7 +2237,7 @@ compute_expr_stats(Relation onerel, double totalrows,
22372237

22382238
ExecDropSingleTupleTableSlot(slot);
22392239
FreeExecutorState(estate);
2240-
MemoryContextResetAndDeleteChildren(expr_context);
2240+
MemoryContextReset(expr_context);
22412241
}
22422242

22432243
MemoryContextSwitchTo(old_context);

src/backend/tcop/postgres.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4457,7 +4457,7 @@ PostgresMain(const char *dbname, const char *username)
44574457
* query input buffer in the cleared MessageContext.
44584458
*/
44594459
MemoryContextSwitchTo(MessageContext);
4460-
MemoryContextResetAndDeleteChildren(MessageContext);
4460+
MemoryContextReset(MessageContext);
44614461

44624462
initStringInfo(&input_message);
44634463

src/backend/utils/cache/evtcache.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ BuildEventTriggerCache(void)
9191
* This can happen either because a previous rebuild failed, or
9292
* because an invalidation happened before the rebuild was complete.
9393
*/
94-
MemoryContextResetAndDeleteChildren(EventTriggerCacheContext);
94+
MemoryContextReset(EventTriggerCacheContext);
9595
}
9696
else
9797
{
@@ -262,7 +262,7 @@ InvalidateEventCacheCallback(Datum arg, int cacheid, uint32 hashvalue)
262262
*/
263263
if (EventTriggerCacheState == ETCS_VALID)
264264
{
265-
MemoryContextResetAndDeleteChildren(EventTriggerCacheContext);
265+
MemoryContextReset(EventTriggerCacheContext);
266266
EventTriggerCache = NULL;
267267
}
268268

src/backend/utils/error/elog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1833,7 +1833,7 @@ FlushErrorState(void)
18331833
errordata_stack_depth = -1;
18341834
recursion_depth = 0;
18351835
/* Delete all data in ErrorContext */
1836-
MemoryContextResetAndDeleteChildren(ErrorContext);
1836+
MemoryContextReset(ErrorContext);
18371837
}
18381838

18391839
/*

src/include/utils/memutils.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,6 @@ extern PGDLLIMPORT MemoryContext CurTransactionContext;
6666
/* This is a transient link to the active portal's memory context: */
6767
extern PGDLLIMPORT MemoryContext PortalContext;
6868

69-
/* Backwards compatibility macro */
70-
#define MemoryContextResetAndDeleteChildren(ctx) MemoryContextReset(ctx)
71-
7269

7370
/*
7471
* Memory-context-type-independent functions in mcxt.c

0 commit comments

Comments
 (0)