d4nielfr4nco
d4nielfr4nco

Reputation: 655

Is it possible to capture DDL events against a specific set of tables with PostgreSQL's event triggers?

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

Upvotes: 1

Views: 214

Answers (1)

Nick Barnes
Nick Barnes

Reputation: 21326

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;

Upvotes: 3

Related Questions