mirror of
https://github.com/postgres/postgres.git
synced 2025-08-06 18:42:54 +03:00
Allow resetting unknown custom GUCs with reserved prefixes.
Currently, ALTER DATABASE/ROLE/SYSTEM RESET [ALL] with an unknown custom GUC with a prefix reserved by MarkGUCPrefixReserved() errors (unless a superuser runs a RESET ALL variant). This is problematic for cases such as an extension library upgrade that removes a GUC. To fix, simply make sure the relevant code paths explicitly allow it. Note that we require superuser or privileges on the parameter to reset it. This is perhaps a bit more restrictive than is necessary, but it's not clear whether further relaxing the requirements is safe. Oversight in commit88103567cb
. The ALTER SYSTEM fix is dependent on commit2d870b4aef
, which first appeared in v17. Unfortunately, back-patching that commit would introduce ABI breakage, and while that breakage seems unlikely to bother anyone, it doesn't seem worth the risk. Hence, the ALTER SYSTEM part of this commit is omitted on v15 and v16. Reported-by: Mert Alev <mert@futo.org> Reviewed-by: Laurenz Albe <laurenz.albe@cybertec.at> Discussion: https://postgr.es/m/18964-ba09dea8c98fccd6%40postgresql.org Backpatch-through: 15
This commit is contained in:
@@ -6,6 +6,8 @@ OBJS = \
|
||||
auto_explain.o
|
||||
PGFILEDESC = "auto_explain - logging facility for execution plans"
|
||||
|
||||
REGRESS = alter_reset
|
||||
|
||||
TAP_TESTS = 1
|
||||
|
||||
ifdef USE_PGXS
|
||||
|
17
contrib/auto_explain/expected/alter_reset.out
Normal file
17
contrib/auto_explain/expected/alter_reset.out
Normal file
@@ -0,0 +1,17 @@
|
||||
--
|
||||
-- This tests resetting unknown custom GUCs with reserved prefixes. There's
|
||||
-- nothing specific to auto_explain; this is just a convenient place to put
|
||||
-- this test.
|
||||
--
|
||||
SELECT current_database() AS datname \gset
|
||||
CREATE ROLE regress_ae_role;
|
||||
ALTER DATABASE :"datname" SET auto_explain.bogus = 1;
|
||||
ALTER ROLE regress_ae_role SET auto_explain.bogus = 1;
|
||||
ALTER ROLE regress_ae_role IN DATABASE :"datname" SET auto_explain.bogus = 1;
|
||||
LOAD 'auto_explain';
|
||||
WARNING: invalid configuration parameter name "auto_explain.bogus", removing it
|
||||
DETAIL: "auto_explain" is now a reserved prefix.
|
||||
ALTER DATABASE :"datname" RESET auto_explain.bogus;
|
||||
ALTER ROLE regress_ae_role RESET auto_explain.bogus;
|
||||
ALTER ROLE regress_ae_role IN DATABASE :"datname" RESET auto_explain.bogus;
|
||||
DROP ROLE regress_ae_role;
|
20
contrib/auto_explain/sql/alter_reset.sql
Normal file
20
contrib/auto_explain/sql/alter_reset.sql
Normal file
@@ -0,0 +1,20 @@
|
||||
--
|
||||
-- This tests resetting unknown custom GUCs with reserved prefixes. There's
|
||||
-- nothing specific to auto_explain; this is just a convenient place to put
|
||||
-- this test.
|
||||
--
|
||||
|
||||
SELECT current_database() AS datname \gset
|
||||
CREATE ROLE regress_ae_role;
|
||||
|
||||
ALTER DATABASE :"datname" SET auto_explain.bogus = 1;
|
||||
ALTER ROLE regress_ae_role SET auto_explain.bogus = 1;
|
||||
ALTER ROLE regress_ae_role IN DATABASE :"datname" SET auto_explain.bogus = 1;
|
||||
|
||||
LOAD 'auto_explain';
|
||||
|
||||
ALTER DATABASE :"datname" RESET auto_explain.bogus;
|
||||
ALTER ROLE regress_ae_role RESET auto_explain.bogus;
|
||||
ALTER ROLE regress_ae_role IN DATABASE :"datname" RESET auto_explain.bogus;
|
||||
|
||||
DROP ROLE regress_ae_role;
|
Reference in New Issue
Block a user