Recently I've discovered that if there are multiple values of the same
parameter in postgresql.conf PostgreSQL will silently use the last one.
It looks like not the best approach to me. For instance, user can find
the first value in the config file and expect that it will be used, etc.

I suggest to warn users about duplicated parameters. Here is a
corresponding patch.


Best regards,
Aleksander Alekseev
diff --git a/src/backend/utils/misc/guc-file.l b/src/backend/utils/misc/guc-file.l
index f01b814..6aa60a4 100644
--- a/src/backend/utils/misc/guc-file.l
+++ b/src/backend/utils/misc/guc-file.l
@@ -304,6 +304,13 @@ ProcessConfigFileInternal(GucContext context, bool applySettings, int elevel)
 			/* Now mark it as present in file */
 			record->status |= GUC_IS_IN_FILE;
+			/* Warn the user about duplicate configuration parameter */
+			ereport(elevel,
+				errmsg("duplicate configuration parameter \"%s\" overrides previous value in file \"%s\" line %u",
+						item->name,
+						item->filename, item->sourceline)));
 		else if (strchr(item->name, GUC_QUALIFIER_SEPARATOR) == NULL)

Attachment: pgp126mUyo0K4.pgp
Description: OpenPGP digital signature

Reply via email to