pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Flávio Suguimoto <flavio.suguimoto@pragyatechnologies.com>
Cc: Richard Huxton <dev@archonet.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Problems with disabling triggers in Postgres 7.3.9
Date: Thu, 09 Mar 2006 10:50:12 -0500
Message-ID: <25361.1141919412@sss.pgh.pa.us> (raw)
In-Reply-To: <GFEGIFLJJCMGLBLAHILKIECHCGAA.flavio.suguimoto@pragyatechnologies.com>
References: <GFEGIFLJJCMGLBLAHILKIECHCGAA.flavio.suguimoto@pragyatechnologies.com>

=?iso-8859-1?Q?Fl=E1vio_Suguimoto?= <flavio.suguimoto@pragyatechnologies.com> writes:
> EXECUTE ''update pg_class set reltriggers = count(*) from pg_trigger where
> pg_class.oid=tgrelid and relname = '' || quote_literal(tablename);

This command is just plain wrong, because the aggregation is done across
uncertain scope.  Something like

update pg_class set reltriggers = (select count(*) from pg_trigger where
                                   pg_class.oid=tgrelid)
where relname = 'foo'

would at least not run the risk of assigning wrong counts.  You still
have the issue that the commands will touch every table with a given
name; there needs to be some thought about schemas here.

In general though I agree with Alvaro's comment that touching system
catalogs directly is bad practice.  You should update to a PG version
that has ALTER TABLE DISABLE TRIGGER, and use that.

			regards, tom lane



view thread (7+ messages)

Message-ID: <25361.1141919412@sss.pgh.pa.us>
Permalink:  ../25361.1141919412@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/25361.1141919412@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, flavio.suguimoto@pragyatechnologies.com, dev@archonet.com
  Subject: Re: Problems with disabling triggers in Postgres 7.3.9
  In-Reply-To: <25361.1141919412@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox