Re: CAST Within EXCLUSION constraint

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: CAST Within EXCLUSION constraint
Дата
Msg-id 7838.1377017411@sss.pgh.pa.us
обсуждение исходный текст
Ответ на CAST Within EXCLUSION constraint  ("David E. Wheeler" <david@justatheory.com>)
Ответы Re: CAST Within EXCLUSION constraint
Список pgsql-hackers
"David E. Wheeler" <david@justatheory.com> writes:
> Well, maybe I can cast it? But no, changing the EXCLUDE line to
>         EXCLUDE USING gist (source::text WITH =, within WITH &&)
> Yields a syntax error:
>     try.sql:13: ERROR:  syntax error at or near "::"
>     LINE 4:     EXCLUDE USING gist (source::text WITH =, within WITH &&)
> So that's out. Why shouldn't :: be allowed?

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

> 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.
        regards, tom lane



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Christopher Browne
Дата:
Сообщение: Re: Personal note: taking some vacation time in Sep/Oct
Следующее
От: "David E. Wheeler"
Дата:
Сообщение: Re: CAST Within EXCLUSION constraint