Re: BUG #6761: unexpected behaviour of 'now'::timestamp - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #6761: unexpected behaviour of 'now'::timestamp
Date
Msg-id 28436.1343235183@sss.pgh.pa.us
Whole thread Raw
In response to Re: BUG #6761: unexpected behaviour of 'now'::timestamp  (Pavel Stehule <pavel.stehule@gmail.com>)
Responses Re: BUG #6761: unexpected behaviour of 'now'::timestamp  (Bert Thomas <bthomas@brothom.nl>)
List pgsql-bugs
Pavel Stehule <pavel.stehule@gmail.com> writes:
> this is not bug - it is consequence of plan cache

FWIW, there is documentation of this issue near the end of
http://www.postgresql.org/docs/9.1/static/plpgsql-implementation.html#PLPGSQL-PLAN-CACHING

This exact case isn't covered in the examples, but the point is that the
expression 'now'::timestamp will get folded to a timestamp constant during
planning, and then not replanned later.  As Pavel says, it's a lot safer
to use one of the variants of the now() function.

            regards, tom lane

pgsql-bugs by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: BUG #6761: unexpected behaviour of 'now'::timestamp
Next
From: Tom Lane
Date:
Subject: Re: BUG #6758: ./configure script sets HAVE_WCSTOMBS_L 1