Re: CAST Within EXCLUSION constraint - Mailing list pgsql-hackers

From David E. Wheeler
Subject Re: CAST Within EXCLUSION constraint
Date
Msg-id 6BFFDFDB-24B2-41D6-9B05-9237BE9CF271@justatheory.com
Whole thread Raw
In response to Re: CAST Within EXCLUSION constraint  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: CAST Within EXCLUSION constraint  (Alexander Korotkov <aekorotkov@gmail.com>)
List pgsql-hackers
On Aug 20, 2013, at 6:50 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

> You need more parentheses -- (source::text) would've worked.

Alas, no, same problem as for CAST():
 ERROR:  functions in index expression must be marked IMMUTABLE

>> No problem, I can use CAST(), right? So I try:
>>        EXCLUDE USING gist (CAST(source AS text) WITH =, within WITH &&)
>> Not so much:
>>    try.sql:13: ERROR:  functions in index expression must be marked IMMUTABLE
>> I guess it's because locale settings might change, and therefore change the text representation? Seems unlikely,
though.
>
> Not locale, just renaming one of the values would be enough to break that.
> Admittedly we don't provide an official way to do that ATM, but you can do
> an UPDATE on pg_enum.

Ah, right. Maybe if there was a way to get at some immutable numeric value…

Thanks,

David




pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: CAST Within EXCLUSION constraint
Next
From: Stephen Frost
Date:
Subject: Re: ALTER SYSTEM SET command to change postgresql.conf parameters (RE: Proposal for Allow postgresql.conf values to be changed via SQL [review])