Skip to content

Fix set_conffile_value comment parsing regular expression

As described in [1], a recent change to the example postgresql.conf file comments revealed an issue with the regular expression used to parse and re-use commented options in the configuration file. The issue will manifest itself when a regular comment starts with a valid option name, and that specific option is being changed.

For instance, in a fresh installation:

$ grep logging_collector /etc/postgresql/15/main/postgresql.conf
					# logging_collector to be on.
#logging_collector = off		# Enable capturing of stderr, jsonlog,
# These are only used if logging_collector is on:

then run

# pg_conftool /etc/postgresql/15/main/postgresql.conf set logging_collector on

and verify that the configuration file was changed in the wrong line:

$ grep logging_collector /etc/postgresql/15/main/postgresql.conf
logging_collector on
#logging_collector = off		# Enable capturing of stderr, jsonlog,
# These are only used if logging_collector is on:

On top of that, part of the documentation of the option before logging_collector is now missing.

The expected result after the requested change in the configure file should be:

# grep logging_collector /etc/postgresql/15/main/postgresql.conf
					# requires logging_collector to be on.
logging_collector = on		# Enable capturing of stderr and csvlog
# These are only used if logging_collector is on:

The proposed patch fixes the regular expression used to parse those comments by ensuring it matches all the contents of a given line.

[1] https://bugs.launchpad.net/ubuntu/+source/postgresql-common/+bug/2007794

Merge request reports

Loading