postgresql/src/backend/commands
Tom Lane 69d5ca484b 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
..
Makefile Split copy.c into four files. 2020-11-23 10:50:50 +02:00
aggregatecmds.c SQL-standard function body 2021-04-07 21:47:55 +02:00
alter.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
amcmds.c Fix some typos, grammar and style in docs and comments 2021-02-24 16:13:17 +09:00
analyze.c Set pg_class.reltuples for partitioned tables 2021-04-09 11:50:33 -04:00
async.c Remove server and libpq support for old FE/BE protocol version 2. 2021-03-04 10:45:55 +02:00
cluster.c Fix typos and grammar in documentation and code comments 2021-04-09 13:53:07 +09:00
collationcmds.c Fix typo in collationcmds.c 2021-04-05 11:18:12 +09:00
comment.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
constraint.c Pass down "logically unchanged index" hint. 2021-01-13 08:11:00 -08:00
conversioncmds.c Add 'noError' argument to encoding conversion functions. 2021-04-01 11:45:22 +03:00
copy.c Rename Default Roles to Predefined Roles 2021-04-01 15:32:06 -04:00
copyfrom.c Fix typos and grammar in documentation and code comments 2021-04-09 13:53:07 +09:00
copyfromparse.c Do COPY FROM encoding conversion/verification in larger chunks. 2021-04-01 12:23:40 +03:00
copyto.c Add support for more progress reporting in COPY 2021-03-09 14:21:03 +09:00
createas.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
dbcommands.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
define.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
discard.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
dropcmds.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
event_trigger.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
explain.c Make use of in-core query id added by commit 5fd9dfa5f5 2021-04-07 14:04:06 -04:00
extension.c Add mbverifystr() functions specific to each encoding. 2021-01-28 14:40:07 +02:00
foreigncmds.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
functioncmds.c SQL-standard function body 2021-04-07 21:47:55 +02:00
indexcmds.c ALTER TABLE ... DETACH PARTITION ... CONCURRENTLY 2021-03-25 18:00:28 -03:00
lockcmds.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
matview.c Enable parallelism in REFRESH MATERIALIZED VIEW. 2021-03-17 15:04:17 +13:00
opclasscmds.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
operatorcmds.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
policy.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
portalcmds.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
prepare.c Improve performance of repeated CALLs within plpgsql procedures. 2021-01-25 22:28:29 -05:00
proclang.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
publicationcmds.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
schemacmds.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
seclabel.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
sequence.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
statscmds.c Extended statistics on expressions 2021-03-27 00:01:11 +01:00
subscriptioncmds.c ALTER SUBSCRIPTION ... ADD/DROP PUBLICATION 2021-04-06 11:49:51 +02:00
tablecmds.c Avoid unnecessary table open/close in TRUNCATE command. 2021-04-12 00:05:58 +09:00
tablespace.c Prevent drop of tablespaces used by partitioned relations 2021-01-14 15:32:14 -03:00
trigger.c Postpone some stuff out of ExecInitModifyTable. 2021-04-06 15:57:11 -04:00
tsearchcmds.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
typecmds.c SQL-standard function body 2021-04-07 21:47:55 +02:00
user.c Standardize pg_authid oid_symbol values. 2021-04-10 12:01:41 -07:00
vacuum.c Add wraparound failsafe to VACUUM. 2021-04-07 12:37:45 -07:00
variable.c Fix some inappropriately-disallowed uses of ALTER ROLE/DATABASE SET. 2021-04-13 15:10:18 -04:00
view.c Update copyright for 2021 2021-01-02 13:06:25 -05:00