Re: Does IMMUTABLE have any effect on functions?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Thomas Schoen <t(dot)schoen(at)vitrado(dot)de>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Does IMMUTABLE have any effect on functions?
Date: 2005-03-03 15:25:01
Message-ID: 21294.1109863501@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thomas Schoen <t(dot)schoen(at)vitrado(dot)de> writes:
> In my expectations the 2nd function call should not have added a new row
> to table "foo", beacause it was called with the same parameter and is
> immutable.

IMMUTABLE is a promise from you to the database (a promise which you
broke, in this case) ... not vice versa. There is no commitment to
avoid duplicate evaluations in all cases, and certainly not to do so
across multiple queries.

BTW, PG 8.0 will flat out reject this function, because it is violating
the requirement that immutable functions not have side-effects.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Terry Lee Tucker 2005-03-03 16:07:46 Re: Disabling triggers in a transaction
Previous Message Tom Lane 2005-03-03 15:17:15 Re: [Auth] "ident" method and LDAP user accounts