Re: to_char not IMMUTABLE?

From: "Albe Laurenz" <all(at)adv(dot)magwien(dot)gv(dot)at>
To: "Mario Weilguni *EXTERN*" <mweilguni(at)sime(dot)com>, <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: to_char not IMMUTABLE?
Date: 2007-01-12 14:42:07
Message-ID: 52EF20B2E3209443BC37736D00C3C1380C40191E@EXADV1.host.magwien.gv.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Mario Weilguni wrote:
>
> I had a problem when upgrading a database from 8.1.4 to 8.2.1:
> Sorry, the error messages are in german.
>
> pg_restore: [archiver (db)] Error while PROCESSING TOC:
> pg_restore: [archiver (db)] Error from TOC entry 1531; 1259
> 3477393 INDEX idx_inspektionen_dat_inspektion
> pg_restore: [archiver (db)] could not execute query: FEHLER:
> Funktionen im Indexausdruck muessen als IMMUTABLE markiert sein
> Command was: CREATE INDEX idx_inspektionen_dat_inspektion
> ON inspektionen USING btree (to_char(dat_inspektion, 'yyyy'::text));
> WARNING: errors ignored on restore: 1
>
> to_char(timestamp, 'yyyy') should be constant and marked
> immutable, or am I wrong here? Or is it not marked immutable
> because of possible changes on date_format?

At some point, the configuration parameter lc_time should have
an influence on the output of to_char(timestamp, text), although
this behaviour is not yet implemented.

I guess that is why the function is STABLE ind not IMMUTABLE.

Maybe you can use date_part('YEAR', dat_inspektion)::bpchar

Yours,
Laurenz Albe

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2007-01-12 14:47:55 Re: [HACKERS] Checkpoint request failed on version 8.2.1.
Previous Message Tom Lane 2007-01-12 14:39:34 Re: to_char not IMMUTABLE?