Received: from sss.pgh.pa.us (sss.pgh.pa.us [209.114.132.154]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f137cdq71666 for ; Sat, 3 Feb 2001 02:38:40 -0500 (EST) (envelope-from tgl@sss.pgh.pa.us) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.11.1/8.11.1) with ESMTP id f137c7901634; Sat, 3 Feb 2001 02:38:07 -0500 (EST) To: Michael Fork cc: doj@wwws2.redaex.de, PostgreSQL-SQL Subject: Re: const cast ? In-reply-to: References: Comments: In-reply-to Michael Fork message dated "Fri, 02 Feb 2001 15:48:15 -0500" Date: Sat, 03 Feb 2001 02:38:07 -0500 Message-ID: <1631.981185887@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200102/18 X-Sequence-Number: 1186 Michael Fork 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