How to syntax check PostgreSQL config files?

SamK picture SamK · May 2, 2013 · Viewed 18.4k times · Source

I am often editing the pg_hda.conf file and I was just wondering if there is a way to make sure that what I just wrote is correct.

So far I'm using a test server to check my changes.

Like Apache has its apache2ctl -t command, does Postgres has something similar?

Answer

Peter Eisentraut picture Peter Eisentraut · May 2, 2013

There is no way to do this that is similar to apache2ctl. If you reload the configuration files and there is a syntax error, the PostgreSQL server will complain in the log and refuse to load the new file. So there is very little risk of messing something up by making a syntax typo. (Of course, this won't guard you against writing semantically wrong things, but apache2ctl won't do that either.) Other than that, it is probably a good idea to test changes in a test server, and have a system that propagates those changes to production in a controlled way.