postgresql/src/backend/utils
Tom Lane 46b6635b77 Fix some inappropriately-disallowed uses of ALTER ROLE/DATABASE SET.
Most GUC check hooks that inspect database state have special checks
that prevent them from throwing hard errors for state-dependent issues
when source == PGC_S_TEST.  This allows, for example,
"ALTER DATABASE d SET default_text_search_config = foo" when the "foo"
configuration hasn't been created yet.  Without this, we have problems
during dump/reload or pg_upgrade, because pg_dump has no idea about
possible dependencies of GUC values and can't ensure a safe restore
ordering.

However, check_role() and check_session_authorization() hadn't gotten
the memo about that, and would throw hard errors anyway.  It's not
entirely clear what is the use-case for "ALTER ROLE x SET role = y",
but we've now heard two independent complaints about that bollixing
an upgrade, so apparently some people are doing it.

Hence, fix these two functions to act more like other check hooks
with similar needs.  (But I did not change their insistence on
being inside a transaction, as it's still not apparent that setting
either GUC from the configuration file would be wise.)

Also fix check_temp_buffers, which had a different form of the disease
of making state-dependent checks without any exception for PGC_S_TEST.
A cursory survey of other GUC check hooks did not find any more issues
of this ilk.  (There are a lot of interdependencies among
PGC_POSTMASTER and PGC_SIGHUP GUCs, which may be a bad idea, but
they're not relevant to the immediate concern because they can't be
set via ALTER ROLE/DATABASE.)

Per reports from Charlie Hornsby and Nathan Bossart.  Back-patch
to all supported branches.

Discussion: https://postgr.es/m/HE1P189MB0523B31598B0C772C908088DB7709@HE1P189MB0523.EURP189.PROD.OUTLOOK.COM
Discussion: https://postgr.es/m/20160711223641.1426.86096@wrigleys.postgresql.org
2021-04-13 15:10:18 -04:00
..
adt Fix out-of-bound memory access for interval -> char conversion 2021-04-12 11:31:40 +09:00
cache Don't leak rd_statlist when a relcache entry is dropped. 2021-03-18 20:37:09 -04:00
error Disallow setting client_min_messages higher than ERROR. 2018-11-08 17:33:46 -05:00
fmgr Fix broken ruleutils support for function TRANSFORM clauses. 2021-01-25 13:03:11 -05:00
hash Remove broken and useless entry-count printing in HASH_DEBUG code. 2017-08-02 12:17:08 -04:00
init Fix postmaster's behavior during smart shutdown. 2020-08-14 13:26:57 -04:00
mb Avoid unnecessary out-of-memory errors during encoding conversion. 2019-10-03 17:34:26 -04:00
misc Fix some inappropriately-disallowed uses of ALTER ROLE/DATABASE SET. 2021-04-13 15:10:18 -04:00
mmgr Adjust DSM and DSA slot usage constants (back-patch). 2020-11-20 10:53:08 +13:00
resowner Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
sort Backpatch tuplesort.c assertion. 2020-07-29 16:00:52 -07:00
time Fix misc typos, mostly in comments. 2018-07-18 16:18:27 +03:00
.gitignore Generate fmgr prototypes automatically 2017-01-17 14:06:07 -05:00
errcodes.txt Revert to 9.6 treatment of ALTER TYPE enumtype ADD VALUE. 2017-09-27 16:14:37 -04:00
Gen_dummy_probes.pl Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
Gen_dummy_probes.sed Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
Gen_fmgrtab.pl Post-PG 10 beta1 pgperltidy run 2017-05-17 19:01:23 -04:00
generate-errcodes.pl Clean up Perl code according to perlcritic 2017-03-27 08:18:22 -04:00
Makefile Fix make rules that generate multiple output files. 2018-03-23 13:45:38 -04:00
probes.d Rename dtrace probes for ongoing xlog -> wal conversion. 2017-02-09 16:40:19 -05:00