Re: Very strange 'now' behaviour in nested triggers.

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Very strange 'now' behaviour in nested triggers.
Дата
Msg-id 4629.1059320950@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Very strange 'now' behaviour in nested triggers.  (Denis Zaitsev <zzz@anda.ru>)
Ответы Re: Very strange 'now' behaviour in nested triggers.  (Roberto Mello <rmello@cc.usu.edu>)
Re: Very strange 'now' behaviour in nested triggers.  (Dmitry Tkach <dmitry@openratings.com>)
Re: Very strange 'now' behaviour in nested triggers.  (Denis Zaitsev <zzz@anda.ru>)
Re: Very strange 'now' behaviour in nested triggers.  (Bruce Momjian <pgman@candle.pha.pa.us>)
Список pgsql-sql
Denis Zaitsev <zzz@anda.ru> writes:
> On Sat, Jul 26, 2003 at 10:31:44AM -0400, Tom Lane wrote:
>> That's a dangerous way to define the default --- 'now' is taken as a
>> literal of type timestamp, which means it will be reduced to a timestamp
>> constant as soon as a statement that requires the default is planned.

> Aaa...  So, the INSERT inside a trigger will use the 'now' for the
> time this trigger is compiled (i.e. called first time)?  Do I
> understand right?  And the only outer trigger uses the right 'now' as
> its value goes from the top-level INSERT...

Right.

I put up a proposal in pgsql-hackers to change this behavior:
http://archives.postgresql.org/pgsql-hackers/2003-07/msg00818.php
If we made that change then the "wrong" way of defining the default
would fail in an obvious fashion --- the 'now' would get reduced to a
particular time immediately at CREATE TABLE.  Doubtless this would annoy
some people, but the "right" way of defining the default isn't really
any harder, and it would save folks from getting burnt in corner cases,
like you were.

Any comments?
        regards, tom lane


В списке pgsql-sql по дате отправления:

Предыдущее
От: Denis Zaitsev
Дата:
Сообщение: Re: Very strange 'now' behaviour in nested triggers.
Следующее
От: Roberto Mello
Дата:
Сообщение: Re: Very strange 'now' behaviour in nested triggers.