Re: How to manage shared library lifetime through C functions

Поиск
Список
Период
Сортировка
От Heikki Linnakangas
Тема Re: How to manage shared library lifetime through C functions
Дата
Msg-id 53DF673C.7090508@vmware.com
обсуждение исходный текст
Ответ на Re: How to manage shared library lifetime through C functions  (Seref Arikan <serefarikan@gmail.com>)
Ответы Re: How to manage shared library lifetime through C functions  (Seref Arikan <serefarikan@gmail.com>)
Список pgsql-hackers
On 08/04/2014 01:31 PM, Seref Arikan wrote:
> Thanks a lot Heikki and Albe. Exactly what I was asking for.
> Heikki: the libraries are written in languages that have their own runtime
> and their documentation insists that both init and dispose calls are
> performed when used from C. PG_init() and proc_exit sounds spot on.

You might also consider creating your own PL handler for those 
languages. Or google around if one exists already.

> Any ideas about keeping some data at session level between calls? Both
> calls of the same function and different C functions. (though temp table is
> always there as an option)

You can use a global variable in the C extension. If you need to 
allocate memory that survives across function calls, use 
"MemoryContextSwitchTo(TopMemoryContext); ... = palloc(...)". I'm sure 
you'll find examples of that in the existing extensions too.

- Heikki




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

Предыдущее
От: Shigeru Hanada
Дата:
Сообщение: Re: Optimization for updating foreign tables in Postgres FDW
Следующее
От: Etsuro Fujita
Дата:
Сообщение: Re: Optimization for updating foreign tables in Postgres FDW