Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id C04D8632517 for ; Thu, 25 Mar 2010 04:27:39 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 44738-01 for ; Thu, 25 Mar 2010 07:27:29 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-ww0-f46.google.com (mail-ww0-f46.google.com [74.125.82.46]) by mail.postgresql.org (Postfix) with ESMTP id 1DF5663254F for ; Thu, 25 Mar 2010 04:27:28 -0300 (ADT) Received: by wwe15 with SMTP id 15so5677948wwe.19 for ; Thu, 25 Mar 2010 00:27:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=lixlqKkaK8SAGiQFXvgp3yLDsbm2IlBI38zWxKLDG/w=; b=DzsW32p1RgS3I8tTJMoDIy6/bN7eyvGLryboHJyMPODA7sGmYUmdaSF3cet4sX5g6S v9QmAIujKNk/0x4f6rLAhCS5IdGea+moFs46fyqzxVu7AnWlZNn48cD8Md29SSH9FoUa uM8cOBW2BOwHvFHMSA7wNvQlzKAE/Vkmz+Fwg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=PVvaY3HLMWqHaE9pveWp416yLJFU4EDMTjaq2lPavttjOHaAxxRtUNy0CvHGiBI5RO U5ohhKx5xbHZd2UueKyrQYSLbbsv4QAaX5C5JIYLcRCZZOlTSGQzhLp5H0GyQFPR5Sqo OiPwpMj2v+mrTnStLUVZnd24sIOyqrLOkiHLQ= MIME-Version: 1.0 Received: by 10.216.162.3 with SMTP id x3mr490635wek.21.1269502047468; Thu, 25 Mar 2010 00:27:27 -0700 (PDT) In-Reply-To: <20100325061616.GA4629@apartia.fr> References: <4B91C184.4090906@venaver.info> <407d949e1003060645i408e0648te67dfd722172f76a@mail.gmail.com> <4B927FED.60209@venaver.info> <4150.1267911115@sss.pgh.pa.us> <20100325061616.GA4629@apartia.fr> Date: Thu, 25 Mar 2010 08:27:27 +0100 Message-ID: <162867791003250027q3cfc5ba9g59d56768aa4c4e5e@mail.gmail.com> Subject: Re: Does IMMUTABLE property propagate? From: Pavel Stehule To: pgsql-sql@postgresql.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 201003/180 X-Sequence-Number: 33887 2010/3/25 Louis-David Mitterrand : > On Sat, Mar 06, 2010 at 04:31:55PM -0500, Tom Lane wrote: >> Petru Ghita 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: > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0CREATE OR REPLACE FUNCTION shorten_cruise_type= (intext text) RETURNS text > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0AS $$ > =C2=A0 =C2=A0 =C2=A0 =C2=A0declare > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0outtext text; > =C2=A0 =C2=A0 =C2=A0 =C2=A0begin > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0outtext =3D trim(r= egexp_replace(intext, E'\\s*Short( Break)?', '', 'i')); > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return outtext; > =C2=A0 =C2=A0 =C2=A0 =C2=A0end; > =C2=A0 =C2=A0 =C2=A0 =C2=A0$$ > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0LANGUAGE 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@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-sql >