You can use the following to list the triggers and see what functions they
call. Then you can check pg_proc to see how TRUNCATE is used in prosrc.


SELECT c.relname,
       t.tgname,
       p.proname        AS function_called,
       t.tgconstraint   AS is_constraint,
       CASE WHEN t.tgconstrrelid > 0
            THEN (SELECT relname
                   FROM pg_class
                  WHERE oid = t.tgconstrrelid)
            ELSE ''
        END             AS constr_tbl,
       t.tgenabled
  FROM pg_trigger t
  INNER JOIN pg_proc p  ON ( p.oid = t.tgfoid)
  INNER JOIN pg_class c ON (c.oid = t.tgrelid)
  WHERE tgname NOT LIKE 'pg_%'
    AND tgname NOT LIKE 'RI_%'  -- < comment out to see constraints
--    AND t.tgenabled = FALSE
 ORDER BY 1;


On Tue, Jun 2, 2015 at 5:31 AM, Albe Laurenz <laurenz.a...@wien.gv.at>
wrote:

> Andreas Ulbrich wrote:
> > I'm in a handle for a trigger for TRUNCATE. Is it possible to find out
> > whether the TRUNCATE TABLE ist called with CASCADE?
>
> I don't think there is.
>
> But you can find out the table where the trigger is defined and examine
> if any foreign key constraints are referring to it.
>
> If yes, then the trigger was called with CASCADE.
> If no, it might have been called either way, but the effect would be the
> same.
>
> Yours,
> Laurenz Albe
>
> --
> Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>



-- 
*Melvin Davidson*
I reserve the right to fantasize.  Whether or not you
wish to share my fantasy is entirely up to you.

Reply via email to