Received: from localhost (unknown [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 05AE02E331E for ; Thu, 10 Jan 2008 12:37:14 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 10905-01-6 for ; Thu, 10 Jan 2008 12:37:04 -0400 (AST) Received: from mail.fmed.uba.ar (mail.fmed.uba.ar [157.92.152.1]) by postgresql.org (Postfix) with ESMTP id BCD412E3130 for ; Thu, 10 Jan 2008 12:37:04 -0400 (AST) Received: from [157.92.155.58] (mailbis [157.92.155.58]) by mail.fmed.uba.ar (Postfix) with ESMTP id 2B24311DA45; Thu, 10 Jan 2008 14:37:07 -0200 (ARST) Message-ID: <47864A6B.3070902@fmed.uba.ar> Date: Thu, 10 Jan 2008 13:40:11 -0300 From: Gerardo Herzig User-Agent: Mozilla Thunderbird 1.0.7 (X11/20050923) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Pavel Stehule CC: Chris Browne , pgsql-sql@postgresql.org Subject: Re: trigger for TRUNCATE? References: <4783BEA9.3020507@fmed.uba.ar> <60tzloyr0u.fsf@dba2.int.libertyrms.com> <162867790801081338n237497efpecffaa255253274d@mail.gmail.com> In-Reply-To: <162867790801081338n237497efpecffaa255253274d@mail.gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200801/68 X-Sequence-Number: 29921 Pavel Stehule wrote: >On 08/01/2008, Chris Browne wrote: > > >>gherzig@fmed.uba.ar (Gerardo Herzig) writes: >> >> >>>Hi all. Acording to the docs, TRUNCATE will not fire a DELETE trigger >>>on the table being truncated. >>>There is a way to capture a TRUNCATE in any way? >>> >>> >>I think there's some sort of "to do" on that... >> >>It ought to be not *too* difficult (I imagine!) to be able to >>associate a trigger with the TRUNCATE action, and therefore run some >>stored function any time TRUNCATE takes place. >> >>For the Slony-I replication system, it would be attractive for this to >>lead to attaching two functions: >> - One function would return an exception so that TRUNCATE against >> a subscriber node would fail... >> >> - Another would pretty much be as simple as submitting an event; >> perform createEvent('_ourcluster', 'TRUNCATE_TABLE', table_id); >> >>A new event, TRUNCATE_TABLE, would do a TRUNCATE against the >>subscribers. >> >>This represents a pretty easy enhancement, given the new kind of >>trigger. >>-- >>(reverse (concatenate 'string "moc.enworbbc" "@" "enworbbc")) >>http://www3.sympatico.ca/cbbrowne/nonrdbms.html >>Frisbeetarianism: The belief that when you die, your soul goes up on >>the roof and gets stuck... >> >>Hello >> >>theoretically you can have trigger on any statement, but I am not sure >>about conformance with std. But, you can wrap TRUNCATE statement into >>some procedure, and then call this procedure with some other actions. >> >>Regards >>Pavel Stehule >> >> >> Yes, the TRUNCATE statement is not sql ansi, maybe is a more low level thing than i think. Gerardo