Michael Fork <[EMAIL PROTECTED]> 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

Reply via email to