Re: abstract: fix poor constant folding in 7.0.x, fixed in 7.1?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alfred Perlstein <bright(at)wintelcom(dot)net>
Cc: PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: abstract: fix poor constant folding in 7.0.x, fixed in 7.1?
Date: 2000-12-08 00:24:55
Message-ID: 28706.976235095@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Alfred Perlstein <bright(at)wintelcom(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2000-12-08 00:36:33 Re: CRC was: Re: beta testing version
Previous Message Alfred Perlstein 2000-12-08 00:20:09 Re: abstract: fix poor constant folding in 7.0.x, fixed in 7.1?