Stateful C-language function with state managed by third-party library

Поиск
Список
Период
Сортировка
От Denys Rtveliashvili
Тема Stateful C-language function with state managed by third-party library
Дата
Msg-id f9317916-e6b6-4e28-b569-9a863f9cd425@me.com
обсуждение исходный текст
Ответы Re: Stateful C-language function with state managed by third-party library  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Hello,

My function neeeds to call a third-party library which would create a state and then that state should be kept for the duration of the current query. The library can deallocate that state in a correct way.

I understand that fn_extra is normally used for this and usually the state is created in a memory context which is deallocated at the end of the query. So normally it is not an issue. However, I cannot make that library use PostgreSQL utilities for memory management.

I am afraid that for long-running sessions it may cause serious memory leaks if they do not deallocate state correctly and in a timely manner.

Is there a mechanism for adding a finalizer hook which would be called and passed that pointer after the query is complete? Or perhaps there is another mechanism? I looked in the documentation and in the source but I do not see it mentioned.

Thank you.

With kind regards,
Denys Rtveliashvili

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

Предыдущее
От: "Jeff"
Дата:
Сообщение: about our photo clipping path
Следующее
От: Tom Lane
Дата:
Сообщение: Re: proposal: disallow operator "=>" and use it for named parameters