Re: Does IMMUTABLE have any effect on functions? - Mailing list pgsql-general

From Tom Lane
Subject Re: Does IMMUTABLE have any effect on functions?
Date
Msg-id 21294.1109863501@sss.pgh.pa.us
Whole thread Raw
In response to Does IMMUTABLE have any effect on functions?  (Thomas Schoen <t.schoen@vitrado.de>)
List pgsql-general
Thomas Schoen <t.schoen@vitrado.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

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: [Auth] "ident" method and LDAP user accounts
Next
From: Terry Lee Tucker
Date:
Subject: Re: Disabling triggers in a transaction