CURRENT_DATE and CURRENT_TIME are broken

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Thomas Lockhart <lockhart(at)alumni(dot)caltech(dot)edu>, pgsql-hackers(at)postgreSQL(dot)org
Subject: CURRENT_DATE and CURRENT_TIME are broken
Date: 2001-02-23 17:51:00
Message-ID: 28692.982950660@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

... in the sense that they are reduced to constants instantly, rather
than being preserved as function calls. For example:

regression=# create table foo (f1 time default current_time);
CREATE
regression=# insert into foo default values;
INSERT 618879 1

<< wait a few seconds >>

regression=# insert into foo default values;
INSERT 618880 1
regression=# select * from foo;
f1
----------
12:41:45
12:41:45
(2 rows)

The problem appears to be that Thomas inserted new pg_proc entries on
11-Nov-2000 that create direct text-to-date and text-to-time
conversions, replacing the old indirect text-to-timestamp-to-date/time
implementation of CURRENT_DATE/TIME. Unfortunately, whereas
text-to-timestamp is marked noncachable, these new entries are not,
and so the parser decides it can fold date('now'::text) to a constant.

We have three choices:

1. Change these pg_proc entries. This does not force an initdb,
exactly, but it won't take effect without one either.

2. Change the function calls emitted by the parser for
CURRENT_DATE/TIME. This doesn't force an initdb either, but it's a
workaround whereas #1 actually fixes the real bug. (Although #2 might
appear to break stored rules in beta databases, any such rules are
already broken because they've already been reduced to constants...)

3. Ship 7.1 with broken CURRENT_DATE/TIME functionality.

I tend to favor #1, but need agreement to change it. Comments?
If we do #1, should we bump catversion.h, or leave it alone?
(I'd vote for not changing catversion, I think.)

regards, tom lane

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Lockhart 2001-02-23 17:53:23 Re: Turkish locale bug
Previous Message Thomas Lockhart 2001-02-23 17:48:45 Re: Date calculation produces wrong output with 7.02