Re: const cast ? - Mailing list pgsql-sql

From Tom Lane
Subject Re: const cast ?
Date
Msg-id 1631.981185887@sss.pgh.pa.us
Whole thread Raw
In response to Re: const cast ?  (Michael Fork <mfork@toledolink.com>)
List pgsql-sql
Michael Fork <mfork@toledolink.com> writes:
> You can create a function with the IsCacheable attribute...
> CREATE FUNCTION my_date_part(date) RETURNS int4 AS '
>     SELECT date_part('year', $1);
> ' LANGUAGE 'sql' WITH iscachable();

The reason date_part --- and most other datetime-related functions ---
is not marked iscachable already is the existence of the special value
CURRENT in some of the datetime datatypes, which makes the result of
any datetime function potentially dependent on when you execute it.
I believe we have agreed that CURRENT is evil and should be eliminated,
but it hasn't gotten done yet.  See past discussions in the pghackers
archives.
        regards, tom lane


pgsql-sql by date:

Previous
From: Roberto Mello
Date:
Subject: Re: Four Odd Questions
Next
From: Florian Steffen
Date:
Subject: Timestamp accuracy