From: Tom Lane <tgl@sss.pgh.pa.us>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: darin@darinhoward.com, "pgsql-bugs@postgresql.org" <pgsql-bugs@postgresql.org>
Subject: Re: BUG #13812: 'now' acting differently than now() in function
Date: Thu, 10 Dec 2015 17:48:43 -0500
Message-ID: <22199.1449787723@sss.pgh.pa.us> (raw)
In-Reply-To: <CAKFQuwYBE-iZKiKP-gkzR8qEp=kdjWHO7SsgH4XHFJn6bmwAmw@mail.gmail.com>
References: <20151210195222.2683.3870@wrigleys.postgresql.org>
<CAKFQuwYBE-iZKiKP-gkzR8qEp=kdjWHO7SsgH4XHFJn6bmwAmw@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Thu, Dec 10, 2015 at 12:52 PM, <darin@darinhoward.com> 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, david.g.johnston@gmail.com
Subject: Re: BUG #13812: 'now' acting differently than now() in function
In-Reply-To: <22199.1449787723@sss.pgh.pa.us>
References: <20151210195222.2683.3870@wrigleys.postgresql.org> <CAKFQuwYBE-iZKiKP-gkzR8qEp=kdjWHO7SsgH4XHFJn6bmwAmw@mail.gmail.com> <22199.1449787723@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox