From: | Denis Zaitsev <zzz(at)anda(dot)ru> |
---|---|
To: | Richard Huxton <dev(at)archonet(dot)com> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Very strange 'now' behaviour in nested triggers. |
Date: | 2003-07-26 19:58:32 |
Message-ID: | 20030727015832.D1636@natasha.ward.six |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc pgsql-sql |
On Sat, Jul 26, 2003 at 03:14:16PM +0100, Richard Huxton wrote:
> On Saturday 26 July 2003 14:39, Denis Zaitsev wrote:
> > In short, the idea this example is to test for is to split a
> > comma-separated value of some text attribute (given to the INSERT
> > operator) and then insert a row for each of the parts of that text
> > value. I've tried to do this thru a nested triggers approach.
>
> I'm not sure I'd use this approach for very long strings
Of course not a very deep recursion, the strings are expected to
consist of less than 10 pieces.
> Not exactly a bug. The crucial thing is that 'now' gets evaluated when the
> query is parsed and the plan built. For the main INSERT that's at the start
> of the transaction (which is what you want).
>
> For the trigger function, what happens is the plan for that insert gets
> compiled the first time the function is called and 'now' gets frozen.
Ok, thanks a much. I've realized...
> Solution: make the default now() or CURRENT_TIMESTAMP and all will be as you
> expect.
>
> PS - I think this is mentioned in the manuals somewhere, but it's not
> surprising you missed it. Interesting example.
As I remember, namely 'now' is mentioned in the manuals, as the best
approach to keep the same value thru the whole transaction. That is
why I used it here. For now I've tested that now() does the thing.
Why? I remember that now() is changing thru the transaction, just
showing the current time...
From | Date | Subject | |
---|---|---|---|
Next Message | Denis Zaitsev | 2003-07-26 20:01:04 | Re: Very strange 'now' behaviour in nested triggers. |
Previous Message | Tom Lane | 2003-07-26 14:31:44 | Re: Very strange 'now' behaviour in nested triggers. |
From | Date | Subject | |
---|---|---|---|
Next Message | Denis Zaitsev | 2003-07-26 20:01:04 | Re: Very strange 'now' behaviour in nested triggers. |
Previous Message | Tom Lane | 2003-07-26 14:31:44 | Re: Very strange 'now' behaviour in nested triggers. |