Re: strange stable function behavior

Поиск
Список
Период
Сортировка
От Dan Black
Тема Re: strange stable function behavior
Дата
Msg-id 27f606250606010538y149c20d3u344e354d01d05daa@mail.gmail.com
обсуждение исходный текст
Ответ на Re: strange stable function behavior  (Martijn van Oosterhout <kleptog@svana.org>)
Список pgsql-general
Thank you very much. It works!!!
Where can I read about such features?

2006/6/1, Martijn van Oosterhout <kleptog@svana.org>:
On Thu, Jun 01, 2006 at 03:09:47PM +0400, Dan Black wrote:
> Hi
> I have a stable function test.test_stable

<snip>

> But if I want to display field sid twice
>
> SELECT id, sid, sid FROM
> (SELECT *, test.test_stable(id) AS sid FROM generate_series(10, 100) AS id)
> tbl
>
> I can see that function test.test_stable executes twice with identical
> parameters

Postgres makes no special effort to avoid multiple calls of the same
function. Especially since you declared it STABLE.

> Is it bug or special feature?

Not a bug nor a special feature, just the way it is. If you put OFFSET 0
in the subquery, that will stop the expansion of the subquery, thus the
function will only be called once.

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFEftscIB7bNG8LQkwRAjITAJ9csUN2V8oHtfRk280cJYTqkpopIwCfRVQ0
cToHKTMqSf4HD21f+bo3jn0=
=/z/0
-----END PGP SIGNATURE-----





--
Verba volent, scripta manent
Dan Black

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

Предыдущее
От: Rafal Pietrak
Дата:
Сообщение: Re: UTF-8 context of BYTEA datatype??
Следующее
От: "Dave Page"
Дата:
Сообщение: Re: Problem in Pg 8.1.4 with CREATEDB