Re: Problems with disabling triggers in Postgres 7.3.9 - Mailing list pgsql-sql

From Tom Lane
Subject Re: Problems with disabling triggers in Postgres 7.3.9
Date
Msg-id 25361.1141919412@sss.pgh.pa.us
Whole thread Raw
In response to Re: Problems with disabling triggers in Postgres 7.3.9  (Flávio Suguimoto<flavio.suguimoto@pragyatechnologies.com>)
List pgsql-sql
Flávio 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


pgsql-sql by date:

Previous
From: Flávio Suguimoto
Date:
Subject: Re: Problems with disabling triggers in Postgres 7.3.9
Next
From: Markus Schaber
Date:
Subject: Set generating functions and subqueries