Re: Clarification on when _PG_init() is invoked for extensions
| От | Rahila Syed |
|---|---|
| Тема | Re: Clarification on when _PG_init() is invoked for extensions |
| Дата | |
| Msg-id | CAH2L28sMJHQaQCY9Fp3A95BWF8mf+cPK7aqQ_zTWRpcKYJMu+A@mail.gmail.com обсуждение исходный текст |
| Ответ на | Clarification on when _PG_init() is invoked for extensions (Ayush Vatsa <ayushvatsa1810@gmail.com>) |
| Список | pgsql-hackers |
Based on documentation and experimentation, I believe the behavior works as follows, but I would appreciate
confirmation or corrections:1/ When the extension is listed in
shared_preload_libraries:_PG_init()is executed before the server
starts accepting connections, and hooks are initialized for every backend process. The downside is that this enables
hooks globally for all databases in the instance.
memory or register a background worker.
3/ When running
CREATE EXTENSION: Here the.sois loaded lazily when a function defined withMODULE_PATHNAMEis
first executed or defined. In this model, I’m unsure whether I need to explicitly runLOAD 'extension'to ensure_PG_init()runs for other existing and upcoming backends.
It mainly runs the .sql script in your extension.
My use case:
I would like the extension to initialize hooks automatically, but only for all (existing and upcoming) backends of the specific
database where the extension is installed - not globally across all databases.
However, depending on where the hook runs, performing catalog lookups to
determine the connected database could be costly.
Could you share more details about the problem you’re trying to solve, or explain why
you want to restrict access to hooks?
Thank you,
В списке pgsql-hackers по дате отправления: