Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id AB86DBEAE5C for ; Wed, 25 Jul 2012 13:53:23 -0300 (ADT) Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Su4pr-0001Fe-05 for pgsql-bugs@postgresql.org; Wed, 25 Jul 2012 16:53:23 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.5/8.14.5) with ESMTP id q6PGr434028438; Wed, 25 Jul 2012 12:53:04 -0400 (EDT) From: Tom Lane To: Pavel Stehule cc: bert@brothom.nl, pgsql-bugs@postgresql.org Subject: Re: BUG #6761: unexpected behaviour of 'now'::timestamp In-reply-to: References: Comments: In-reply-to Pavel Stehule message dated "Wed, 25 Jul 2012 18:27:29 +0200" Date: Wed, 25 Jul 2012 12:53:03 -0400 Message-ID: <28436.1343235183@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201207/198 X-Sequence-Number: 33674 Pavel Stehule 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