Hi,
i wonder if the attribute IMMUTABLE has any effect on functions. Maybe its not implemented yet?
I tried the following:
CREATE TABLE foo (bar int4);
CREATE FUNCTION foo(int4) RETURNS int4 AS ' INSERT INTO foo (bar) VALUES ($1); SELECT $1; ' LANGUAGE 'sql' IMMUTABLE;
...now without any transaction...
select * from foo(1);
foo ----- 1 (1 row)
SELECT * FROM foo;
bar ----- 1 (1 row)
select * from foo(1);
foo ----- 1 (1 row)
SELECT * FROM foo;
bar ----- 1 1 (1 row)
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.
The same happens when i try to call the function twice within a single transaction.
Maybe the "IMMUTABLE" attribute is just some sort of comment?
greets, Tom Schön
---------------------------(end of broadcast)--------------------------- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to majordomo@xxxxxxxxxxxxxx)