Received: from localhost (unknown [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 7699F2E36CB for ; Thu, 10 Jan 2008 13:47:21 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 30288-06 for ; Thu, 10 Jan 2008 13:47:16 -0400 (AST) Received: from lists.commandprompt.com (host-159.commandprompt.net [207.173.203.159]) by postgresql.org (Postfix) with ESMTP id D8EA12E3692 for ; Thu, 10 Jan 2008 13:47:16 -0400 (AST) Received: from perhan.alvh.no-ip.org (200-126-101-79.bk7-dsl.surnet.cl [200.126.101.79]) (authenticated bits=0) by lists.commandprompt.com (8.13.8/8.13.8) with ESMTP id m0AHlE68027950 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 10 Jan 2008 09:47:16 -0800 Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 4491B47BCC; Thu, 10 Jan 2008 14:47:05 -0300 (CLST) Date: Thu, 10 Jan 2008 14:47:05 -0300 From: Alvaro Herrera To: Tom Lane Cc: Gerardo Herzig , Pavel Stehule , Chris Browne , pgsql-sql@postgresql.org Subject: Re: trigger for TRUNCATE? Message-ID: <20080110174705.GO6465@alvh.no-ip.org> References: <4783BEA9.3020507@fmed.uba.ar> <60tzloyr0u.fsf@dba2.int.libertyrms.com> <162867790801081338n237497efpecffaa255253274d@mail.gmail.com> <47864A6B.3070902@fmed.uba.ar> <20080110171027.GK6465@alvh.no-ip.org> <8003.1199986734@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <8003.1199986734@sss.pgh.pa.us> User-Agent: Mutt/1.5.17 (2007-11-01) X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0 (lists.commandprompt.com [207.173.203.159]); Thu, 10 Jan 2008 09:47:17 -0800 (PST) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200801/71 X-Sequence-Number: 29924 Tom Lane escribió: > Alvaro Herrera writes: > > Gerardo Herzig escribió: > >> Yes, the TRUNCATE statement is not sql ansi, maybe is a more low level > >> thing than i think. > > > TRUNCATE currently does not fire triggers, but that doesn't mean it's > > impossible to do it. I think it would be fairly easy to add support > > for that. > > The entire point of TRUNCATE is to not do a table scan, so making it > fire per-row triggers seems pretty misguided to me. My thinking is that a TRUNCATE trigger is a per-statement trigger which doesn't have access to the set of deleted rows (Replicator uses it that way -- we replicate the truncate action, and replay it on the replica). In that way it would be different from a per-statement trigger for DELETE. -- Alvaro Herrera http://www.CommandPrompt.com/ PostgreSQL Replication, Consulting, Custom Development, 24x7 support