Re: Renaming MemoryContextResetAndDeleteChildren to MemoryContextReset

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: Renaming MemoryContextResetAndDeleteChildren to MemoryContextReset
Date: 2015-02-27 13:42:33
Message-ID: 27753.1425044553@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk> writes:
> "Tom" == Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:
> Tom> We've discussed doing $SUBJECT off and on for nearly ten years,

> So, this is also changing (indirectly) the effect of ReScanExprContext
> so that deletes child contexts too.

Right, this is actually the main point so far as I'm concerned. My
"expanded arrays" patch currently has

#define ResetExprContext(econtext) \
- MemoryContextReset((econtext)->ecxt_per_tuple_memory)
+ MemoryContextResetAndDeleteChildren((econtext)->ecxt_per_tuple_memory)

but this is a more general fix.

> I guess the only question is whether anything currently relies on
> ReScanExprContext's current behavior.

I've not seen any regression test failures either with the "expanded
arrays" patch or this one. It's conceivable that something would create a
context under a short-lived expression context and expect it to still be
there (though empty) after a context reset; that idea was the reason I
designed MemoryContextReset this way in the first place. But fifteen
years later, it's quite clear that that was a mistake and we don't
actually use contexts that way.

(Worth noting is that the memory context reset callback mechanism
I propose nearby is sort of a second pass at expression shutdown
callbacks, as well.)

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message ktm@rice.edu 2015-02-27 14:03:28 Re: GSoC idea - Simulated annealing to search for query plans
Previous Message Robert Haas 2015-02-27 12:54:34 Re: MemoryContext reset/delete callbacks