Re: Does IMMUTABLE property propagate?

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Does IMMUTABLE property propagate?
Date: 2010-03-25 07:27:27
Message-ID: 162867791003250027q3cfc5ba9g59d56768aa4c4e5e@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

2010/3/25 Louis-David Mitterrand <vindex+lists-pgsql-sql(at)apartia(dot)org>:
> On Sat, Mar 06, 2010 at 04:31:55PM -0500, Tom Lane wrote:
>> Petru Ghita <petrutz(at)venaver(dot)info> writes:
>> > "..immediately replaced with the function value" doesn't mean that the
>> > results of a previously evaluated function for the same parameters are
>> > stored and reused?
>>
>> No, it means what it says: the function is executed once and replaced
>> with a constant representing the result value.
>
> So for example a function like:
>
>
>        CREATE OR REPLACE FUNCTION shorten_cruise_type(intext text) RETURNS text
>                AS $$
>        declare
>                outtext text;
>        begin
>                outtext = trim(regexp_replace(intext, E'\\s*Short( Break)?', '', 'i'));
>                return outtext;
>        end;
>        $$
>                LANGUAGE plpgsql;
>

yes it should be declared as immutable. plpgsql function is black box
for executor, so you have to use some flag. language sql is different,
executor see inside, so there you can not do it.

Regards
Pavel Stehule

> could/should be declared immutable?
>
> Thanks,
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Louis-David Mitterrand 2010-03-25 07:54:05 Re: Does IMMUTABLE property propagate?
Previous Message Louis-David Mitterrand 2010-03-25 06:16:17 Re: Does IMMUTABLE property propagate?