Re: ERROR: functions in index expression must be marked IMMUTABLE

From: Geoff Winkless <pgsqladmin(at)geoff(dot)dj>
To: "Sven R(dot) Kunze" <srkunze(at)mail(dot)de>
Cc: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: ERROR: functions in index expression must be marked IMMUTABLE
Date: 2017-02-27 11:10:25
Message-ID: CAEzk6fcZbUzUykw-tjkBT9p=rOmqUhcH1=S_po-+twu=oT1qbA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 27 February 2017 at 10:52, Sven R. Kunze <srkunze(at)mail(dot)de> wrote:

>
> So, what can I do to parse texts to date(times) in a safe manner?
>
>
You know best the format of your data; if you know that your date field is
always in a particular style and timezone, you can write a function that
can be considered safe to set IMMUTABLE, where a more generic​ system
todate function cannot.

It might be sensible to call the function something that describes it
exactly, rather than my_to_date you could call it utc_yyyymmdd_todate or
something, just in case someone comes along later and sees an immutable
todate function and thinks they can use it for something else.

Geoff

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Thomas Güttler 2017-02-27 11:47:03 Re: via psycopg2 or pg2pg? Move rows from one database to other
Previous Message Sven R. Kunze 2017-02-27 10:52:17 Re: ERROR: functions in index expression must be marked IMMUTABLE