Andres Freund <andres@anarazel.de> writes:
> After doing so, I got pretty weird crashes. A bit of debugging later it
> became apparent that the issue is in how plpgsql caches expression
> states: ...
> which means we'll re-use ExprStates built in another subtransaction.
Sure, why not? They generally aren't going to change across
subtransactions.
I do not recall that there's a separate resowner for those things
though. Usually the idea for ExprState-related resources is to
clean them up in an ExprContextCallback, cf executor/functions.c.
Might work better if you attack it that way instead of via a resowner.
Or maybe we could set up a separate resowner for plpgsql's simple
expression states. Not sure what consequences that would have,
but it doesn't seem unreasonable on its face.
regards, tom lane