Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb998ce3

Browse files
Allow resetting unknown custom GUCs with reserved prefixes.
Currently, ALTER DATABASE/ROLE/SYSTEM RESET [ALL] with an unknowncustom GUC with a prefix reserved by MarkGUCPrefixReserved() errors(unless a superuser runs a RESET ALL variant). This is problematicfor cases such as an extension library upgrade that removes a GUC.To fix, simply make sure the relevant code paths explicitly allowit. Note that we require superuser or privileges on the parameterto reset it. This is perhaps a bit more restrictive than isnecessary, but it's not clear whether further relaxing therequirements is safe.Oversight in commit8810356. The ALTER SYSTEM fix is dependenton commit2d870b4, which first appeared in v17. Unfortunately,back-patching that commit would introduce ABI breakage, and whilethat breakage seems unlikely to bother anyone, it doesn't seemworth the risk. Hence, the ALTER SYSTEM part of this commit isomitted 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.orgBackpatch-through: 15
1 parentadfd802 commitb998ce3

File tree

5 files changed

+54
-4
lines changed

5 files changed

+54
-4
lines changed

‎contrib/auto_explain/Makefile‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ OBJS = \
66
auto_explain.o
77
PGFILEDESC = "auto_explain - logging facility for execution plans"
88

9+
REGRESS = alter_reset
10+
911
TAP_TESTS = 1
1012

1113
ifdefUSE_PGXS
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--
2+
-- This tests resetting unknown custom GUCs with reserved prefixes. There's
3+
-- nothing specific to auto_explain; this is just a convenient place to put
4+
-- this test.
5+
--
6+
SELECT current_database() AS datname \gset
7+
CREATE ROLE regress_ae_role;
8+
ALTER DATABASE :"datname" SET auto_explain.bogus = 1;
9+
ALTER ROLE regress_ae_role SET auto_explain.bogus = 1;
10+
ALTER ROLE regress_ae_role IN DATABASE :"datname" SET auto_explain.bogus = 1;
11+
LOAD 'auto_explain';
12+
WARNING: invalid configuration parameter name "auto_explain.bogus", removing it
13+
DETAIL: "auto_explain" is now a reserved prefix.
14+
ALTER DATABASE :"datname" RESET auto_explain.bogus;
15+
ALTER ROLE regress_ae_role RESET auto_explain.bogus;
16+
ALTER ROLE regress_ae_role IN DATABASE :"datname" RESET auto_explain.bogus;
17+
DROP ROLE regress_ae_role;

‎contrib/auto_explain/meson.build‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ tests += {
2020
'name':'auto_explain',
2121
'sd':meson.current_source_dir(),
2222
'bd':meson.current_build_dir(),
23+
'regress': {
24+
'sql': [
25+
'alter_reset',
26+
],
27+
},
2328
'tap': {
2429
'tests': [
2530
't/001_auto_explain.pl',
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--
2+
-- This tests resetting unknown custom GUCs with reserved prefixes. There's
3+
-- nothing specific to auto_explain; this is just a convenient place to put
4+
-- this test.
5+
--
6+
7+
SELECT current_database()AS datname \gset
8+
CREATE ROLE regress_ae_role;
9+
10+
ALTERDATABASE :"datname"SETauto_explain.bogus=1;
11+
ALTER ROLE regress_ae_roleSETauto_explain.bogus=1;
12+
ALTER ROLE regress_ae_roleIN DATABASE :"datname"SETauto_explain.bogus=1;
13+
14+
LOAD'auto_explain';
15+
16+
ALTERDATABASE :"datname" RESETauto_explain.bogus;
17+
ALTER ROLE regress_ae_role RESETauto_explain.bogus;
18+
ALTER ROLE regress_ae_roleIN DATABASE :"datname" RESETauto_explain.bogus;
19+
20+
DROP ROLE regress_ae_role;

‎src/backend/utils/misc/guc.c‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6561,6 +6561,7 @@ validate_option_array_item(const char *name, const char *value,
65616561

65626562
{
65636563
structconfig_generic*gconf;
6564+
boolreset_custom;
65646565

65656566
/*
65666567
* There are three cases to consider:
@@ -6579,16 +6580,21 @@ validate_option_array_item(const char *name, const char *value,
65796580
* it's assumed to be fully validated.)
65806581
*
65816582
* name is not known and can't be created as a placeholder. Throw error,
6582-
* unless skipIfNoPermissions is true, in which case return false.
6583+
* unless skipIfNoPermissions or reset_custom is true. If reset_custom is
6584+
* true, this is a RESET or RESET ALL operation for an unknown custom GUC
6585+
* with a reserved prefix, in which case we want to fall through to the
6586+
* placeholder case described in the preceding paragraph (else there'd be
6587+
* no way for users to remove them). Otherwise, return false.
65836588
*/
6584-
gconf=find_option(name, true,skipIfNoPermissions,ERROR);
6585-
if (!gconf)
6589+
reset_custom= (!value&&valid_custom_variable_name(name));
6590+
gconf=find_option(name, true,skipIfNoPermissions||reset_custom,ERROR);
6591+
if (!gconf&& !reset_custom)
65866592
{
65876593
/* not known, failed to make a placeholder */
65886594
return false;
65896595
}
65906596

6591-
if (gconf->flags&GUC_CUSTOM_PLACEHOLDER)
6597+
if (!gconf||gconf->flags&GUC_CUSTOM_PLACEHOLDER)
65926598
{
65936599
/*
65946600
* We cannot do any meaningful check on the value, so only permissions

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp