pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Greg Stark <gsstark@mit.edu>
Cc: Louis-David Mitterrand <vindex+lists-pgsql-sql@apartia.org>
Cc: pgsql-sql@postgresql.org
Subject: Re: Does IMMUTABLE property propagate?
Date: Thu, 25 Mar 2010 12:55:54 -0400
Message-ID: <20124.1269536154@sss.pgh.pa.us> (raw)
In-Reply-To: <407d949e1003250905m323c6959wd07b0d7310cd271c@mail.gmail.com>
References: <4B91C184.4090906@venaver.info>
	<407d949e1003060645i408e0648te67dfd722172f76a@mail.gmail.com>
	<4B927FED.60209@venaver.info>
	<4150.1267911115@sss.pgh.pa.us>
	<20100325061616.GA4629@apartia.fr>
	<162867791003250027q3cfc5ba9g59d56768aa4c4e5e@mail.gmail.com>
	<20100325075405.GA17176@apartia.fr>
	<16800.1269527726@sss.pgh.pa.us>
	<407d949e1003250905m323c6959wd07b0d7310cd271c@mail.gmail.com>

Greg Stark <gsstark@mit.edu> writes:
> On Thu, Mar 25, 2010 at 2:35 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> When you're intending to have a SQL function be inlined, it's probably
>> best not to mark it as either IMMUTABLE or STRICT --- that doesn't buy
>> anything and it can complicate matters as to whether inlining is legal.

> I'm confused, I thought it was volatile and strict that prevented inlining.

No: we won't inline if the contained expression is more volatile than
what the function is marked as being.  This is a hack that prevents the
inlining logic from defeating kluges that people might be using in
certain applications, namely putting "immutable" or "stable" wrapper
functions around functions that are more volatile than that in the eyes
of the system.  You can do that to force the planner to treat things as
immutable/stable in certain contexts; but of course the trick wouldn't
work if the inliner opens up the function and exposes its true contents.
But in the other direction, exposing a definition that is less volatile
than the function's declaration cannot break anything.

Similarly, a STRICT marking prevents inlining unless the planner can
prove that the contained expression would act the same as the function
declaration w.r.t. returning null for any null input; and in all but
the simplest cases it can't prove that.

			regards, tom lane



view thread (12+ messages)

Message-ID: <20124.1269536154@sss.pgh.pa.us>
Permalink:  ../20124.1269536154@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/20124.1269536154@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, gsstark@mit.edu, vindex+lists-pgsql-sql@apartia.org
  Subject: Re: Does IMMUTABLE property propagate?
  In-Reply-To: <20124.1269536154@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox