Re: includeifexists in configuration file
Andrew Dunstan <andrew@dunslane.net>
From: Andrew Dunstan <andrew@dunslane.net>
To: Greg Smith <greg@2ndQuadrant.com>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2011-12-16T01:16:22Z
Lists: pgsql-hackers
On 12/15/2011 06:54 AM, Greg Smith wrote: > On 12/12/2011 04:47 PM, Andrew Dunstan wrote: >> I have briefly looked at the code (but not tried to apply or build >> it), and modulo the naming issue it looks OK to me. >> Unless there is some other issue let's just get it applied. It looks >> like almost a no-brainer to me. > > It isn't very fancy, but is does something people that can fit into a > couple of use-cases. Attached update has two changes to address the > suggestions I got, which closes everything I knew about with this one: > > -It's now include_if_exists > -Files that are skipped are logged now > > So current behavior: > > $ tail -n 1 postgresql.conf > include 'missing.conf' > $ start > server starting > $ tail $PGLOG > LOG: could not open configuration file > "/home/gsmith/pgwork/data/include-exists/missing.conf": No such file > or directory > FATAL: configuration file > "/home/gsmith/pgwork/data/include-exists/postgresql.conf" contains errors > > And new behavior: > > $ vi $PGDATA/postgresql.conf > $ tail -n 1 postgresql.conf > include_if_exists 'missing.conf' > $ start > server starting > $ tail $PGLOG > LOG: skipping missing configuration file > "/home/gsmith/pgwork/data/include-exists/missing.conf" > LOG: database system was shut down at 2011-12-15 06:48:46 EST > LOG: database system is ready to accept connections Committed. I changed the elog() call to use ereport(): you're not supposed to use elog() for things we expect might well happen and cause log entries - see bottom of <http://www.postgresql.org/docs/current/static/error-message-reporting.html>. I've probably been guilty of this in the past, it's a bit too easy to forget. cheers andrew