Skip to content

Instantly share code, notes, and snippets.

@pauldzy
Created August 14, 2019 14:45
Show Gist options
  • Save pauldzy/9e581f9672480bf78b792b793aaa97d6 to your computer and use it in GitHub Desktop.
Save pauldzy/9e581f9672480bf78b792b793aaa97d6 to your computer and use it in GitHub Desktop.
Alternative notify_ddl_postgrest event trigger
CREATE OR REPLACE FUNCTION public.notify_ddl_postgrest()
RETURNS event_trigger
AS $$
DECLARE
obj RECORD;
BEGIN
FOR obj IN SELECT * FROM pg_event_trigger_ddl_commands()
LOOP
IF obj.object_type IN ('type','function','procedure')
THEN
NOTIFY ddl_command_end;
END IF;
END LOOP;
END;
$$ LANGUAGE 'plpgsql';
CREATE EVENT TRIGGER ddl_postgrest ON ddl_command_end EXECUTE PROCEDURE public.notify_ddl_postgrest();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment