shared_preload_libraries

A server configuration parameter determining what libraries are to be loaded when PostgreSQL starts

shared_preload_libraries is a server configuration parameter determining which libraries are to be loaded when PostgreSQL starts. Any libraries which use shared memory must be loaded via this parameter.

shared_preload_libraries was added in PostgreSQL 7.4 (as  preload_libraries).

Usage

Normally shared_preload_libraries contains just the name of each library, in which case it is assumed the library is in LIBDIR/postgresql/ (where LIBDIR is the value reported by pg_config --libdir), e.g.:

shared_preload_libraries = 'auto_explain,pg_stat_statements'

Library files can also be specified as an absolute filepath, e.g.:

shared_preload_libraries = '/usr/pgsql-13/lib/pg_stat_statements/pg_stat_statements.so'

Note that the file suffix (here ".so") is optional and is usually omitted.

Change history

Source code

shared_preload_libraries is defined in src/backend/utils/misc/guc.c:

	{
		{"shared_preload_libraries", PGC_POSTMASTER, CLIENT_CONN_PRELOAD,
			gettext_noop("Lists shared libraries to preload into server."),
			NULL,
			GUC_LIST_INPUT | GUC_LIST_QUOTE | GUC_SUPERUSER_ONLY
		},
		&shared_preload_libraries_string,
		"",
		NULL, NULL, NULL
	},

and is processed via process_shared_preload_libraries() in src/backend/utils/init/miscinit.c:

/*
 * process any libraries that should be preloaded at postmaster start
 */
void
process_shared_preload_libraries(void)
{
	process_shared_preload_libraries_in_progress = true;
	load_libraries(shared_preload_libraries_string,
				   "shared_preload_libraries",
				   false);
	process_shared_preload_libraries_in_progress = false;
}

Note that the underlying parsing of the comma-separated string is handled by SplitDirectoriesString() (from src/backend/utils/adt/varlena.c), which effectively means the maximum length of values which can be provided is MAXPGPATH - 1.

Categories

Configuration, GUC configuration item

See also

local_preload_libraries, session_preload_libraries