Re: Turning off triggers ? - Mailing list pgsql-general

From Jean-Luc Lachance
Subject Re: Turning off triggers ?
Date
Msg-id 3DE252CF.DD30D223@nsd.ca
Whole thread Raw
In response to Re: Turning off triggers ?  (Adam Witney <awitney@sghms.ac.uk>)
Responses eXtreme PostgreSQL using system catalogs (was Turning off triggers ?)  (Chris Gamache <cgg007@yahoo.com>)
List pgsql-general
If you look at a pg_dump file, you will find:

UPDATE "pg_class" SET "reltriggers" = 0 WHERE "relname" = '<table
name>';

UPDATE pg_class SET reltriggers = (
  SELECT count(*) FROM pg_trigger where pg_class.oid = tgrelid)
WHERE relname = '<table name>';

The first statemant turn off trigers, the second turns them back on.

JLL


Adam Witney wrote:
>
> Never tried this myself but there is an entry in the cookbook pages that, on
> the face of it seems to do what you are asking...
>
> http://www.brasileiro.net:8080/postgres/cookbook/view-one-recipe.adp?recipe_
> id=5925
>
> > On 25 Nov 2002, Glen Eustace wrote:
> >
> >> Is there a way that all the triggers associated with a table can be
> >> turned off ? I would like to be able to bulk load a table ( I have to
> >> use inserts not copy ) and I don't want the triggers to fire. Once
> >> loaded I want to turn them back on again. This process will be repeated
> >> quite often ( during the development phase).
>
> --
> This message has been scanned for viruses and
> dangerous content by MailScanner, and is
> believed to be clean.
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster

pgsql-general by date:

Previous
From: Adam Witney
Date:
Subject: Re: Turning off triggers ?
Next
From: "Hilmar Lapp"
Date:
Subject: Re: transaction aborted, queries ignored