From: | strk <strk(at)keybit(dot)net> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Cc: | Mark Cave-Ayland <m(dot)cave-ayland(at)webbased(dot)co(dot)uk> |
Subject: | IMMUTABLE bug ? |
Date: | 2005-10-26 17:19:10 |
Message-ID: | 20051026171910.GA4040@keybit.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
I cant get the IMMUTABLE modifier meaning.
The 'testme' IMMUTABLE function is invoked 3 times
in the following query:
# select testme(1), testme(1), testme(1);
NOTICE: called
NOTICE: called
NOTICE: called
testme | testme | testme
--------+--------+--------
ret | ret | ret
(1 row)
Why is so ? shouldn't the IMMUTABLE keywork make
it a single call ?
From the 8.0 manual :
IMMUTABLE indicates that the function always returns the same result
when given the same argument values; that is, it does not do database
lookups or otherwise use information not directly present in its
argument list. If this option is given, any call of the function
with all-constant arguments can be immediately replaced with the
function value.
The function definition:
CREATE OR REPLACE FUNCTION testme(integer) RETURNS text AS
' BEGIN
RAISE NOTICE ''called'';
return ''ret''::text;
END ' LANGUAGE 'plpgsql' IMMUTABLE STRICT;
PostgreSQL version 8.0.0
--strk;
From | Date | Subject | |
---|---|---|---|
Next Message | Alon Goldshuv | 2005-10-26 17:20:41 | Libpq optimization |
Previous Message | Grzegorz Piotr Jaskiewicz | 2005-10-26 16:57:26 | Re: problem with custom Gist for custom type |