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

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Geoff Winkless <pgsqladmin(at)geoff(dot)dj>
Cc: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>, "Sven R(dot) Kunze" <srkunze(at)mail(dot)de>, Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: ERROR: functions in index expression must be marked IMMUTABLE
Date: 2017-02-28 16:50:19
Message-ID: CAKFQuwZ4DHu9zcdDkrPx-v2_=JCD0vbD-NbvRyORikQEH5VV9w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Feb 28, 2017 at 9:35 AM, Geoff Winkless <pgsqladmin(at)geoff(dot)dj> wrote:

> On 28 February 2017 at 15:59, Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
> wrote:
>
>> On 02/28/2017 07:30 AM, Sven R. Kunze wrote:
>>
>>> On 28.02.2017 15:40, Adrian Klaver wrote:
>>>
>>>> [explanation of why date casting and to_datetime don't work]
>>>>
>>>
>>> Why is to_date not immutable?
>>>
>>
>> Not sure, but if I where to hazard a guess, from the source code in
>> formatting.c:
>>
>> https://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f
>> =src/backend/utils/adt/formatting.c;h=e552c8d20b61a082049068
>> d2f8d776e35fef1179;hb=HEAD
>>
>> ​Would the fact that you can have month names in to_date strings make it
> dependent on current locale?
>
>
​That would seem to be it.

cache_locale_time() at the top of DCH_to_char which is in the call stack of
the shared parsing code for both to_date and to_timestamp.


https://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/backend/utils/adt/formatting.c;h=e552c8d20b61a082049068d2f8d776e35fef1179;hb=HEAD#l2363

Supposedly one could provide a version of to_date that accepts a locale in
which to interpret names in the input data - or extend the format string
with some kind of "{locale=en_US}" syntax to avoid changing the function
signature.

David J.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ivan Voras 2017-02-28 16:50:53 Making a unique constraint deferrable?
Previous Message Geoff Winkless 2017-02-28 16:35:56 Re: ERROR: functions in index expression must be marked IMMUTABLE