Re: Clarification on when _PG_init() is invoked for extensions - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Clarification on when _PG_init() is invoked for extensions
Date
Msg-id 2076422.1763675893@sss.pgh.pa.us
Whole thread Raw
In response to Re: Clarification on when _PG_init() is invoked for extensions  (Ayush Vatsa <ayushvatsa1810@gmail.com>)
List pgsql-hackers
Ayush Vatsa <ayushvatsa1810@gmail.com> writes:
> My use case is that I’m building an experimental extension that will be
> installed only in a few
> databases. I want the hooks initialized by this extension to apply only to
> those specific
> databases, while all other databases should continue with the default
> PostgreSQL behavior.

If you don't name the extension in shared_preload_libraries, it
will not be loaded into the postmaster, but only into individual
sessions.  The ways the latter can happen are

* session_preload_libraries or local_preload_libraries GUC
* explicit LOAD command
* creation of a C function that references that library
* calling of a C function that references that library

Extensions per se don't have anything to do with this,
except to the extent that an extension's creation script
might do some of the above actions.

You might be able to get what you want by doing

ALTER DATABASE db SET session_preload_libraries = 'your-library'

for each DB you want it to be active in.  If it exposes any SQL
objects you'd also need to issue CREATE EXTENSION in each DB.

            regards, tom lane



pgsql-hackers by date:

Previous
From: Jacob Champion
Date:
Subject: Re: RFC 9266: Channel Bindings for TLS 1.3 support
Next
From: Jacob Champion
Date:
Subject: Re: RFC 9266: Channel Bindings for TLS 1.3 support