Re: Proposal: SET ROLE hook - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Proposal: SET ROLE hook
Date
Msg-id 7081.1452105401@sss.pgh.pa.us
Whole thread Raw
In response to Re: Proposal: SET ROLE hook  (Joe Conway <mail@joeconway.com>)
Responses Re: Proposal: SET ROLE hook  (Joe Conway <mail@joeconway.com>)
List pgsql-hackers
Joe Conway <mail@joeconway.com> writes:
> Compared to both of these alternatives, I still feel that the specific
> SET ROLE hook is cleanest and best path forward. If there are no other
> comments or concerns, I will commit this in a day or two.

While I don't think there's any great harm in inventing such a hook, I'm
not sure it's going to be all that useful where placed.  GUC assign_hooks
basically cannot risk throwing errors, which enormously restricts what can
safely be done inside the proposed hook: it would be unwise to do catalog
accesses, for example.  (Which means I think the example usage is broken;
in fact, it's already broken by your note that the code has to be able to
execute in a failed transaction.)

I think a design that was actually somewhat robust would require two
hooks, one at check_role and one at assign_role, wherein the first one
would do any potentially-failing work and package all required info into
a blob that could be passed through to the assign hook.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Greg Stark
Date:
Subject: Re: pglogical_output - a general purpose logical decoding output plugin
Next
From: Robert Haas
Date:
Subject: Re: Proposal for JSONB functions for internal representation casting insted text-casting