Re: BUG #13938: CAST error on Index "function must be immutable"

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: kurt(at)kwnet(dot)at
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #13938: CAST error on Index "function must be immutable"
Date: 2016-02-09 17:15:54
Message-ID: 14233.1455038154@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

kurt(at)kwnet(dot)at writes:
> CREATE TABLE ud_data (
> val TEXT,
> );

> CREATE INDEX ud_data_FLOAT ON ud_data(CAST(val AS FLOAT)) WHERE i_type=3;
> --accepted as valid.

> CREATE INDEX ud_data_TIME ON ud_data(CAST(val AS INTERVAL)) WHERE
> i_type=10;
> --results in error "functions in index expression must be marked IMMUTABLE"

This is not a bug. The cast from text to interval isn't immutable because
its results may vary depending on the IntervalStyle setting.

> --the same error when casting to TIMESTAMP (with or without time zone)

Same, although it's DateStyle and/or TimeZone that affect this.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Xtra Coder 2016-02-09 18:42:15 Re: BUG #13937: 'src' -> jsonb_each() -> jsonb_object() -> 'dst' does not recreate 'src' as valid jsonb
Previous Message David G. Johnston 2016-02-09 16:14:24 Re: BUG #13934: wrong result of split_part with char value