Re: Constant propagation and similar issues - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Constant propagation and similar issues
Date
Msg-id 6909.969216395@sss.pgh.pa.us
Whole thread Raw
In response to Re: Constant propagation and similar issues  (Thomas Lockhart <lockhart@alumni.caltech.edu>)
List pgsql-hackers
Thomas Lockhart <lockhart@alumni.caltech.edu> writes:
>> AFAIK hardly anyone actually uses CURRENT, and I've been thinking of
>> proposing that we eliminate it to make the world safe for constant-
>> folding timestamp operations.  (Thomas, any comments here?)

> Well, it is a feature from "the old days". Pretty neat one at that, and
> is an example of a useful feature not found in other DBs or in
> standards, but which might show up someday because they are useful.

I'm not convinced that it is useful.  What I think it is is a good way
of shooting yourself in the foot, because it's so hard to control when
'CURRENT' will be reduced to a specific time value.

I have no problem with the datetime input converters accepting the input
string 'CURRENT' and immediately replacing it with the current time.
That behavior is clearly useful and creates no semantic issues.  But
I don't think that a special data value that symbolically represents
current time is either useful or well-defined.

Just to give one example of why the concept is broken: consider an index
on a timestamp column that contains some CURRENT values.  Today the
index might look like2000-01-01 11:33:05-042000-09-17 14:39:44-04CURRENT2000-09-18 14:11:07-04
which is fine.  But twenty-four hours from now, this index will be out
of order and hence broken.  (The btree routines do not cope at all
gracefully with logically-inconsistent indexes.)

So I still recommend that we remove the special value CURRENT.  Then we
can mark the datetime-related operators constant-foldable, which will
eliminate a complaint that we can otherwise expect to hear constantly
(saw another instance today in pgsql-sql).
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: ascii to character conversion in postgres
Next
From: Oleg Bartunov
Date:
Subject: Re: broken locale in 7.0.2 without multibyte support (FreeBSD 4.1-RELEASE) ?