From: wcting163@163.com
To: pgsql-bugs@postgresql.org
Subject: BUG #6047: prepare p1 as select 'now'::timestamp; then "execute p1" many times, they return the same time
Date: Thu, 2 Jun 2011 02:53:01 GMT
Message-ID: <201106020253.p522r1eD076376@wwwmaster.postgresql.org> (raw)
The following bug has been logged online:
Bug reference: 6047
Logged by:
Email address: wcting163@163.com
PostgreSQL version: 9.0.4
Operating system: WinXP 32bit
Description: prepare p1 as select 'now'::timestamp; then "execute p1"
many times, they return the same time
Details:
when i execute the following statements:
prepare p1 as select 'now'::timestamp;
execute p1;
execute p1;
every time i execute statement "execute p1", they all return the same time,
the time when "prepare p1 ..." is created.
but i expect it return the changing time ---- the current time.
1). although i kown that, "the system will convert **now** to a timestamp as
soon as the constant is parsed",
i think this is a bug.
2). maybe you suggest me:
prepare p1 as select now()::timestamp;
then "execute p1" will return the current time.
this is because now() is a builtin function, so we can change "select
'now'::timestamp" to "select now()::timestamp";
but, what about "prepare p1 as select 'today'::timestamp"??
today() is not a builtin function, we can't change it to "select
today()::timestamp";
So, the implementation method of "now" and "today" is different, and
prepare p1 as select 'today'::timestamp;
execute p1;-- will always return the day when the "prepare p1 ..." is
created, even we're in another day.
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: wcting163@163.com
Subject: Re: BUG #6047: prepare p1 as select 'now'::timestamp; then "execute p1" many times, they return the same time
In-Reply-To: <201106020253.p522r1eD076376@wwwmaster.postgresql.org>
References: <201106020253.p522r1eD076376@wwwmaster.postgresql.org>
* 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