Does IMMUTABLE have any effect on functions?

Поиск
Список
Период
Сортировка
От Thomas Schoen
Тема Does IMMUTABLE have any effect on functions?
Дата
Msg-id 42270E5D.3020607@vitrado.de
обсуждение исходный текст
Ответы Re: Does IMMUTABLE have any effect on functions?  (Martijn van Oosterhout <kleptog@svana.org>)
Re: Does IMMUTABLE have any effect on functions?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
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

В списке pgsql-general по дате отправления:

Предыдущее
От: Stephane Bortzmeyer
Дата:
Сообщение: Re: [Auth] "ident" method and LDAP user accounts
Следующее
От: Martijn van Oosterhout
Дата:
Сообщение: Re: Does IMMUTABLE have any effect on functions?