Re: Problems with disabling triggers in Postgres 7.3.9
| От | Tom Lane |
|---|---|
| Тема | Re: Problems with disabling triggers in Postgres 7.3.9 |
| Дата | |
| Msg-id | 25361.1141919412@sss.pgh.pa.us обсуждение исходный текст |
| Ответ на | Re: Problems with disabling triggers in Postgres 7.3.9 (Flávio Suguimoto<flavio.suguimoto@pragyatechnologies.com>) |
| Список | 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 по дате отправления: