Re: Maintaining state across function calls

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Maintaining state across function calls
Дата
Msg-id 1794.1353338925@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Maintaining state across function calls  (matt@byrney.com)
Ответы Re: Maintaining state across function calls
Список pgsql-general
matt@byrney.com writes:
> The question is: what's the "best practice" way of letting a
> C/C++-language function hang onto internal state across calls?

A static variable for that is a really horrid idea.  Instead use
fcinfo->flinfo->fn_extra to point to some workspace palloc'd in the
appropriate context.  If you grep the PG sources for fn_extra you'll
find plenty of examples.

            regards, tom lane


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