Re: Immutable way to cast timestamp TEXT to DATE? (for index)

From: Ken Tanzer <ken(dot)tanzer(at)gmail(dot)com>
To: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
Cc: PG-General Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Re: Immutable way to cast timestamp TEXT to DATE? (for index)
Date: 2019-01-04 22:37:55
Message-ID: CAD3a31W0naEvCV8b3r+wbfO6sPc9Ay6rnWUVgS6dYvV4RkAE5w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Jan 4, 2019 at 2:27 PM Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
wrote:

> On 1/4/19 2:21 PM, Ken Tanzer wrote:
> >
> > I've tried various ways of getting to a date (::date, LEFT(x,10)::date,
> > etc.), but all of them throw the error "functions in index expression
> > must be marked IMMUTABLE."
>
> ?:
> '2014-10-23T00:00:00'::timestamp
>
> Can you also show the actual index expression?
>
>
Here's a few of the ones I tried:

ag_reach=> CREATE INDEX ON export_hch_encounter_history
(CAST("Service_Date" AS date));
ERROR: functions in index expression must be marked IMMUTABLE
ag_reach=> CREATE INDEX ON export_hch_encounter_history
(CAST(LEFT("Service_Date",10) AS date));
ERROR: functions in index expression must be marked IMMUTABLE
ag_reach=> CREATE INDEX ON export_hch_encounter_history
(CAST("Service_Date"::timestamp AS date));
ERROR: functions in index expression must be marked IMMUTABLE
ag_reach=> CREATE INDEX ON export_hch_encounter_history
(("Service_Date"::date));
ERROR: functions in index expression must be marked
IMMUTABLEag_reach=> CREATE INDEX ON export_hch_encounter_history
((LEFT("Service_Date",10)::date));
ERROR: functions in index expression must be marked IMMUTABLE

--

AGENCY Software
A Free Software data system
By and for non-profits
*http://agency-software.org/ <http://agency-software.org/>*
*https://demo.agency-software.org/client
<https://demo.agency-software.org/client>*
ken(dot)tanzer(at)agency-software(dot)org
(253) 245-3801

Subscribe to the mailing list
<agency-general-request(at)lists(dot)sourceforge(dot)net?body=subscribe> to
learn more about AGENCY or
follow the discussion.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Andrew Gierth 2019-01-04 22:54:16 Re: Immutable way to cast timestamp TEXT to DATE? (for index)
Previous Message Adrian Klaver 2019-01-04 22:27:02 Re: Immutable way to cast timestamp TEXT to DATE? (for index)