Commit d56b3afc authored by Tom Lane's avatar Tom Lane

Restructure error handling in reading of postgresql.conf.

This patch has two distinct purposes: to report multiple problems in
postgresql.conf rather than always bailing out after the first one,
and to change the policy for whether changes are applied when there are
unrelated errors in postgresql.conf.

Formerly the policy was to apply no changes if any errors could be
detected, but that had a significant consistency problem, because in some
cases specific values might be seen as valid by some processes but invalid
by others.  This meant that the latter processes would fail to adopt
changes in other parameters even though the former processes had done so.

The new policy is that during SIGHUP, the file is rejected as a whole
if there are any errors in the "name = value" syntax, or if any lines
attempt to set nonexistent built-in parameters, or if any lines attempt
to set custom parameters whose prefix is not listed in (the new value of)
custom_variable_classes.  These tests should always give the same results
in all processes, and provide what seems a reasonably robust defense
against loading values from badly corrupted config files.  If these tests
pass, all processes will apply all settings that they individually see as
good, ignoring (but logging) any they don't.

In addition, the postmaster does not abandon reading a configuration file
after the first syntax error, but continues to read the file and report
syntax errors (up to a maximum of 100 syntax errors per file).

The postmaster will still refuse to start up if the configuration file
contains any errors at startup time, but these changes allow multiple
errors to be detected and reported before quitting.

Alexey Klyukin, reviewed by Andy Colson and av (Alexander ?)
with some additional hacking by Tom Lane
parent 5ec6b7f1
......@@ -101,7 +101,9 @@ include 'filename'
value. Alternatively, you can send the signal to a single server
process directly. Some parameters can only be set at server start;
any changes to their entries in the configuration file will be ignored
until the server is restarted.
until the server is restarted. Invalid parameter settings in the
configuration file are likewise ignored (but logged) during
<systemitem>SIGHUP</> processing.
</para>
<para>
......
......@@ -5295,10 +5295,12 @@ readRecoveryCommandFile(void)
}
/*
* Since we're asking ParseConfigFp() to error out at FATAL, there's no
* need to check the return value.
* Since we're asking ParseConfigFp() to report errors as FATAL, there's
* no need to check the return value.
*/
ParseConfigFp(fd, RECOVERY_COMMAND_FILE, 0, FATAL, &head, &tail);
(void) ParseConfigFp(fd, RECOVERY_COMMAND_FILE, 0, FATAL, &head, &tail);
FreeFile(fd);
for (item = head; item; item = item->next)
{
......@@ -5504,7 +5506,6 @@ readRecoveryCommandFile(void)
}
FreeConfigVariables(head);
FreeFile(fd);
}
/*
......
......@@ -472,9 +472,10 @@ parse_extension_control_file(ExtensionControlFile *control,
}
/*
* Parse the file content, using GUC's file parsing code
* Parse the file content, using GUC's file parsing code. We need not
* check the return value since any errors will be thrown at ERROR level.
*/
ParseConfigFp(file, filename, 0, ERROR, &head, &tail);
(void) ParseConfigFp(file, filename, 0, ERROR, &head, &tail);
FreeFile(file);
......
This diff is collapsed.
This diff is collapsed.
......@@ -313,7 +313,7 @@ extern void ParseLongOption(const char *string, char **name, char **value);
extern bool parse_int(const char *value, int *result, int flags,
const char **hintmsg);
extern bool parse_real(const char *value, double *result);
extern bool set_config_option(const char *name, const char *value,
extern int set_config_option(const char *name, const char *value,
GucContext context, GucSource source,
GucAction action, bool changeVal);
extern char *GetConfigOptionByName(const char *name, const char **varname);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment