1

Can I restrict an event trigger to only capture events when DDL is performed against a specific set of tables?

d4nielfr4nco
  • 635
  • 1
  • 6
  • 17

1 Answers1

3

I don't think you can avoid capturing the event, as the current CREATE EVENT TRIGGER statement only supports filtering by command tag.

Once you're in the trigger function, you have access to a bit more information, so you could put something like this at the top:

IF EXISTS (
    SELECT 1 FROM pg_event_trigger_ddl_commands()
    WHERE object_identity NOT IN ('myschema.mytable')
  )
THEN
  RETURN;
END IF;
Nick Barnes
  • 19,816
  • 3
  • 51
  • 63