Hi,
On 2023-04-29 18:24:47 -0400, Tom Lane wrote:
> A completely different way of looking at it is that we should not
> treat this as ExecBRUpdateTriggers's bug at all. The slot mechanisms
> are supposed to protect the data referenced by a slot, so why is that
> failing to happen in this example? The correct fix might involve
> newslot acquiring a buffer pin, for example.
I think the slot mechanism today (and historically) doesn't protect against
quite a few such scenarios - and it's not clear how to change that. Most of
the scenarios where we need to materialize are because the underlying memory
is going to be released / reset, i.e. we don't hold a buffer pin in the first
place. I guess we could try to protect against that by registering a memory
context hook, but that'd be a very heavyweight mechanism.
Greetings,
Andres Freund