Search code examples
postgresqlpostgresql-9.6postgresql-10

Postgres find which tables are modified in DML trigger


I have hundreds of DML triggers across multiple schemas. Most of them modify the DML of more than one table.

Using information_schema.triggers and pg_trigger tables I am able to find the list of triggers and the trigger event tables alone.

Is it possible to get the list of tables that are modified(trigger target tables) by each trigger?


Solution

  • No, because the trigger action is a function, and functions are stored as plain strings in the prosrc column of the pg_proc system catalog table.

    You could perform a case insensitive search for table names in that column, but you are going to come up with false positives (any if dynamic SQL is used, with a couple of false negatives too).