]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix ALTER SYSTEM to cope with duplicate entries in postgresql.auto.conf.
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 14 Aug 2019 19:09:20 +0000 (15:09 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 14 Aug 2019 19:09:20 +0000 (15:09 -0400)
commitf8c9a08520eea2ea7f0197b878515d99861d6221
treeb2b7422d37336cdaefe5032d5ac92f10b4d56f53
parentf2bdfebb962d117c51b60dcb63de1adcc9ee0380
Fix ALTER SYSTEM to cope with duplicate entries in postgresql.auto.conf.

ALTER SYSTEM itself normally won't make duplicate entries (although
up till this patch, it was possible to confuse it by writing case
variants of a GUC's name).  However, if some external tool has appended
entries to the file, that could result in duplicate entries for a single
GUC name.  In such a situation, ALTER SYSTEM did exactly the wrong thing,
because it replaced or removed only the first matching entry, leaving
the later one(s) still there and hence still determining the active value.

This patch fixes that by making ALTER SYSTEM sweep through the file and
remove all matching entries, then (if not ALTER SYSTEM RESET) append the
new setting to the end.  This means entries will be in order of last
setting rather than first setting, but that shouldn't hurt anything.

Also, make the comparisons case-insensitive so that the right things
happen if you do, say, ALTER SYSTEM SET "TimeZone" = 'whatever'.

This has been broken since ALTER SYSTEM was invented, so back-patch
to all supported branches.

Ian Barwick, with minor mods by me

Discussion: https://postgr.es/m/aed6cc9f-98f3-2693-ac81-52bb0052307e@2ndquadrant.com
src/backend/utils/misc/guc.c