On Sun, Apr 21, 2024 at 1:55 PM David G. Johnston <david.g.johnston@xxxxxxxxx> wrote:
On Sunday, April 21, 2024, yudhi s <learnerdatabase99@xxxxxxxxx> wrote:so that it will be able to assign the privilege, so we will be able to create the event trigger without need to run the event trigger script from super user itself?Write a security-definer function owned by superuser and grant app_user permission to execute it.David J.
Thank You David.
CREATE OR REPLACE FUNCTION create_event_trigger_func()
RETURNS void
LANGUAGE plpgsql
SECURITY DEFINER
AS $$
BEGIN
EXECUTE 'CREATE EVENT TRIGGER event_trigger_name ON schema_name ...';
END;
$$;
GRANT EXECUTE ON FUNCTION create_event_trigger_func() TO app_user;