Re: BUG #6761: unexpected behaviour of 'now'::timestamp

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: bert(at)brothom(dot)nl, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #6761: unexpected behaviour of 'now'::timestamp
Date: 2012-07-25 16:53:03
Message-ID: 28436.1343235183@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox
Thread:
Lists: pgsql-bugs

Pavel Stehule <pavel(dot)stehule(at)gmail(dot)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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Bruce Momjian 2012-07-25 17:01:13 Re: [BUGS] BUG #6733: All Tables Empty After pg_upgrade (PG 9.2.0 beta 2)
Previous Message Pavel Stehule 2012-07-25 16:27:29 Re: BUG #6761: unexpected behaviour of 'now'::timestamp