Re: Unclear documentation (IMMUTABLE functions)

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Unclear documentation (IMMUTABLE functions)
Дата
Msg-id 15434.1062774348@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Unclear documentation (IMMUTABLE functions)  (Daniel Schreiber <daniel.schreiber@s1999.tu-chemnitz.de>)
Ответы Re: Unclear documentation (IMMUTABLE functions)  (Daniel Schreiber <daniel.schreiber@s1999.tu-chemnitz.de>)
Список pgsql-bugs
Daniel Schreiber <daniel.schreiber@s1999.tu-chemnitz.de> writes:
> A question on IMMUTABLE functions: do they only have to return the same value
> during a session/connection or during the databse server's lifetime?

Lifetime, I'd say, since among other things IMMUTABLE is considered to
mean that it's okay to build an index on the function's results.

Of course, you can cheat: the system makes no attempt to verify whether
a function that you say is IMMUTABLE really is.  There are cases where
it's useful to lie about the mutability property of a function.  What
you are basically controlling here is whether the planner will deem it
safe to pre-evaluate a call of the function.  Unless you actually do
build a functional index using a function, I doubt it could matter
whether the results change from one session to the next.

> I wrote a function that uses the CURRENT_USER session variable, and for my
> current usage it is very important, that it returns a different value for
> each database connection.

CURRENT_USER is marked STABLE, not IMMUTABLE.  Not sure what your point
is here.

            regards, tom lane

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

Предыдущее
От: Stephan Szabo
Дата:
Сообщение: Re: Unclear documentation (IMMUTABLE functions)
Следующее
От: Daniel Schreiber
Дата:
Сообщение: Re: Unclear documentation (IMMUTABLE functions)