pg_reload_conf()
pg_reload_conf()
is a system function which instructs PostgreSQL to reload its configuration by sending a SIGHUP
signal.
pg_reload_conf()
was added in PostgreSQL 8.1.
Usage
pg_reload_conf() → boolean
Note that the boolean value returned by pg_reload_conf()
merely indicates whether PostgreSQL could be successfully signalled, not whether the configuration was successfully reloaded.
Query the pg_file_settings
and pg_hba_file_rules
views to check for possible errors in the postgresql.conf
and pg_hba.conf
files respectively.
Alternatives
PostgreSQL can also be instructed to reload its configuration by one of the following methods:
- directly sending a
SIGHUP
signal to the postmaster process - executing
pg_ctl reload
A full restart of the PostgreSQL instance will of course also cause the new configuration to be read.
Change history
- PostgreSQL 8.1
- added (commit b609695b)
Examples
Basic usage example for pg_reload_conf()
:
postgres=# SELECT pg_reload_conf(); pg_reload_conf ---------------- t (1 row)
Executing pg_reload_conf()
with an invalid configuration item:
postgres=# SELECT * FROM pg_file_settings WHERE applied IS FALSE; sourcefile | sourceline | seqno | name | setting | applied | error --------------------------------+------------+-------+------+---------+---------+------------------------------ /var/lib/pgsql/postgresql.conf | 3 | 22 | port | foo | f | setting could not be applied (1 row) postgres=# SELECT pg_reload_conf(); pg_reload_conf ---------------- t (1 row)
In this case, error messages like the following will be visible in the PostgreSQL log file:
[2021-04-14 09:02:13 UTC] LOG: 00000: received SIGHUP, reloading configuration files [2021-04-14 09:02:13 UTC] LOG: 22023: invalid value for parameter "port": "foo" [2021-04-14 09:02:13 UTC] LOG: F0000: configuration file "/var/lib/pgsql/postgresql.conf" contains errors; unaffected changes were applied
References
- PostgreSQL documentation: Server Signaling Functions