Re: Allow database owners to CREATE EVENT TRIGGER

David G. Johnston <david.g.johnston@gmail.com>

From: "David G. Johnston" <david.g.johnston@gmail.com>
To: Steve Chavez <steve@supabase.io>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, Aleksander Alekseev <aleksander@timescale.com>, PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2025-04-23T00:41:05Z
Lists: pgsql-hackers
On Tuesday, April 22, 2025, Steve Chavez <steve@supabase.io> wrote:

> >  alter event trigger command which doesn’t need to be exercised here
>
> That part does need to be tested, I modified `AlterEventTriggerOwner_internal`
> to allow altering owners to regular users. Before it was only restricted to
> superusers.
>
> > Actually, leave the other member around, but not granted ownership, and
> both create tables, to demonstrate that a non-superuser and non-owner is
> unaffected by the trigger.
>
> I've updated the tests accordingly. Please let me know if that's what you
> had in mind.
>

Pretty much.  You have a bad drop table cleanup command, and I’d drop the
entire alter event trigger owner test.

The other thing I’m wondering, but haven’t gotten around to testing, is
whether a role affected by the event trigger is able to just drop the
trigger given this implementation.  I always get member/member-of dynamics
confused.  Having member (possibly via set role…) trying to drop the
trigger would be good to prove that it isn’t allowed.

David J.