Re: abstract: fix poor constant folding in 7.0.x, fixed in 7.1? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: abstract: fix poor constant folding in 7.0.x, fixed in 7.1?
Date
Msg-id 28706.976235095@sss.pgh.pa.us
Whole thread Raw
In response to abstract: fix poor constant folding in 7.0.x, fixed in 7.1?  (Alfred Perlstein <bright@wintelcom.net>)
Responses Re: abstract: fix poor constant folding in 7.0.x, fixed in 7.1?  (Alfred Perlstein <bright@wintelcom.net>)
List pgsql-hackers
Alfred Perlstein <bright@wintelcom.net> writes:
> Each function should have a marker that explains whether when given
> a const input if the output might vary, that way subexpressions can
> be collapsed until an input becomes non-const.

We already have that and do that.

The reason the datetime-related routines are generally not marked
'proiscachable' is that there's this weird notion of a CURRENT time
value, which means that the result of a datetime calculation may
vary depending on when you do it, even though the inputs don't.

Note that CURRENT here does not mean translating 'now' to current
time during input conversion, it's a special-case data value inside
the system.

I proposed awhile back (see pghackers thread "Constant propagation and
similar issues" from mid-September) that we should eliminate the CURRENT
concept, so that datetime calculations can be constant-folded safely.
That, um, didn't meet with universal approval... but I still think it
would be a good idea.

In the meantime you can cheat by defining functions that you choose
to mark ISCACHABLE, as has been discussed several times in the archives.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: CRC was: Re: beta testing version
Next
From: Alfred Perlstein
Date:
Subject: Re: abstract: fix poor constant folding in 7.0.x, fixed in 7.1?