enable_alter_system_guc.patch
application/octet-stream
Filename: enable_alter_system_guc.patch
Type: application/octet-stream
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: unified
| File | + | − |
|---|---|---|
| src/backend/utils/misc/guc.c | 8 | 0 |
| src/backend/utils/misc/guc_tables.c | 10 | 0 |
| src/include/utils/guc_tables.h | 3 | 0 |
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index 84e7ad4d90..8aad969962 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -4463,6 +4463,14 @@ AlterSystemSetConfigFile(AlterSystemStmt *altersysstmt)
*/
name = altersysstmt->setstmt->name;
+ if (! EnableAlterSystem)
+ {
+
+ ereport(ERROR,
+ (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
+ errmsg("permission denied to run ALTER SYSTEM")));
+ }
+
switch (altersysstmt->setstmt->kind)
{
case VAR_SET_VALUE:
diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c
index bdb26e2b77..1a876a5f50 100644
--- a/src/backend/utils/misc/guc_tables.c
+++ b/src/backend/utils/misc/guc_tables.c
@@ -490,6 +490,7 @@ extern const struct config_enum_entry dynamic_shared_memory_options[];
/*
* GUC option variables that are exported from this module
*/
+bool EnableAlterSystem = true;
bool log_duration = false;
bool Debug_print_plan = false;
bool Debug_print_parse = false;
@@ -1051,6 +1052,15 @@ struct config_bool ConfigureNamesBool[] =
false,
NULL, NULL, NULL
},
+ {
+ {"enable_alter_system", PGC_POSTMASTER, UNGROUPED,
+ gettext_noop("Enable ALTER SYSTEM command"),
+ NULL
+ },
+ &EnableAlterSystem,
+ true,
+ NULL, NULL, NULL
+ },
{
{"bonjour", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
gettext_noop("Enables advertising the server via Bonjour."),
diff --git a/src/include/utils/guc_tables.h b/src/include/utils/guc_tables.h
index d5a0880678..e434b26cba 100644
--- a/src/include/utils/guc_tables.h
+++ b/src/include/utils/guc_tables.h
@@ -309,4 +309,7 @@ extern char *config_enum_get_options(struct config_enum *record,
const char *suffix,
const char *separator);
+/* GUC reference to enable/disable alter system */
+extern PGDLLIMPORT bool EnableAlterSystem;
+
#endif /* GUC_TABLES_H */