Re: const cast ?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Michael Fork <mfork(at)toledolink(dot)com>
Cc: doj(at)wwws2(dot)redaex(dot)de, PostgreSQL-SQL <pgsql-sql(at)postgresql(dot)org>
Subject: Re: const cast ?
Date: 2001-02-03 07:38:07
Message-ID: 1631.981185887@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Michael Fork <mfork(at)toledolink(dot)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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message <No Name> 2001-02-03 14:50:32 Packages to Install
Previous Message Roberto Mello 2001-02-03 05:08:33 Re: Four Odd Questions