Re: BUG #13812: 'now' acting differently than now() in function

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: BUG #13812: 'now' acting differently than now() in function
Дата
Msg-id 22199.1449787723@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: BUG #13812: 'now' acting differently than now() in function  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список pgsql-bugs
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Thu, Dec 10, 2015 at 12:52 PM, <darin@darinhoward.com> wrote:
>> I would not expect the date2 on row 2 to be the same date2 as row 1.

> ​I may be missing a nuance here, this could
> maybe use better documentation surrounding implications, but the basic
> answer is that 'now' is a string literal that ends up getting resolved at
> parse time during the first invocation of the function and then its value
> is cached and re-used during subsequent executions.  The "now()" volatile
> function is instead left alone by the parser and instead is invoked during
> each execution of the UPDATE.

> I am going from memory here since I cannot locate the documentation that
> points out this fact...

There's some discussion near the bottom of this page:
http://www.postgresql.org/docs/9.4/static/plpgsql-implementation.html

            regards, tom lane

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

Предыдущее
От: "David G. Johnston"
Дата:
Сообщение: Re: BUG #13812: 'now' acting differently than now() in function
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: BUG #13809: Reassign owned throws error