Re: [GENERAL] Postgresql init and cleanup module functions

Поиск
Список
Период
Сортировка
От Yan Pas
Тема Re: [GENERAL] Postgresql init and cleanup module functions
Дата
Msg-id CADceNN6VbSCPTbp1gFp2pyOT2Dr-j2Y76TAWKn6rQWjO5jFvtA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: [GENERAL] Postgresql init and cleanup module functions  (Andres Freund <andres@anarazel.de>)
Список pgsql-general
Sorry, replied only to direct sender, duplicating to both sender and mailing list
---
MSG1:
Thanks you, that is what I was looking for!

I was testing sample module and found it's behavior odd:
1. functions have few permissions, they even were not able to create file in "/tmp" directory. At least I'm able to use pglog (ereport(LOG, (errmsg("init")));)
2. _PG_init() is called separately for each connection right before any of the module's function is called by the client, so there are many instances of the module
3. For cleaning up I've use trick with standard 'atexit' function, called inside _PG_init() and it works properly
4. Global object's constructor and destructor are called on module unload.

I thought it works like "dlopen on postgres start, dlclose on postgres shutdown". I think I should stick to background worker process which will provide some C-Postgres functions
---
MSG2:
After reading bg workers' manual it seems to me that they cannot provide postgres functions. So the only way to achieve ONE global state and postgres functions using this state is to use some IPC between background process and dynamicaly loadable module (e.g. Unix/TCP sockets)

Regards, Yan

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

Предыдущее
От: Vick Khera
Дата:
Сообщение: Re: [GENERAL] Postgres logs showing error after replication
Следующее
От: Tom Lane
Дата:
Сообщение: Re: [GENERAL] Dealing with number formats when server and client are different locales