Re: [SQL] trigger for TRUNCATE?

2008-01-14 Thread Peter Childs
On 11/01/2008, Simon Riggs [EMAIL PROTECTED] wrote: On Fri, 2008-01-11 at 08:24 +, Richard Huxton wrote: I've always considered TRUNCATE to be DDL rather than DML. I mentally group it with DROP TABLE rather than DELETE DDL/DML probably isn't the right split, since its then arguable as

Re: [SQL] trigger for TRUNCATE?

2008-01-11 Thread Erik Jones
On Jan 11, 2008, at 2:24 AM, Richard Huxton wrote: Tom Lane wrote: Alvaro Herrera [EMAIL PROTECTED] writes: 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

Re: [SQL] trigger for TRUNCATE?

2008-01-11 Thread Bruce Momjian
Added to TODO: * Add ability to trigger on TRUNCATE http://archives.postgresql.org/pgsql-sql/2008-01/msg00050.php --- Simon Riggs wrote: On Fri, 2008-01-11 at 08:24 +, Richard Huxton wrote: I've always

Re: [SQL] trigger for TRUNCATE?

2008-01-11 Thread Simon Riggs
On Fri, 2008-01-11 at 08:24 +, Richard Huxton wrote: I've always considered TRUNCATE to be DDL rather than DML. I mentally group it with DROP TABLE rather than DELETE DDL/DML probably isn't the right split, since its then arguable as to which group of commands it belongs in. I see we

Re: [SQL] trigger for TRUNCATE?

2008-01-10 Thread Gerardo Herzig
Pavel Stehule wrote: On 08/01/2008, Chris Browne [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] (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

Re: [SQL] trigger for TRUNCATE?

2008-01-10 Thread Alvaro Herrera
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. Currently, Mammoth

Re: [SQL] trigger for TRUNCATE?

2008-01-10 Thread Tom Lane
Alvaro Herrera [EMAIL PROTECTED] 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

Re: [SQL] trigger for TRUNCATE?

2008-01-10 Thread Alvaro Herrera
Tom Lane escribió: Alvaro Herrera [EMAIL PROTECTED] 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

Re: [SQL] trigger for TRUNCATE?

2008-01-10 Thread Gerardo Herzig
Tom Lane wrote: Alvaro Herrera [EMAIL PROTECTED] 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

Re: [SQL] trigger for TRUNCATE?

2008-01-10 Thread Tom Lane
Alvaro Herrera [EMAIL PROTECTED] writes: 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

Re: [SQL] trigger for TRUNCATE?

2008-01-10 Thread Simon Riggs
Alvaro Herrera wrote: My thinking is that a TRUNCATE trigger is a per-statement trigger which doesn't have access to the set of deleted rows. In that way it would be different from a per-statement trigger for DELETE. Completely agree. A truncate trigger should run a different function to

Re: [SQL] trigger for TRUNCATE?

2008-01-10 Thread Chris Browne
[EMAIL PROTECTED] (Tom Lane) writes: Alvaro Herrera [EMAIL PROTECTED] 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

[SQL] trigger for TRUNCATE?

2008-01-08 Thread Gerardo Herzig
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? Thanks! Gerardo ---(end of broadcast)--- TIP 2: Don't 'kill -9' the postmaster

Re: [SQL] trigger for TRUNCATE?

2008-01-08 Thread Chris Browne
[EMAIL PROTECTED] (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

Re: [SQL] trigger for TRUNCATE?

2008-01-08 Thread Pavel Stehule
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 On 08/01/2008, Chris Browne [EMAIL PROTECTED] wrote: