Tom Lane wrote:
> I'm not sure there is any clean solution that would make this do what
> you expect, partly because it's not real clear what you expect
> (consider nested SECURITY DEFINER functions, error recovery, etc).
> I'd be inclined to put a band-aid on it by forbidding SET SESSION
> AUTHORIZATION inside functions.
Well, we could also try to just not switch back to the old value when
exiting the function. I'll have a look to see whether that is doable.