Hi all,
I'm running the followin example on Postgres 7.3.3
I notice that if I declare an immutable function like this:
CREATE OR REPLACE FUNCTION test (integer) RETURNS integer
AS '
declare
begin
raise notice ''test called'';
return $1+1;
end;'
LANGUAGE plpgsql IMMUTABLE;
and I use this function for a partial index:
create table t_a
(
a integer,
b integer
);
insert into t_a values ( 1, 0 );
insert into t_a values ( 1, 1 );
insert into t_a values ( 1, 2 );
Now creating an index on that table:
create index idxv on t_a ( b ) where test(3) = b;
NOTICE: test called
NOTICE: test called
NOTICE: test called
CREATE INDEX
the function is immutable but is executed 3 times
( one for each row).
The same if I reindex the table:
reindex table t_a;
NOTICE: test called
NOTICE: test called
NOTICE: test called
REINDEX
Regards
Gaetano Mendola