Re: [SQL] date_trunc'd timestamp index possible?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruno Wolff III <bruno(at)wolff(dot)to>
Cc: "D(dot) Duccini" <duccini(at)backpack(dot)com>, pgsql-sql(at)postgresql(dot)org, Pgsql-novice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: [SQL] date_trunc'd timestamp index possible?
Date: 2004-10-01 18:49:34
Message-ID: 13492.1096656574@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-novice pgsql-sql

Bruno Wolff III <bruno(at)wolff(dot)to> writes:
> I am not sure how to check if the supplied function for converting
> a timestamp with time zone to a timestamp without timezone using a
> specified time zone is immutable. I think this function should be
> immutable, but that it probably isn't.

Yup. In 7.4:

regression=# select provolatile from pg_proc where oid = 'timezone(text,timestamptz)'::regprocedure;
provolatile
-------------
s
(1 row)

regression=#

This is a thinko that's already been corrected for 8.0:

regression=# select provolatile from pg_proc where oid = 'timezone(text,timestamptz)'::regprocedure;
provolatile
-------------
i
(1 row)

regression=#

If you wanted you could just UPDATE pg_proc to correct this mistake.
Another possibility is to create a function that's an IMMUTABLE
wrapper around the standard function.

Looking at this, I realize that date_trunc() is mismarked: the
timestamptz variant is strongly dependent on the timezone setting
and so should be STABLE not IMMUTABLE. Ooops.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Darcy Buskermolen 2004-10-01 18:52:58 Re: AIX and V8 beta 3
Previous Message Greg Stark 2004-10-01 18:47:46 Handling of mutable functions in subqueries?

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2004-10-01 18:52:46 Re: max_connections not changing
Previous Message Bruno Wolff III 2004-10-01 18:44:37 Re: date_trunc'd timestamp index possible?

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2004-10-01 21:17:28 Re: date_trunc'd timestamp index possible?
Previous Message Bruno Wolff III 2004-10-01 18:44:37 Re: date_trunc'd timestamp index possible?