Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1a7A1r-0004Qk-Iu for pgsql-bugs@arkaria.postgresql.org; Thu, 10 Dec 2015 22:49:39 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1a7A1r-0005xP-2C for pgsql-bugs@arkaria.postgresql.org; Thu, 10 Dec 2015 22:49:39 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1a7A1F-0005HG-Jq for pgsql-bugs@postgresql.org; Thu, 10 Dec 2015 22:49:01 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1a7A1C-0004Ea-AL for pgsql-bugs@postgresql.org; Thu, 10 Dec 2015 22:49:01 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id tBAMmhwu022200; Thu, 10 Dec 2015 17:48:43 -0500 From: Tom Lane To: "David G. Johnston" cc: darin@darinhoward.com, "pgsql-bugs@postgresql.org" Subject: Re: BUG #13812: 'now' acting differently than now() in function In-reply-to: References: <20151210195222.2683.3870@wrigleys.postgresql.org> Comments: In-reply-to "David G. Johnston" message dated "Thu, 10 Dec 2015 14:18:55 -0700" Date: Thu, 10 Dec 2015 17:48:43 -0500 Message-ID: <22199.1449787723@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org "David G. Johnston" writes: > On Thu, Dec 10, 2015 at 12:52 PM, 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 -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs