X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 36A689DCC2E for ; Thu, 9 Mar 2006 11:50:14 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 90886-06 for ; Thu, 9 Mar 2006 11:50:16 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 7D2779DCC5D for ; Thu, 9 Mar 2006 11:50:09 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id k29FoCmd025362; Thu, 9 Mar 2006 10:50:12 -0500 (EST) To: =?iso-8859-1?Q?Fl=E1vio_Suguimoto?= cc: "Richard Huxton" , pgsql-sql@postgresql.org Subject: Re: Problems with disabling triggers in Postgres 7.3.9 In-reply-to: References: Comments: In-reply-to =?iso-8859-1?Q?Fl=E1vio_Suguimoto?= message dated "Thu, 09 Mar 2006 11:25:28 -0300" Date: Thu, 09 Mar 2006 10:50:12 -0500 Message-ID: <25361.1141919412@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.112 required=5 tests=[AWL=0.112] X-Spam-Score: 0.112 X-Spam-Level: X-Archive-Number: 200603/142 X-Sequence-Number: 24488 =?iso-8859-1?Q?Fl=E1vio_Suguimoto?= 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