Andrew Gierth <andrew@tao11.riddles.org.uk> writes:
> "Tom" == Tom Lane <tgl@sss.pgh.pa.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