Thread: Disable Trigger

Disable Trigger

From
Charles Haron
Date:
Is there a way to temporarily disable a trigger without dropping and
re-adding it?

Thanks,
Chuck


Re: Disable Trigger

From
Bruce Momjian
Date:
Charles Haron wrote:
> Is there a way to temporarily disable a trigger without dropping and
> re-adding it?

You can update the sytem tables by setting the number of triggers to
zero on the table. See the PostgreSQL cookbook for examples.  We have a
TODO item to get this implemented cleanly.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Re: Disable Trigger

From
CoL
Date:
hi,

Charles Haron wrote, On 3/23/2004 21:48:

> Is there a way to temporarily disable a trigger without dropping and
> re-adding it?

if you ever use dump:
pg_dump --disable-triggers ...


off:
UPDATE pg_catalog.pg_class SET reltriggers = 0 WHERE oid =
'tablename'::pg_catalog.regclass;

on:
UPDATE pg_catalog.pg_class SET reltriggers = (SELECT pg_catalog.count(*)
FROM pg_catalog.pg_trigger where pg_class.oid = tgrelid) WHERE oid =
'tablename'::pg_catalog.regclass;

C.