Skip site navigation (1) Skip section navigation (2)

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 (view raw, whole thread or download thread 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

pgsql-bugs by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2018 The PostgreSQL Global Development Group