Reputation: 107
I'm writing an extension for PostgreSQL in C language. The extension is loaded by PostgreSQL when I specify its' name in shared_preload_libraries. Out of curiosity, is there a way for PG to load my extension without specifying its' name in shared_preload_libraries?
Upvotes: 1
Views: 2415
Reputation: 324771
You can load extension modules:
From shared_preload_libraries
. This loads at postmaster start time, so the extension can register shared memory, locks, hooks etc before we start forking backends.
With session_preload_libraries
. This loads after fork(), in a backend, so it can't register shmem etc.
With local_preload_libraries
. Like session_preload_libraries
, but limited to the plugins
directory and settable by normal users.
With the LOAD
statement, or implicitly by running a function that refers to a LANGUAGE c
implementation.
There's no alternative to getting the full effect of shared_preload_libraries
. The other options don't permit you to do things that require code to be run in the postmaster, like register addin LWLocks or static shared memory segments. But if you don't do those things a simple LOAD
suffices.
Upvotes: 2