X-Original-To: pgsql-novice-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6D3F232A1BF for ; Fri, 1 Oct 2004 22:17:38 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 60074-08 for ; Fri, 1 Oct 2004 21:17:29 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id E3B4332A1A2 for ; Fri, 1 Oct 2004 22:17:30 +0100 (BST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id i91LHS9Q015054; Fri, 1 Oct 2004 17:17:28 -0400 (EDT) To: "D. Duccini" Cc: Bruno Wolff III , pgsql-sql@postgresql.org, Pgsql-novice Subject: Re: date_trunc'd timestamp index possible? In-reply-to: References: Comments: In-reply-to "D. Duccini" message dated "Fri, 01 Oct 2004 13:28:47 -0500" Date: Fri, 01 Oct 2004 17:17:28 -0400 Message-ID: <15053.1096665448@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200410/13 X-Sequence-Number: 11098 "D. Duccini" writes: > I think we found a way around it! > CREATE OR REPLACE FUNCTION date_immutable( timestamptz ) RETURNS date AS > 'SELECT date( $1 ) ;' LANGUAGE 'sql' IMMUTABLE ; No, you just found a way to corrupt your index. Pretending that date(timestamptz) is immutable does not make it so. The above *will* break the first time someone uses the table with a different timezone setting. What you can do safely is date(footime AT TIME ZONE 'something'), since this nails down the zone in which the date is interpreted. regards, tom lane