From 5f2b574f4b0a36042e6393e6765a8429120b1918 Mon Sep 17 00:00:00 2001
From: Mark Dilger <mark.dilger@enterprisedb.com>
Date: Wed, 15 Dec 2021 07:35:00 -0800
Subject: [PATCH v6] Allow GRANT of SET and ALTER SYSTEM SET for gucs

Allow granting of privilege to set or alter system set variables
which otherwise can only be managed by superusers.  Each
(role,variable,privilege) triple is independently grantable, so a
user may be granted privilege to SET but not to ALTER SYSTEM SET on
a variable, or vice versa.  The privilege to SET a userset variable
may be granted, though doing so has no practical effect, since any
role can set userset variables anyway.  Worse, there is no way to
revoke the privilege to SET a userset variable.  To remedy that,
most core userset variables have been changed to suset, with
explicit grants to set the variable to public.
---
 contrib/pg_trgm/Makefile                      |   6 +-
 contrib/pg_trgm/pg_trgm--1.6--1.7.sql         |   8 +
 contrib/pg_trgm/pg_trgm.control               |   2 +-
 contrib/postgres_fdw/Makefile                 |   3 +-
 contrib/postgres_fdw/option.c                 |   2 +-
 .../postgres_fdw/postgres_fdw--1.1--1.2.sql   |   6 +
 contrib/postgres_fdw/postgres_fdw.control     |   2 +-
 contrib/sepgsql/hooks.c                       |   2 +-
 contrib/sepgsql/sepgsql.sql.in                |   1 +
 doc/src/sgml/catalogs.sgml                    |  75 +-
 doc/src/sgml/ddl.sgml                         |  41 +-
 doc/src/sgml/func.sgml                        |  20 +-
 doc/src/sgml/ref/grant.sgml                   |   7 +
 doc/src/sgml/ref/set.sgml                     |   5 +-
 src/backend/catalog/Makefile                  |   6 +-
 src/backend/catalog/aclchk.c                  | 254 ++++++
 src/backend/catalog/catalog.c                 |   6 +
 src/backend/catalog/dependency.c              |   6 +
 src/backend/catalog/objectaddress.c           |  46 ++
 src/backend/catalog/pg_setting_acl.c          | 122 +++
 src/backend/catalog/setting_privileges.sql    |  62 ++
 src/backend/catalog/system_views.sql          |  13 +
 src/backend/commands/alter.c                  |   1 +
 src/backend/commands/dropcmds.c               |   7 +
 src/backend/commands/event_trigger.c          |   6 +
 src/backend/commands/seclabel.c               |   1 +
 src/backend/commands/tablecmds.c              |   1 +
 src/backend/parser/gram.y                     |  99 ++-
 src/backend/utils/adt/acl.c                   | 258 ++++++
 src/backend/utils/cache/lsyscache.c           |  20 +
 src/backend/utils/cache/syscache.c            |  23 +
 src/backend/utils/misc/guc.c                  | 402 +++++----
 src/bin/initdb/initdb.c                       |   5 +
 src/bin/pg_dump/dumputils.c                   |   7 +-
 src/bin/pg_dump/pg_backup_archiver.c          |   2 +
 src/bin/pg_dump/pg_dump.c                     |   5 +-
 src/bin/pg_dump/pg_dumpall.c                  |  71 ++
 src/include/catalog/dependency.h              |   1 +
 src/include/catalog/pg_default_acl.h          |   1 +
 src/include/catalog/pg_proc.dat               |  19 +
 src/include/catalog/pg_setting_acl.h          |  63 ++
 src/include/nodes/parsenodes.h                |   5 +-
 src/include/parser/kwlist.h                   |   1 +
 src/include/utils/acl.h                       |  10 +-
 src/include/utils/guc.h                       |   2 +
 src/include/utils/lsyscache.h                 |   1 +
 src/include/utils/syscache.h                  |   2 +
 src/test/modules/test_pg_dump/t/001_base.pl   |  47 ++
 src/test/regress/expected/guc_privs.out       | 780 ++++++++++++++++++
 src/test/regress/expected/privileges.out      |  53 +-
 src/test/regress/expected/rules.out           |  13 +
 src/test/regress/expected/sanity_check.out    |   1 +
 src/test/regress/parallel_schedule            |   2 +-
 src/test/regress/sql/guc_privs.sql            | 185 +++++
 src/test/regress/sql/privileges.sql           |  44 +-
 55 files changed, 2644 insertions(+), 189 deletions(-)
 create mode 100644 contrib/pg_trgm/pg_trgm--1.6--1.7.sql
 create mode 100644 contrib/postgres_fdw/postgres_fdw--1.1--1.2.sql
 create mode 100644 src/backend/catalog/pg_setting_acl.c
 create mode 100644 src/backend/catalog/setting_privileges.sql
 create mode 100644 src/include/catalog/pg_setting_acl.h
 create mode 100644 src/test/regress/expected/guc_privs.out
 create mode 100644 src/test/regress/sql/guc_privs.sql

diff --git a/contrib/pg_trgm/Makefile b/contrib/pg_trgm/Makefile
index 1fbdc9ec1e..8fac4f6289 100644
--- a/contrib/pg_trgm/Makefile
+++ b/contrib/pg_trgm/Makefile
@@ -9,9 +9,9 @@ OBJS = \
 	trgm_regexp.o
 
 EXTENSION = pg_trgm
-DATA = pg_trgm--1.5--1.6.sql pg_trgm--1.4--1.5.sql pg_trgm--1.3--1.4.sql \
-	pg_trgm--1.3.sql pg_trgm--1.2--1.3.sql pg_trgm--1.1--1.2.sql \
-	pg_trgm--1.0--1.1.sql
+DATA = pg_trgm--1.6--1.7.sql pg_trgm--1.5--1.6.sql pg_trgm--1.4--1.5.sql \
+	pg_trgm--1.3--1.4.sql pg_trgm--1.3.sql pg_trgm--1.2--1.3.sql \
+	pg_trgm--1.1--1.2.sql pg_trgm--1.0--1.1.sql
 PGFILEDESC = "pg_trgm - trigram matching"
 
 REGRESS = pg_trgm pg_word_trgm pg_strict_word_trgm
diff --git a/contrib/pg_trgm/pg_trgm--1.6--1.7.sql b/contrib/pg_trgm/pg_trgm--1.6--1.7.sql
new file mode 100644
index 0000000000..06b783acbd
--- /dev/null
+++ b/contrib/pg_trgm/pg_trgm--1.6--1.7.sql
@@ -0,0 +1,8 @@
+/* contrib/pg_trgm/pg_trgm--1.6--1.7.sql */
+
+-- complain if script is sourced in psql, rather than via ALTER EXTENSION
+\echo Use "ALTER EXTENSION pg_trgm UPDATE TO '1.7'" to load this file. \quit
+
+GRANT SET VALUE ON "pg_trgm.similarity_threshold" TO public;
+GRANT SET VALUE ON "pg_trgm.word_similarity_threshold" TO public;
+GRANT SET VALUE ON "pg_trgm.strict_word_similarity_threshold" TO public;
diff --git a/contrib/pg_trgm/pg_trgm.control b/contrib/pg_trgm/pg_trgm.control
index 1d6a9ddf25..6e3ee43c51 100644
--- a/contrib/pg_trgm/pg_trgm.control
+++ b/contrib/pg_trgm/pg_trgm.control
@@ -1,6 +1,6 @@
 # pg_trgm extension
 comment = 'text similarity measurement and index searching based on trigrams'
-default_version = '1.6'
+default_version = '1.7'
 module_pathname = '$libdir/pg_trgm'
 relocatable = true
 trusted = true
diff --git a/contrib/postgres_fdw/Makefile b/contrib/postgres_fdw/Makefile
index c1b0cad453..3564015ee8 100644
--- a/contrib/postgres_fdw/Makefile
+++ b/contrib/postgres_fdw/Makefile
@@ -14,7 +14,8 @@ PG_CPPFLAGS = -I$(libpq_srcdir)
 SHLIB_LINK_INTERNAL = $(libpq)
 
 EXTENSION = postgres_fdw
-DATA = postgres_fdw--1.0.sql postgres_fdw--1.0--1.1.sql
+DATA = postgres_fdw--1.0.sql postgres_fdw--1.0--1.1.sql \
+	postgres_fdw--1.1--1.2.sql
 
 REGRESS = postgres_fdw
 
diff --git a/contrib/postgres_fdw/option.c b/contrib/postgres_fdw/option.c
index 48c7417e6e..5d30345fcf 100644
--- a/contrib/postgres_fdw/option.c
+++ b/contrib/postgres_fdw/option.c
@@ -464,7 +464,7 @@ _PG_init(void)
 							   NULL,
 							   &pgfdw_application_name,
 							   NULL,
-							   PGC_USERSET,
+							   PGC_SUSET,
 							   0,
 							   NULL,
 							   NULL,
diff --git a/contrib/postgres_fdw/postgres_fdw--1.1--1.2.sql b/contrib/postgres_fdw/postgres_fdw--1.1--1.2.sql
new file mode 100644
index 0000000000..b174e04283
--- /dev/null
+++ b/contrib/postgres_fdw/postgres_fdw--1.1--1.2.sql
@@ -0,0 +1,6 @@
+/* contrib/postgres_fdw/postgres_fdw--1.1--1.2.sql */
+
+-- complain if script is sourced in psql, rather than via ALTER EXTENSION
+\echo Use "ALTER EXTENSION postgres_fdw UPDATE TO '1.2'" to load this file. \quit
+
+GRANT SET VALUE ON "postgres_fdw.application_name" TO public;
diff --git a/contrib/postgres_fdw/postgres_fdw.control b/contrib/postgres_fdw/postgres_fdw.control
index d489382064..a4b800be4f 100644
--- a/contrib/postgres_fdw/postgres_fdw.control
+++ b/contrib/postgres_fdw/postgres_fdw.control
@@ -1,5 +1,5 @@
 # postgres_fdw extension
 comment = 'foreign-data wrapper for remote PostgreSQL servers'
-default_version = '1.1'
+default_version = '1.2'
 module_pathname = '$libdir/postgres_fdw'
 relocatable = true
diff --git a/contrib/sepgsql/hooks.c b/contrib/sepgsql/hooks.c
index 19a3ffb7ff..f7ffd3d486 100644
--- a/contrib/sepgsql/hooks.c
+++ b/contrib/sepgsql/hooks.c
@@ -449,7 +449,7 @@ _PG_init(void)
 							 NULL,
 							 &sepgsql_debug_audit,
 							 false,
-							 PGC_USERSET,
+							 PGC_SUSET,
 							 GUC_NOT_IN_SAMPLE,
 							 NULL,
 							 NULL,
diff --git a/contrib/sepgsql/sepgsql.sql.in b/contrib/sepgsql/sepgsql.sql.in
index 917d12dbbe..4dce769306 100644
--- a/contrib/sepgsql/sepgsql.sql.in
+++ b/contrib/sepgsql/sepgsql.sql.in
@@ -34,4 +34,5 @@ CREATE OR REPLACE FUNCTION pg_catalog.sepgsql_setcon(text) RETURNS bool AS 'MODU
 CREATE OR REPLACE FUNCTION pg_catalog.sepgsql_mcstrans_in(text) RETURNS text AS 'MODULE_PATHNAME', 'sepgsql_mcstrans_in' LANGUAGE C STRICT;
 CREATE OR REPLACE FUNCTION pg_catalog.sepgsql_mcstrans_out(text) RETURNS text AS 'MODULE_PATHNAME', 'sepgsql_mcstrans_out' LANGUAGE C STRICT;
 CREATE OR REPLACE FUNCTION pg_catalog.sepgsql_restorecon(text) RETURNS bool AS 'MODULE_PATHNAME', 'sepgsql_restorecon' LANGUAGE C;
+GRANT SET VALUE ON "sepgsql.debug_audit" TO public;
 SELECT sepgsql_restorecon(NULL);
diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml
index 03e2537b07..3f7e55c3b9 100644
--- a/doc/src/sgml/catalogs.sgml
+++ b/doc/src/sgml/catalogs.sgml
@@ -105,6 +105,11 @@
       <entry>collations (locale information)</entry>
      </row>
 
+     <row>
+      <entry><link linkend="catalog-pg-setting-acl"><structname>pg_setting_acl</structname></link></entry>
+      <entry>configuration parameters which have privileges granted to roles</entry>
+     </row>
+
      <row>
       <entry><link linkend="catalog-pg-constraint"><structname>pg_constraint</structname></link></entry>
       <entry>check constraints, unique constraints, primary key constraints, foreign key constraints</entry>
@@ -2423,6 +2428,64 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
   </para>
  </sect1>
 
+ <sect1 id="catalog-pg-setting-acl">
+  <title><structname>pg_setting_acl</structname></title>
+
+  <indexterm zone="catalog-pg-setting-acl">
+   <primary>pg_setting_acl</primary>
+  </indexterm>
+
+  <para>
+   The catalog <structname>pg_setting_acl</structname> records configuration
+   parameters which have had privileges to <literal>SET</literal> or
+   <literal>ALTER SYSTEM</literal> granted to one or more roles.
+  </para>
+
+  <para>
+   Unlike most system catalogs, <structname>pg_setting_acl</structname>
+   is shared across all databases of a cluster: there is only one
+   copy of <structname>pg_setting_acl</structname> per cluster, not
+   one per database.
+  </para>
+
+  <table>
+   <title><structname>pg_setting_acl</structname> Columns</title>
+   <tgroup cols="1">
+    <thead>
+     <row>
+      <entry role="catalog_table_entry"><para role="column_definition">
+       Column Type
+      </para>
+      <para>
+       Description
+      </para></entry>
+     </row>
+    </thead>
+
+    <tbody>
+     <row>
+      <entry role="catalog_table_entry"><para role="column_definition">
+       <structfield>setting</structfield> <type>text</type>
+      </para>
+      <para>
+       The name of the configuration parameter for which privileges are granted.
+      </para></entry>
+     </row>
+
+     <row>
+      <entry role="catalog_table_entry"><para role="column_definition">
+       <structfield>setacl</structfield> <type>aclitem[]</type>
+      </para>
+      <para>
+       Access privileges; see <xref linkend="ddl-priv"/> for details
+      </para></entry>
+     </row>
+
+    </tbody>
+   </tgroup>
+  </table>
+ </sect1>
+
  <sect1 id="catalog-pg-constraint">
   <title><structname>pg_constraint</structname></title>
 
@@ -12494,11 +12557,13 @@ SELECT * FROM pg_locks pl LEFT JOIN pg_prepared_xacts ppx
     <term><literal>superuser</literal></term>
     <listitem>
      <para>
-      These settings can be set from <filename>postgresql.conf</filename>,
-      or within a session via the <command>SET</command> command; but only superusers
-      can change them via <command>SET</command>.  Changes in
-      <filename>postgresql.conf</filename> will affect existing sessions
-      only if no session-local value has been established with <command>SET</command>.
+      These settings can be set from <filename>postgresql.conf</filename>, or
+      within a session via the <command>SET</command> command; but only
+      superusers or users with <literal>SET VALUE</literal> privilege granted
+      on the setting can change them via <command>SET</command>.  Changes in
+      <filename>postgresql.conf</filename> will affect existing sessions only
+      if no session-local value has been established with
+      <command>SET</command>.
      </para>
     </listitem>
    </varlistentry>
diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index 64d9030652..3b48e8006e 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -1672,7 +1672,8 @@ ALTER TABLE products RENAME TO items;
    <literal>INSERT</literal>, <literal>UPDATE</literal>, <literal>DELETE</literal>,
    <literal>TRUNCATE</literal>, <literal>REFERENCES</literal>, <literal>TRIGGER</literal>,
    <literal>CREATE</literal>, <literal>CONNECT</literal>, <literal>TEMPORARY</literal>,
-   <literal>EXECUTE</literal>, and <literal>USAGE</literal>.
+   <literal>EXECUTE</literal>, <literal>USAGE</literal>, <literal>SET VALUE</literal>
+   and <literal>ALTER SYSTEM</literal>.
    The privileges applicable to a particular
    object vary depending on the object's type (table, function, etc).
    More detail about the meanings of these privileges appears below.
@@ -1940,6 +1941,28 @@ REVOKE ALL ON accounts FROM PUBLIC;
       </para>
      </listitem>
     </varlistentry>
+
+    <varlistentry>
+     <term><literal>SET VALUE</literal></term>
+     <listitem>
+      <para>
+       Allows non-superuser roles to use the <command>SET</command> command to
+       change <literal>superuser</literal> run-time configuration parameters.
+       (Any user can set <literal>user</literal> run-time configuration
+       parameters.)
+      </para>
+     </listitem>
+    </varlistentry>
+
+    <varlistentry>
+     <term><literal>ALTER SYSTEM</literal></term>
+     <listitem>
+      <para>
+       Allows non-superuser roles to use the <command>ALTER SYSTEM
+       SET</command> command to change server configuration parameters.
+      </para>
+     </listitem>
+    </varlistentry>
    </variablelist>
 
    The privileges required by other commands are listed on the
@@ -2078,6 +2101,16 @@ REVOKE ALL ON accounts FROM PUBLIC;
        <literal>TYPE</literal>
       </entry>
      </row>
+     <row>
+      <entry><literal>SET VALUE</literal></entry>
+      <entry><literal>s</literal></entry>
+      <entry>configuration parameter</entry>
+     </row>
+     <row>
+      <entry><literal>ALTER SYSTEM</literal></entry>
+      <entry><literal>A</literal></entry>
+      <entry>configuration parameter</entry>
+     </row>
      </tbody>
    </tgroup>
   </table>
@@ -2184,6 +2217,12 @@ REVOKE ALL ON accounts FROM PUBLIC;
       <entry><literal>U</literal></entry>
       <entry><literal>\dT+</literal></entry>
      </row>
+     <row>
+      <entry><literal>Configuration parameter</literal></entry>
+      <entry><literal>sA</literal></entry>
+      <entry>none</entry>
+      <entry><literal></literal></entry>
+     </row>
     </tbody>
    </tgroup>
   </table>
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index 5801299b27..7a66eaef08 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -22624,8 +22624,7 @@ SELECT * FROM pg_ls_dir('.') WITH ORDINALITY AS t(ls,n);
    privilege is held with grant option. Also, multiple privilege types can be
    listed separated by commas, in which case the result will be true if any of
    the listed privileges is held. (Case of the privilege string is not
-   significant, and extra whitespace is allowed between but not within
-   privilege names.)
+   significant, and extra whitespace is allowed between privilege names.)
    Some examples:
 <programlisting>
 SELECT has_table_privilege('myschema.mytable', 'select');
@@ -22890,6 +22889,23 @@ SELECT has_function_privilege('joeuser', 'myfunc(int, text)', 'execute');
        </para></entry>
       </row>
 
+      <row>
+       <entry role="func_table_entry"><para role="func_signature">
+        <indexterm>
+         <primary>has_setting_privilege</primary>
+        </indexterm>
+        <function>has_setting_privilege</function> (
+          <optional> <parameter>user</parameter> <type>name</type> or <type>oid</type>, </optional>
+          <parameter>setting</parameter> <type>text</type> or <type>oid</type>,
+          <parameter>privilege</parameter> <type>text</type> )
+        <returnvalue>boolean</returnvalue>
+       </para>
+       <para>
+        Does user have privilege for setting?
+        Allowable privilege types are <literal>SET VALUE</literal> and <literal>ALTER SYSTEM</literal>.
+       </para></entry>
+      </row>
+
       <row>
        <entry role="func_table_entry"><para role="func_signature">
         <indexterm>
diff --git a/doc/src/sgml/ref/grant.sgml b/doc/src/sgml/ref/grant.sgml
index a897712de2..21ec320a8d 100644
--- a/doc/src/sgml/ref/grant.sgml
+++ b/doc/src/sgml/ref/grant.sgml
@@ -92,6 +92,11 @@ GRANT { USAGE | ALL [ PRIVILEGES ] }
     TO <replaceable class="parameter">role_specification</replaceable> [, ...] [ WITH GRANT OPTION ]
     [ GRANTED BY <replaceable class="parameter">role_specification</replaceable> ]
 
+GRANT { SET VALUE | ALTER SYSTEM }
+    ON <replaceable class="parameter">configuration_parameter</replaceable> [, ...]
+    TO <replaceable class="parameter">role_specification</replaceable> [, ...] [ WITH GRANT OPTION ]
+    [ GRANTED BY <replaceable class="parameter">role_specification</replaceable> ]
+
 GRANT <replaceable class="parameter">role_name</replaceable> [, ...] TO <replaceable class="parameter">role_specification</replaceable> [, ...]
     [ WITH ADMIN OPTION ]
     [ GRANTED BY <replaceable class="parameter">role_specification</replaceable> ]
@@ -185,6 +190,8 @@ GRANT <replaceable class="parameter">role_name</replaceable> [, ...] TO <replace
      <term><literal>TEMPORARY</literal></term>
      <term><literal>EXECUTE</literal></term>
      <term><literal>USAGE</literal></term>
+     <term><literal>SET VALUE</literal></term>
+     <term><literal>ALTER SYSTEM</literal></term>
      <listitem>
       <para>
        Specific types of privileges, as defined in <xref linkend="ddl-priv"/>.
diff --git a/doc/src/sgml/ref/set.sgml b/doc/src/sgml/ref/set.sgml
index 339ee9eec9..a08057d1d1 100644
--- a/doc/src/sgml/ref/set.sgml
+++ b/doc/src/sgml/ref/set.sgml
@@ -34,8 +34,9 @@ SET [ SESSION | LOCAL ] TIME ZONE { <replaceable class="parameter">timezone</rep
    parameters.  Many of the run-time parameters listed in
    <xref linkend="runtime-config"/> can be changed on-the-fly with
    <command>SET</command>.
-   (But some require superuser privileges to change, and others cannot
-   be changed after server or session start.)
+   (But some require either superuser privileges or granted <literal>SET
+   VALUE</literal> privileges to change, and others cannot be changed after
+   server or session start.)
    <command>SET</command> only affects the value used by the current
    session.
   </para>
diff --git a/src/backend/catalog/Makefile b/src/backend/catalog/Makefile
index 4e6efda97f..45e5330c12 100644
--- a/src/backend/catalog/Makefile
+++ b/src/backend/catalog/Makefile
@@ -28,6 +28,7 @@ OBJS = \
 	pg_cast.o \
 	pg_class.o \
 	pg_collation.o \
+	pg_setting_acl.o \
 	pg_constraint.o \
 	pg_conversion.o \
 	pg_db_role_setting.o \
@@ -54,7 +55,7 @@ include $(top_srcdir)/src/backend/common.mk
 # there are reputedly other, undocumented ordering dependencies.
 CATALOG_HEADERS := \
 	pg_proc.h pg_type.h pg_attribute.h pg_class.h \
-	pg_attrdef.h pg_constraint.h pg_inherits.h pg_index.h pg_operator.h \
+	pg_attrdef.h pg_setting_acl.h pg_constraint.h pg_inherits.h pg_index.h pg_operator.h \
 	pg_opfamily.h pg_opclass.h pg_am.h pg_amop.h pg_amproc.h \
 	pg_language.h pg_largeobject_metadata.h pg_largeobject.h pg_aggregate.h \
 	pg_statistic.h pg_statistic_ext.h pg_statistic_ext_data.h \
@@ -126,6 +127,7 @@ install-data: bki-stamp installdirs
 	$(INSTALL_DATA) $(srcdir)/system_functions.sql '$(DESTDIR)$(datadir)/system_functions.sql'
 	$(INSTALL_DATA) $(srcdir)/system_views.sql '$(DESTDIR)$(datadir)/system_views.sql'
 	$(INSTALL_DATA) $(srcdir)/information_schema.sql '$(DESTDIR)$(datadir)/information_schema.sql'
+	$(INSTALL_DATA) $(srcdir)/setting_privileges.sql '$(DESTDIR)$(datadir)/setting_privileges.sql'
 	$(INSTALL_DATA) $(srcdir)/sql_features.txt '$(DESTDIR)$(datadir)/sql_features.txt'
 
 installdirs:
@@ -133,7 +135,7 @@ installdirs:
 
 .PHONY: uninstall-data
 uninstall-data:
-	rm -f $(addprefix '$(DESTDIR)$(datadir)'/, postgres.bki system_constraints.sql system_functions.sql system_views.sql information_schema.sql sql_features.txt)
+	rm -f $(addprefix '$(DESTDIR)$(datadir)'/, postgres.bki system_constraints.sql system_functions.sql system_views.sql information_schema.sql setting_privileges.sql sql_features.txt)
 
 # postgres.bki, system_constraints.sql, and the generated headers are
 # in the distribution tarball, so they are not cleaned here.
diff --git a/src/backend/catalog/aclchk.c b/src/backend/catalog/aclchk.c
index ce0a4ff14e..c40dc94bc1 100644
--- a/src/backend/catalog/aclchk.c
+++ b/src/backend/catalog/aclchk.c
@@ -49,6 +49,7 @@
 #include "catalog/pg_operator.h"
 #include "catalog/pg_opfamily.h"
 #include "catalog/pg_proc.h"
+#include "catalog/pg_setting_acl.h"
 #include "catalog/pg_statistic_ext.h"
 #include "catalog/pg_subscription.h"
 #include "catalog/pg_tablespace.h"
@@ -112,6 +113,7 @@ static void ExecGrant_Largeobject(InternalGrant *grantStmt);
 static void ExecGrant_Namespace(InternalGrant *grantStmt);
 static void ExecGrant_Tablespace(InternalGrant *grantStmt);
 static void ExecGrant_Type(InternalGrant *grantStmt);
+static void ExecGrant_Setting(InternalGrant *grantStmt);
 
 static void SetDefaultACLsInSchemas(InternalDefaultACL *iacls, List *nspnames);
 static void SetDefaultACL(InternalDefaultACL *iacls);
@@ -259,6 +261,9 @@ restrict_and_check_grant(bool is_grant, AclMode avail_goptions, bool all_privs,
 		case OBJECT_TYPE:
 			whole_mask = ACL_ALL_RIGHTS_TYPE;
 			break;
+		case OBJECT_SETTING:
+			whole_mask = ACL_ALL_RIGHTS_SETTING;
+			break;
 		default:
 			elog(ERROR, "unrecognized object type: %d", objtype);
 			/* not reached, but keep compiler quiet */
@@ -498,6 +503,10 @@ ExecuteGrantStmt(GrantStmt *stmt)
 			all_privileges = ACL_ALL_RIGHTS_FOREIGN_SERVER;
 			errormsg = gettext_noop("invalid privilege type %s for foreign server");
 			break;
+		case OBJECT_SETTING:
+			all_privileges = ACL_ALL_RIGHTS_SETTING;
+			errormsg = gettext_noop("invalid privilege type %s for setting");
+			break;
 		default:
 			elog(ERROR, "unrecognized GrantStmt.objtype: %d",
 				 (int) stmt->objtype);
@@ -600,6 +609,9 @@ ExecGrantStmt_oids(InternalGrant *istmt)
 		case OBJECT_TABLESPACE:
 			ExecGrant_Tablespace(istmt);
 			break;
+		case OBJECT_SETTING:
+			ExecGrant_Setting(istmt);
+			break;
 		default:
 			elog(ERROR, "unrecognized GrantStmt.objtype: %d",
 				 (int) istmt->objtype);
@@ -759,6 +771,38 @@ objectNamesToOids(ObjectType objtype, List *objnames)
 				objects = lappend_oid(objects, srvid);
 			}
 			break;
+		case OBJECT_SETTING:
+			foreach(cell, objnames)
+			{
+				char	   *setting = strVal(lfirst(cell));
+				Oid			settingid = get_setting_oid(setting, true);
+
+				if (!OidIsValid(settingid))
+				{
+					/*
+					 * Lookup the existing entry, or if necessary, add a new
+					 * entry for this parameter.  Entries only exist for
+					 * parameters which currently have, or previously have had,
+					 * privileges assigned.
+					 *
+					 * It is tempting to sanity-check the given configuration
+					 * parameter name against known guc names in the guc
+					 * tables, but for handling upgrades we need to accept
+					 * setting names that do not yet exist.
+					 */
+					settingid = SettingAclCreate(setting, true);
+
+					/*
+					 * Prevent error when processing duplicate objects, and
+					 * make this new entry visible to our later selves which
+					 * will need to update the Acl.
+					 */
+					CommandCounterIncrement();
+				}
+
+				objects = lappend_oid(objects, settingid);
+			}
+			break;
 		default:
 			elog(ERROR, "unrecognized GrantStmt.objtype: %d",
 				 (int) objtype);
@@ -1494,6 +1538,9 @@ RemoveRoleFromObjectACL(Oid roleid, Oid classid, Oid objid)
 			case ForeignDataWrapperRelationId:
 				istmt.objtype = OBJECT_FDW;
 				break;
+			case SettingAclRelationId:
+				istmt.objtype = OBJECT_SETTING;
+				break;
 			default:
 				elog(ERROR, "unexpected object class %u", classid);
 				break;
@@ -3225,6 +3272,131 @@ ExecGrant_Type(InternalGrant *istmt)
 	table_close(relation, RowExclusiveLock);
 }
 
+static void
+ExecGrant_Setting(InternalGrant *istmt)
+{
+	Relation	relation;
+	ListCell   *cell;
+
+	if (istmt->all_privs && istmt->privileges == ACL_NO_RIGHTS)
+		istmt->privileges = ACL_ALL_RIGHTS_SETTING;
+
+	relation = table_open(SettingAclRelationId, RowExclusiveLock);
+
+	foreach(cell, istmt->objects)
+	{
+		Oid			settingId = lfirst_oid(cell);
+		Form_pg_setting_acl pg_setting_acl_tuple;
+		Datum		aclDatum;
+		bool		isNull;
+		AclMode		avail_goptions;
+		AclMode		this_privileges;
+		Acl		   *old_acl;
+		Acl		   *new_acl;
+		Oid			grantorId;
+		HeapTuple	tuple;
+		HeapTuple	newtuple;
+		Datum		values[Natts_pg_setting_acl];
+		bool		nulls[Natts_pg_setting_acl];
+		bool		replaces[Natts_pg_setting_acl];
+		int			noldmembers;
+		int			nnewmembers;
+		Oid		   *oldmembers;
+		Oid		   *newmembers;
+
+		tuple = SearchSysCache1(SETTINGOID, ObjectIdGetDatum(settingId));
+		if (!HeapTupleIsValid(tuple))
+			elog(ERROR, "cache lookup failed for setting %u", settingId);
+
+		pg_setting_acl_tuple = (Form_pg_setting_acl) GETSTRUCT(tuple);
+
+		/*
+		 * Get owner ID and working copy of existing ACL. If there's no ACL,
+		 * substitute the proper default.
+		 */
+		aclDatum = SysCacheGetAttr(SETTINGNAME, tuple, Anum_pg_setting_acl_setacl,
+								   &isNull);
+		if (isNull)
+		{
+			old_acl = acldefault(OBJECT_SETTING, InvalidOid);
+			/* There are no old member roles according to the catalogs */
+			noldmembers = 0;
+			oldmembers = NULL;
+		}
+		else
+		{
+			old_acl = DatumGetAclPCopy(aclDatum);
+			/* Get the roles mentioned in the existing ACL */
+			noldmembers = aclmembers(old_acl, &oldmembers);
+		}
+
+		/* Determine ID to do the grant as, and available grant options */
+		select_best_grantor(GetUserId(), istmt->privileges,
+							old_acl, GetUserId(),
+							&grantorId, &avail_goptions);
+
+		/*
+		 * Restrict the privileges to what we can actually grant, and emit the
+		 * standards-mandated warning and error messages.
+		 */
+		this_privileges =
+			restrict_and_check_grant(istmt->is_grant, avail_goptions,
+									 istmt->all_privs, istmt->privileges,
+									 settingId, grantorId, OBJECT_SETTING,
+									 text_to_cstring(&pg_setting_acl_tuple->setting),
+									 0, NULL);
+
+		/*
+		 * Generate new ACL.
+		 */
+		new_acl = merge_acl_with_grant(old_acl, istmt->is_grant,
+									   istmt->grant_option, istmt->behavior,
+									   istmt->grantees, this_privileges,
+									   grantorId, InvalidOid);
+
+		/*
+		 * We need the members of both old and new ACLs so we can correct the
+		 * shared dependency information.
+		 */
+		nnewmembers = aclmembers(new_acl, &newmembers);
+
+		/* finished building new ACL value, now insert it */
+		MemSet(values, 0, sizeof(values));
+		MemSet(nulls, false, sizeof(nulls));
+		MemSet(replaces, false, sizeof(replaces));
+
+		replaces[Anum_pg_setting_acl_setacl - 1] = true;
+		values[Anum_pg_setting_acl_setacl - 1] = PointerGetDatum(new_acl);
+
+		newtuple = heap_modify_tuple(tuple, RelationGetDescr(relation), values,
+									 nulls, replaces);
+
+		CatalogTupleUpdate(relation, &newtuple->t_self, newtuple);
+
+		/* Update initial privileges for extensions */
+		recordExtensionInitPriv(settingId, SettingAclRelationId, 0, new_acl);
+
+		/* Update the shared dependency ACL info */
+		updateAclDependencies(SettingAclRelationId,
+							  pg_setting_acl_tuple->oid, 0,
+							  InvalidOid,
+							  noldmembers, oldmembers,
+							  nnewmembers, newmembers);
+
+		ReleaseSysCache(tuple);
+
+		pfree(new_acl);
+
+		/* Post alter hook called for grant and revoke */
+		InvokeObjectPostAlterHook(SettingAclRelationId, settingId, 0);
+
+		/* prevent error when processing duplicate objects */
+		CommandCounterIncrement();
+	}
+
+	table_close(relation, RowExclusiveLock);
+}
+
 
 static AclMode
 string_to_privilege(const char *privname)
@@ -3255,6 +3427,10 @@ string_to_privilege(const char *privname)
 		return ACL_CREATE_TEMP;
 	if (strcmp(privname, "connect") == 0)
 		return ACL_CONNECT;
+	if (strcmp(privname, "set value") == 0)
+		return ACL_SET_VALUE;
+	if (strcmp(privname, "alter system") == 0)
+		return ACL_ALTER_SYSTEM;
 	if (strcmp(privname, "rule") == 0)
 		return 0;				/* ignore old RULE privileges */
 	ereport(ERROR,
@@ -3292,6 +3468,10 @@ privilege_to_string(AclMode privilege)
 			return "TEMP";
 		case ACL_CONNECT:
 			return "CONNECT";
+		case ACL_SET_VALUE:
+			return "SET VALUE";
+		case ACL_ALTER_SYSTEM:
+			return "ALTER SYSTEM";
 		default:
 			elog(ERROR, "unrecognized privilege: %d", (int) privilege);
 	}
@@ -3328,6 +3508,13 @@ aclcheck_error(AclResult aclerr, ObjectType objtype,
 					case OBJECT_COLUMN:
 						msg = gettext_noop("permission denied for column %s");
 						break;
+					case OBJECT_SETTING:
+						/*
+						 * Quote the object name for backward compatibility
+						 * with behavior before SET was handled here.
+						 */
+						msg = gettext_noop("permission denied to set parameter \"%s\"");
+						break;
 					case OBJECT_CONVERSION:
 						msg = gettext_noop("permission denied for conversion %s");
 						break;
@@ -3564,6 +3751,7 @@ aclcheck_error(AclResult aclerr, ObjectType objtype,
 					case OBJECT_AMPROC:
 					case OBJECT_ATTRIBUTE:
 					case OBJECT_CAST:
+					case OBJECT_SETTING:
 					case OBJECT_DEFAULT:
 					case OBJECT_DEFACL:
 					case OBJECT_DOMCONSTRAINT:
@@ -4000,6 +4188,59 @@ pg_database_aclmask(Oid db_oid, Oid roleid,
 	return result;
 }
 
+/*
+ * Exported routine for examining a user's privileges for a configuration
+ * parameter (GUC)
+ */
+AclMode
+pg_setting_acl_aclmask(Oid config_oid, Oid roleid,
+						AclMode mask, AclMaskHow how)
+{
+	AclMode		result;
+	HeapTuple	tuple;
+	Datum		aclDatum;
+	bool		isNull;
+	Acl		   *acl;
+
+	/* Superusers bypass all permission checking. */
+	if (superuser_arg(roleid))
+		return mask;
+
+	/*
+	 * Get the setting's ACL from pg_setting_acl
+	 */
+	tuple = SearchSysCache1(SETTINGOID, ObjectIdGetDatum(config_oid));
+	if (!HeapTupleIsValid(tuple))
+		ereport(ERROR,
+				(errcode(ERRCODE_UNDEFINED_DATABASE),
+				 errmsg("setting with OID %u does not exist",
+						config_oid)));
+
+	aclDatum = SysCacheGetAttr(SETTINGOID, tuple, Anum_pg_setting_acl_setacl,
+							   &isNull);
+	if (isNull)
+	{
+		/* No ACL, so build default ACL */
+		acl = acldefault(OBJECT_SETTING, InvalidOid);
+		aclDatum = (Datum) 0;
+	}
+	else
+	{
+		/* detoast ACL if necessary */
+		acl = DatumGetAclP(aclDatum);
+	}
+
+	result = aclmask(acl, roleid, InvalidOid, mask, how);
+
+	/* if we have a detoasted copy, free it */
+	if (acl && (Pointer) acl != DatumGetPointer(aclDatum))
+		pfree(acl);
+
+	ReleaseSysCache(tuple);
+
+	return result;
+}
+
 /*
  * Exported routine for examining a user's privileges for a function
  */
@@ -4713,6 +4954,19 @@ pg_database_aclcheck(Oid db_oid, Oid roleid, AclMode mode)
 		return ACLCHECK_NO_PRIV;
 }
 
+/*
+ * Exported routine for checking a user's access privileges to a configuration
+ * parameter
+ */
+AclResult
+pg_setting_acl_aclcheck(Oid config_oid, Oid roleid, AclMode mode)
+{
+	if (pg_setting_acl_aclmask(config_oid, roleid, mode, ACLMASK_ANY) != 0)
+		return ACLCHECK_OK;
+	else
+		return ACLCHECK_NO_PRIV;
+}
+
 /*
  * Exported routine for checking a user's access privileges to a function
  */
diff --git a/src/backend/catalog/catalog.c b/src/backend/catalog/catalog.c
index aa7d4d5456..a069c2fb39 100644
--- a/src/backend/catalog/catalog.c
+++ b/src/backend/catalog/catalog.c
@@ -34,6 +34,7 @@
 #include "catalog/pg_largeobject.h"
 #include "catalog/pg_namespace.h"
 #include "catalog/pg_replication_origin.h"
+#include "catalog/pg_setting_acl.h"
 #include "catalog/pg_shdepend.h"
 #include "catalog/pg_shdescription.h"
 #include "catalog/pg_shseclabel.h"
@@ -246,6 +247,7 @@ IsSharedRelation(Oid relationId)
 	/* These are the shared catalogs (look for BKI_SHARED_RELATION) */
 	if (relationId == AuthIdRelationId ||
 		relationId == AuthMemRelationId ||
+		relationId == SettingAclRelationId ||
 		relationId == DatabaseRelationId ||
 		relationId == SharedDescriptionRelationId ||
 		relationId == SharedDependRelationId ||
@@ -260,6 +262,8 @@ IsSharedRelation(Oid relationId)
 		relationId == AuthIdOidIndexId ||
 		relationId == AuthMemRoleMemIndexId ||
 		relationId == AuthMemMemRoleIndexId ||
+		relationId == SettingAclSettingIndexId ||
+		relationId == SettingAclOidIndexId ||
 		relationId == DatabaseNameIndexId ||
 		relationId == DatabaseOidIndexId ||
 		relationId == SharedDescriptionObjIndexId ||
@@ -277,6 +281,8 @@ IsSharedRelation(Oid relationId)
 	/* These are their toast tables and toast indexes */
 	if (relationId == PgAuthidToastTable ||
 		relationId == PgAuthidToastIndex ||
+		relationId == PgSettingAclToastTable ||
+		relationId == PgSettingAclToastIndex ||
 		relationId == PgDatabaseToastTable ||
 		relationId == PgDatabaseToastIndex ||
 		relationId == PgDbRoleSettingToastTable ||
diff --git a/src/backend/catalog/dependency.c b/src/backend/catalog/dependency.c
index fe9c714257..57174b7c19 100644
--- a/src/backend/catalog/dependency.c
+++ b/src/backend/catalog/dependency.c
@@ -52,6 +52,7 @@
 #include "catalog/pg_publication_namespace.h"
 #include "catalog/pg_publication_rel.h"
 #include "catalog/pg_rewrite.h"
+#include "catalog/pg_setting_acl.h"
 #include "catalog/pg_statistic_ext.h"
 #include "catalog/pg_subscription.h"
 #include "catalog/pg_tablespace.h"
@@ -150,6 +151,7 @@ static const Oid object_classes[] = {
 	TypeRelationId,				/* OCLASS_TYPE */
 	CastRelationId,				/* OCLASS_CAST */
 	CollationRelationId,		/* OCLASS_COLLATION */
+	SettingAclRelationId,		/* OCLASS_SETTING */
 	ConstraintRelationId,		/* OCLASS_CONSTRAINT */
 	ConversionRelationId,		/* OCLASS_CONVERSION */
 	AttrDefaultRelationId,		/* OCLASS_DEFAULT */
@@ -1504,6 +1506,7 @@ doDeletion(const ObjectAddress *object, int flags)
 			/*
 			 * These global object types are not supported here.
 			 */
+		case OCLASS_SETTING:
 		case OCLASS_ROLE:
 		case OCLASS_DATABASE:
 		case OCLASS_TBLSPACE:
@@ -2778,6 +2781,9 @@ getObjectClass(const ObjectAddress *object)
 		case CollationRelationId:
 			return OCLASS_COLLATION;
 
+		case SettingAclRelationId:
+			return OCLASS_SETTING;
+
 		case ConstraintRelationId:
 			return OCLASS_CONSTRAINT;
 
diff --git a/src/backend/catalog/objectaddress.c b/src/backend/catalog/objectaddress.c
index 2bae3fbb17..682ae5e390 100644
--- a/src/backend/catalog/objectaddress.c
+++ b/src/backend/catalog/objectaddress.c
@@ -51,6 +51,7 @@
 #include "catalog/pg_publication_namespace.h"
 #include "catalog/pg_publication_rel.h"
 #include "catalog/pg_rewrite.h"
+#include "catalog/pg_setting_acl.h"
 #include "catalog/pg_statistic_ext.h"
 #include "catalog/pg_subscription.h"
 #include "catalog/pg_tablespace.h"
@@ -2309,6 +2310,7 @@ pg_get_object_address(PG_FUNCTION_ARGS)
 		case OBJECT_COLUMN:
 		case OBJECT_ATTRIBUTE:
 		case OBJECT_COLLATION:
+		case OBJECT_SETTING:
 		case OBJECT_CONVERSION:
 		case OBJECT_STATISTIC_EXT:
 		case OBJECT_TSPARSER:
@@ -3510,6 +3512,22 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
 				break;
 			}
 
+		case OCLASS_SETTING:
+			{
+				char	   *setting;
+
+				setting = get_setting_name(object->objectId);
+				if (!setting)
+				{
+					if (!missing_ok)
+						elog(ERROR, "cache lookup failed for setting %u",
+							 object->objectId);
+					break;
+				}
+				appendStringInfo(&buffer, _("setting %s"), setting);
+				break;
+			}
+
 		case OCLASS_SCHEMA:
 			{
 				char	   *nspname;
@@ -4473,6 +4491,10 @@ getObjectTypeDescription(const ObjectAddress *object, bool missing_ok)
 			appendStringInfoString(&buffer, "collation");
 			break;
 
+		case OCLASS_SETTING:
+			appendStringInfoString(&buffer, "setting");
+			break;
+
 		case OCLASS_CONSTRAINT:
 			getConstraintTypeDescription(&buffer, object->objectId,
 										 missing_ok);
@@ -4977,6 +4999,30 @@ getObjectIdentityParts(const ObjectAddress *object,
 				break;
 			}
 
+		case OCLASS_SETTING:
+			{
+				HeapTuple	configTup;
+				Form_pg_setting_acl configForm;
+				char	   *namestr;
+
+				configTup = SearchSysCache1(SETTINGOID,
+											ObjectIdGetDatum(object->objectId));
+				if (!HeapTupleIsValid(configTup))
+				{
+					if (!missing_ok)
+						elog(ERROR, "cache lookup failed for setting %u",
+							 object->objectId);
+					break;
+				}
+				configForm = (Form_pg_setting_acl) GETSTRUCT(configTup);
+				namestr = text_to_cstring(&configForm->setting);
+				appendStringInfoString(&buffer, namestr);
+				if (objname)
+					*objname = list_make1(namestr);
+				ReleaseSysCache(configTup);
+				break;
+			}
+
 		case OCLASS_CONVERSION:
 			{
 				HeapTuple	conTup;
diff --git a/src/backend/catalog/pg_setting_acl.c b/src/backend/catalog/pg_setting_acl.c
new file mode 100644
index 0000000000..3c6594da03
--- /dev/null
+++ b/src/backend/catalog/pg_setting_acl.c
@@ -0,0 +1,122 @@
+/*-------------------------------------------------------------------------
+ *
+ * pg_setting_acl.c
+ *	  routines to support manipulation of the pg_setting_acl relation
+ *
+ * Portions Copyright (c) 1996-2021, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1994, Regents of the University of California
+ *
+ *
+ * IDENTIFICATION
+ *	  src/backend/catalog/pg_setting_acl.c
+ *
+ *-------------------------------------------------------------------------
+ */
+#include "postgres.h"
+
+#include "access/genam.h"
+#include "access/heapam.h"
+#include "access/htup_details.h"
+#include "access/sysattr.h"
+#include "access/table.h"
+#include "access/tableam.h"
+#include "catalog/catalog.h"
+#include "catalog/dependency.h"
+#include "catalog/indexing.h"
+#include "catalog/objectaccess.h"
+#include "catalog/pg_namespace.h"
+#include "catalog/pg_setting_acl.h"
+#include "mb/pg_wchar.h"
+#include "utils/builtins.h"
+#include "utils/fmgroids.h"
+#include "utils/guc.h"
+#include "utils/pg_locale.h"
+#include "utils/rel.h"
+#include "utils/syscache.h"
+
+
+/*
+ * SettingAclCreate
+ *
+ * Add a new tuple to pg_setting_acl.
+ *
+ * setting: the setting name to create.
+ * if_not_exists: if true, don't fail on duplicate name, but rather return
+ * the existing entry's Oid.
+ */
+Oid
+SettingAclCreate(const char *setting, bool if_not_exists)
+{
+	Relation	rel;
+	TupleDesc	tupDesc;
+	HeapTuple	tuple;
+	Datum		values[Natts_pg_setting_acl];
+	bool		nulls[Natts_pg_setting_acl];
+	Oid			settingId;
+	const char *canonical;
+
+	/*
+	 * Check whether the setting (by the given name or alias)
+	 * already exists.
+	 */
+	settingId = get_setting_oid(setting, true);
+	if (OidIsValid(settingId))
+	{
+		if (if_not_exists)
+			return settingId;
+		ereport(ERROR,
+				(errcode(ERRCODE_DUPLICATE_OBJECT),
+				 errmsg("setting \"%s\" already exists",
+						setting)));
+	}
+
+	/*
+	 * We must not require the setting to be in the list of existent GUCs,
+	 * as we may be called at different points during upgrades or the
+	 * installation or removal of extensions.  Instead, perform a basic sanity
+	 * check of the setting, and translate old forms of known names to their
+	 * canonical forms.
+	 *
+	 * If you deprecate a configuration name in favor of a new spelling, be
+	 * sure to consider whether to also upgrade pg_setting_acl entries.
+	 */
+	if (!valid_variable_name(setting, NULL))
+		ereport(ERROR,
+				(errcode(ERRCODE_INVALID_NAME),
+				 errmsg("invalid setting name \"%s\"",
+						setting)));
+	canonical = GetConfigOptionCanonicalName(setting);
+	if (!canonical)
+		canonical = setting;
+
+	/*
+	 * Create and insert a new record, starting with a blank Acl.
+	 *
+	 * We don't take a strong enough lock to prevent concurrent insertions,
+	 * relying instead on the unique index.
+	 */
+	rel = table_open(SettingAclRelationId, RowExclusiveLock);
+	tupDesc = RelationGetDescr(rel);
+	MemSet(values, 0, sizeof(values));
+	MemSet(nulls, false, sizeof(nulls));
+	values[Anum_pg_setting_acl_setting - 1] =
+		DirectFunctionCall1(textin, CStringGetDatum(canonical));
+	settingId = GetNewOidWithIndex(rel,
+									   SettingAclOidIndexId,
+									   Anum_pg_setting_acl_oid);
+	values[Anum_pg_setting_acl_oid - 1] = ObjectIdGetDatum(settingId);
+	nulls[Anum_pg_setting_acl_setacl - 1] = true;
+	tuple = heap_form_tuple(tupDesc, values, nulls);
+	CatalogTupleInsert(rel, tuple);
+
+	/* Post creation hook for new setting */
+	InvokeObjectPostCreateHook(SettingAclRelationId, settingId, 0);
+
+	/*
+	 * Close pg_setting_acl, but keep lock till commit.
+	 */
+	heap_freetuple(tuple);
+	table_close(rel, NoLock);
+
+	return settingId;
+}
diff --git a/src/backend/catalog/setting_privileges.sql b/src/backend/catalog/setting_privileges.sql
new file mode 100644
index 0000000000..b788ebee7f
--- /dev/null
+++ b/src/backend/catalog/setting_privileges.sql
@@ -0,0 +1,62 @@
+/*
+ * PostgreSQL User SET variables
+ *
+ * Copyright (c) 2021, PostgreSQL Global Development Group
+ *
+ * src/backend/catalog/setting_privileges.sql
+ *
+ * Note: this file is read in single-user -j mode, which means that the
+ * command terminator is semicolon-newline-newline; whenever the backend
+ * sees that, it stops and executes what it's got.  If you write a lot of
+ * statements without empty lines between, they'll all get quoted to you
+ * in any error message about one of them, so don't do that.  Also, you
+ * cannot write a semicolon immediately followed by an empty line in a
+ * string literal (including a function body!) or a multiline comment.
+ */
+
+GRANT SET VALUE ON
+	enable_seqscan, enable_indexscan, enable_indexonlyscan, enable_bitmapscan,
+	enable_tidscan, enable_sort, enable_incremental_sort, enable_hashagg,
+	enable_material, enable_memoize, enable_nestloop, enable_mergejoin,
+	enable_hashjoin, enable_gathermerge, enable_partitionwise_join,
+	enable_partitionwise_aggregate, enable_parallel_append,
+	enable_parallel_hash, enable_partition_pruning, enable_async_append, geqo,
+	exit_on_error, debug_print_parse, debug_print_rewritten, debug_print_plan,
+	debug_pretty_print, trace_notify, transform_null_equals,
+	default_transaction_read_only, transaction_read_only,
+	default_transaction_deferrable, transaction_deferrable, row_security,
+	check_function_bodies, array_nulls, default_with_oids, trace_sort,
+	trace_syncscan, optimize_bounded_sort, escape_string_warning,
+	standard_conforming_strings, synchronize_seqscans, quote_all_identifiers,
+	parallel_leader_participation, jit, jit_expressions, jit_tuple_deforming,
+	default_statistics_target, from_collapse_limit, join_collapse_limit,
+	geqo_threshold, geqo_effort, geqo_pool_size, geqo_generations,
+	temp_buffers, work_mem, maintenance_work_mem, logical_decoding_work_mem,
+	vacuum_cost_page_hit, vacuum_cost_page_miss, vacuum_cost_page_dirty,
+	vacuum_cost_limit, statement_timeout, lock_timeout,
+	idle_in_transaction_session_timeout, idle_session_timeout,
+	vacuum_freeze_min_age, vacuum_freeze_table_age,
+	vacuum_multixact_freeze_min_age, vacuum_multixact_freeze_table_age,
+	vacuum_failsafe_age, vacuum_multixact_failsafe_age, wal_skip_threshold,
+	wal_sender_timeout, commit_siblings, extra_float_digits,
+	log_parameter_max_length_on_error, effective_io_concurrency,
+	maintenance_io_concurrency, backend_flush_after,
+	max_parallel_maintenance_workers, max_parallel_workers_per_gather,
+	max_parallel_workers, tcp_keepalives_idle, tcp_keepalives_interval,
+	ssl_renegotiation_limit, tcp_keepalives_count, gin_fuzzy_search_limit,
+	effective_cache_size, min_parallel_table_scan_size,
+	min_parallel_index_scan_size, gin_pending_list_limit, tcp_user_timeout,
+	client_connection_check_interval, seq_page_cost, random_page_cost,
+	cpu_tuple_cost, cpu_index_tuple_cost, cpu_operator_cost,
+	parallel_tuple_cost, parallel_setup_cost, jit_above_cost,
+	jit_optimize_above_cost, jit_inline_above_cost, cursor_tuple_fraction,
+	geqo_selection_bias, geqo_seed, hash_mem_multiplier, seed,
+	vacuum_cost_delay, DateStyle, default_table_access_method,
+	default_tablespace, temp_tablespaces, lc_monetary, lc_numeric, lc_time,
+	local_preload_libraries, search_path, role, TimeZone,
+	timezone_abbreviations, default_text_search_config, application_name,
+	backslash_quote, bytea_output, client_min_messages, constraint_exclusion,
+	default_toast_compression, default_transaction_isolation,
+	transaction_isolation, IntervalStyle, synchronous_commit, xmlbinary,
+	xmloption, force_parallel_mode, password_encryption, plan_cache_mode
+	TO public;
diff --git a/src/backend/catalog/system_views.sql b/src/backend/catalog/system_views.sql
index 61b515cdb8..bd772dc9c5 100644
--- a/src/backend/catalog/system_views.sql
+++ b/src/backend/catalog/system_views.sql
@@ -593,6 +593,19 @@ CREATE RULE pg_settings_n AS
 
 GRANT SELECT, UPDATE ON pg_settings TO PUBLIC;
 
+CREATE VIEW pg_setting_privileges AS
+	SELECT grantor.rolname AS grantor,
+		   grantee.rolname AS grantee,
+		   set_acl.setting AS setting,
+		   acl.privilege_type AS privilege_type,
+		   acl.is_grantable
+		FROM pg_catalog.pg_setting_acl set_acl,
+		LATERAL (SELECT * FROM aclexplode(set_acl.setacl)) acl
+		LEFT JOIN pg_catalog.pg_authid grantee ON acl.grantee = grantee.oid
+		LEFT JOIN pg_catalog.pg_authid grantor ON acl.grantor = grantor.oid;
+
+GRANT SELECT ON pg_setting_privileges TO PUBLIC;
+
 CREATE VIEW pg_file_settings AS
    SELECT * FROM pg_show_all_file_settings() AS A;
 
diff --git a/src/backend/commands/alter.c b/src/backend/commands/alter.c
index 40044070cf..7da2e62683 100644
--- a/src/backend/commands/alter.c
+++ b/src/backend/commands/alter.c
@@ -639,6 +639,7 @@ AlterObjectNamespace_oid(Oid classId, Oid objid, Oid nspOid,
 			break;
 
 		case OCLASS_CAST:
+		case OCLASS_SETTING:
 		case OCLASS_CONSTRAINT:
 		case OCLASS_DEFAULT:
 		case OCLASS_LANGUAGE:
diff --git a/src/backend/commands/dropcmds.c b/src/backend/commands/dropcmds.c
index 4e545adf95..45bc1c1948 100644
--- a/src/backend/commands/dropcmds.c
+++ b/src/backend/commands/dropcmds.c
@@ -276,6 +276,13 @@ does_not_exist_skipping(ObjectType objtype, Node *object)
 				name = NameListToString(castNode(List, object));
 			}
 			break;
+		case OBJECT_SETTING:
+			if (!schema_does_not_exist_skipping(castNode(List, object), &msg, &name))
+			{
+				msg = gettext_noop("setting \"%s\" does not exist, skipping");
+				name = NameListToString(castNode(List, object));
+			}
+			break;
 		case OBJECT_CONVERSION:
 			if (!schema_does_not_exist_skipping(castNode(List, object), &msg, &name))
 			{
diff --git a/src/backend/commands/event_trigger.c b/src/backend/commands/event_trigger.c
index df264329d8..d6df5b3ad9 100644
--- a/src/backend/commands/event_trigger.c
+++ b/src/backend/commands/event_trigger.c
@@ -937,6 +937,7 @@ EventTriggerSupportsObjectType(ObjectType obtype)
 {
 	switch (obtype)
 	{
+		case OBJECT_SETTING:
 		case OBJECT_DATABASE:
 		case OBJECT_TABLESPACE:
 		case OBJECT_ROLE:
@@ -1012,6 +1013,7 @@ EventTriggerSupportsObjectClass(ObjectClass objclass)
 {
 	switch (objclass)
 	{
+		case OCLASS_SETTING:
 		case OCLASS_DATABASE:
 		case OCLASS_TBLSPACE:
 		case OCLASS_ROLE:
@@ -2078,6 +2080,8 @@ stringify_grant_objtype(ObjectType objtype)
 	{
 		case OBJECT_COLUMN:
 			return "COLUMN";
+		case OBJECT_SETTING:
+			return "SETTING";
 		case OBJECT_TABLE:
 			return "TABLE";
 		case OBJECT_SEQUENCE:
@@ -2161,6 +2165,8 @@ stringify_adefprivs_objtype(ObjectType objtype)
 	{
 		case OBJECT_COLUMN:
 			return "COLUMNS";
+		case OBJECT_SETTING:
+			return "SETTINGS";
 		case OBJECT_TABLE:
 			return "TABLES";
 		case OBJECT_SEQUENCE:
diff --git a/src/backend/commands/seclabel.c b/src/backend/commands/seclabel.c
index 53c18628a7..8f6f9bd7a0 100644
--- a/src/backend/commands/seclabel.c
+++ b/src/backend/commands/seclabel.c
@@ -67,6 +67,7 @@ SecLabelSupportsObjectType(ObjectType objtype)
 		case OBJECT_ATTRIBUTE:
 		case OBJECT_CAST:
 		case OBJECT_COLLATION:
+		case OBJECT_SETTING:
 		case OBJECT_CONVERSION:
 		case OBJECT_DEFAULT:
 		case OBJECT_DEFACL:
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 47b29001d5..5672e9d1e4 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -12359,6 +12359,7 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
 			case OCLASS_TYPE:
 			case OCLASS_CAST:
 			case OCLASS_COLLATION:
+			case OCLASS_SETTING:
 			case OCLASS_CONVERSION:
 			case OCLASS_LANGUAGE:
 			case OCLASS_LARGEOBJECT:
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index 3d4dd43e47..132b6907c5 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -363,8 +363,8 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
 %type <str>		foreign_server_version opt_foreign_server_version
 %type <str>		opt_in_database
 
-%type <str>		OptSchemaName
-%type <list>	OptSchemaEltList
+%type <str>		OptSchemaName setting_name
+%type <list>	OptSchemaEltList setting_target
 
 %type <chr>		am_type
 
@@ -402,8 +402,8 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
 %type <str>		iso_level opt_encoding
 %type <rolespec> grantee
 %type <list>	grantee_list
-%type <accesspriv> privilege
-%type <list>	privileges privilege_list
+%type <accesspriv> privilege setting_priv
+%type <list>	privileges privilege_list setting_priv_list
 %type <privtarget> privilege_target
 %type <objwithargs> function_with_argtypes aggregate_with_argtypes operator_with_argtypes
 %type <list>	function_with_argtypes_list aggregate_with_argtypes_list operator_with_argtypes_list
@@ -715,7 +715,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
 	ORDER ORDINALITY OTHERS OUT_P OUTER_P
 	OVER OVERLAPS OVERLAY OVERRIDING OWNED OWNER
 
-	PARALLEL PARSER PARTIAL PARTITION PASSING PASSWORD PLACING PLANS POLICY
+	PARALLEL PARAMETER PARSER PARTIAL PARTITION PASSING PASSWORD PLACING PLANS POLICY
 	POSITION PRECEDING PRECISION PRESERVE PREPARE PREPARED PRIMARY
 	PRIOR PRIVILEGES PROCEDURAL PROCEDURE PROCEDURES PROGRAM PUBLICATION
 
@@ -6972,6 +6972,20 @@ GrantStmt:	GRANT privileges ON privilege_target TO grantee_list
 					n->grantor = $8;
 					$$ = (Node*)n;
 				}
+			| GRANT setting_priv_list ON setting_target TO grantee_list
+			opt_grant_grant_option opt_granted_by
+				{
+					GrantStmt *n = makeNode(GrantStmt);
+					n->is_grant = true;
+					n->privileges = $2;
+					n->targtype = ACL_TARGET_OBJECT;
+					n->objtype = OBJECT_SETTING;
+					n->objects = $4;
+					n->grantees = $6;
+					n->grant_option = $7;
+					n->grantor = $8;
+					$$ = (Node*)n;
+				}
 		;
 
 RevokeStmt:
@@ -7005,6 +7019,36 @@ RevokeStmt:
 					n->behavior = $11;
 					$$ = (Node *)n;
 				}
+			| REVOKE setting_priv_list ON setting_target FROM grantee_list
+			opt_granted_by opt_drop_behavior
+				{
+					GrantStmt *n = makeNode(GrantStmt);
+					n->is_grant = false;
+					n->grant_option = false;
+					n->privileges = $2;
+					n->targtype = ACL_TARGET_OBJECT;
+					n->objtype = OBJECT_SETTING;
+					n->objects = $4;
+					n->grantees = $6;
+					n->grantor = $7;
+					n->behavior = $8;
+					$$ = (Node *)n;
+				}
+			| REVOKE GRANT OPTION FOR setting_priv_list ON setting_target
+			FROM grantee_list opt_granted_by opt_drop_behavior
+				{
+					GrantStmt *n = makeNode(GrantStmt);
+					n->is_grant = false;
+					n->grant_option = true;
+					n->privileges = $5;
+					n->targtype = ACL_TARGET_OBJECT;
+					n->objtype = OBJECT_SETTING;
+					n->objects = $7;
+					n->grantees = $9;
+					n->grantor = $10;
+					n->behavior = $11;
+					$$ = (Node *)n;
+				}
 		;
 
 
@@ -7073,6 +7117,49 @@ privilege:	SELECT opt_column_list
 			}
 		;
 
+setting_priv_list: setting_priv						{ $$ = list_make1($1); }
+			| setting_priv_list ',' setting_priv	{ $$ = lappend($1, $3); }
+		;
+
+setting_priv:
+		ALTER SYSTEM_P
+			{
+				AccessPriv *n = makeNode(AccessPriv);
+				n->priv_name = pstrdup("alter system");
+				n->cols = NIL;
+				$$ = n;
+			}
+		| SET VALUE_P
+			{
+				AccessPriv *n = makeNode(AccessPriv);
+				n->priv_name = pstrdup("set value");
+				n->cols = NIL;
+				$$ = n;
+			}
+		;
+
+
+setting_target:
+			setting_name
+				{
+					$$ = list_make1(makeString($1));
+				}
+			| setting_target ',' setting_name
+				{
+					$$ = lappend($1, makeString($3));
+				}
+		;
+
+setting_name:
+			ColId
+				{
+					$$ = $1;
+				}
+			| setting_name '.' ColId
+				{
+					$$ = psprintf("%s.%s", $1, $3);
+				}
+		;
 
 /* Don't bother trying to fold the first two rules into one using
  * opt_table.  You're going to get conflicts.
@@ -15818,6 +15905,7 @@ unreserved_keyword:
 			| OWNED
 			| OWNER
 			| PARALLEL
+			| PARAMETER
 			| PARSER
 			| PARTIAL
 			| PARTITION
@@ -16396,6 +16484,7 @@ bare_label_keyword:
 			| OWNED
 			| OWNER
 			| PARALLEL
+			| PARAMETER
 			| PARSER
 			| PARTIAL
 			| PARTITION
diff --git a/src/backend/utils/adt/acl.c b/src/backend/utils/adt/acl.c
index 67f8b29434..f0dd3e52ed 100644
--- a/src/backend/utils/adt/acl.c
+++ b/src/backend/utils/adt/acl.c
@@ -23,6 +23,7 @@
 #include "catalog/pg_authid.h"
 #include "catalog/pg_class.h"
 #include "catalog/pg_database.h"
+#include "catalog/pg_setting_acl.h"
 #include "catalog/pg_type.h"
 #include "commands/dbcommands.h"
 #include "commands/proclang.h"
@@ -36,6 +37,7 @@
 #include "utils/array.h"
 #include "utils/builtins.h"
 #include "utils/catcache.h"
+#include "utils/guc.h"
 #include "utils/inval.h"
 #include "utils/lsyscache.h"
 #include "utils/memutils.h"
@@ -109,6 +111,8 @@ static Oid	convert_tablespace_name(text *tablespacename);
 static AclMode convert_tablespace_priv_string(text *priv_type_text);
 static Oid	convert_type_name(text *typename);
 static AclMode convert_type_priv_string(text *priv_type_text);
+static Oid	convert_setting_name(text *setting);
+static AclMode convert_setting_priv_string(text *priv_setting_text);
 static AclMode convert_role_priv_string(text *priv_type_text);
 static AclResult pg_role_aclcheck(Oid role_oid, Oid roleid, AclMode mode);
 
@@ -306,6 +310,12 @@ aclparse(const char *s, AclItem *aip)
 			case ACL_CONNECT_CHR:
 				read = ACL_CONNECT;
 				break;
+			case ACL_SET_VALUE_CHR:
+				read = ACL_SET_VALUE;
+				break;
+			case ACL_ALTER_SYSTEM_CHR:
+				read = ACL_ALTER_SYSTEM;
+				break;
 			case 'R':			/* ignore old RULE privileges */
 				read = 0;
 				break;
@@ -794,6 +804,10 @@ acldefault(ObjectType objtype, Oid ownerId)
 			world_default = ACL_USAGE;
 			owner_default = ACL_ALL_RIGHTS_TYPE;
 			break;
+		case OBJECT_SETTING:
+			world_default = ACL_NO_RIGHTS;
+			owner_default = ACL_NO_RIGHTS;
+			break;
 		default:
 			elog(ERROR, "unrecognized objtype: %d", (int) objtype);
 			world_default = ACL_NO_RIGHTS;	/* keep compiler quiet */
@@ -1602,6 +1616,10 @@ convert_priv_string(text *priv_type_text)
 		return ACL_CREATE_TEMP;
 	if (pg_strcasecmp(priv_type, "CONNECT") == 0)
 		return ACL_CONNECT;
+	if (pg_strcasecmp(priv_type, "SET VALUE") == 0)
+		return ACL_SET_VALUE;
+	if (pg_strcasecmp(priv_type, "ALTER SYSTEM") == 0)
+		return ACL_ALTER_SYSTEM;
 	if (pg_strcasecmp(priv_type, "RULE") == 0)
 		return 0;				/* ignore old RULE privileges */
 
@@ -1698,6 +1716,10 @@ convert_aclright_to_string(int aclright)
 			return "TEMPORARY";
 		case ACL_CONNECT:
 			return "CONNECT";
+		case ACL_SET_VALUE:
+			return "SET VALUE";
+		case ACL_ALTER_SYSTEM:
+			return "ALTER SYSTEM";
 		default:
 			elog(ERROR, "unrecognized aclright: %d", aclright);
 			return NULL;
@@ -4429,6 +4451,205 @@ convert_type_priv_string(text *priv_type_text)
 	return convert_any_priv_string(priv_type_text, type_priv_map);
 }
 
+/*
+ * has_setting_privilege variants
+ *		These are all named "has_setting_privilege" at the SQL level.
+ *		They take various combinations of setting name, setting OID,
+ *		user name, user OID, or implicit user = current_user.
+ *
+ *		The result is a boolean value: true if user has the indicated
+ *		privilege, false if not, or NULL if object doesn't exist.
+ */
+
+/*
+ * has_setting_privilege_name_name
+ *		Check user privileges on a setting given
+ *		name username, text setting, and text priv name.
+ */
+Datum
+has_setting_privilege_name_name(PG_FUNCTION_ARGS)
+{
+	Name		username = PG_GETARG_NAME(0);
+	text	   *setting = PG_GETARG_TEXT_PP(1);
+	text	   *priv_setting_text = PG_GETARG_TEXT_PP(2);
+	Oid			roleid;
+	Oid			settingoid;
+	AclMode		mode;
+	AclResult	aclresult;
+
+	roleid = get_role_oid_or_public(NameStr(*username));
+	settingoid = convert_setting_name(setting);
+	mode = convert_setting_priv_string(priv_setting_text);
+
+	aclresult = pg_setting_acl_aclcheck(settingoid, roleid, mode);
+
+	PG_RETURN_BOOL(aclresult == ACLCHECK_OK);
+}
+
+/*
+ * has_setting_privilege_name
+ *		Check user privileges on a setting given
+ *		text setting and text priv name.
+ *		current_user is assumed
+ */
+Datum
+has_setting_privilege_name(PG_FUNCTION_ARGS)
+{
+	text	   *setting = PG_GETARG_TEXT_PP(0);
+	text	   *priv_setting_text = PG_GETARG_TEXT_PP(1);
+	Oid			roleid;
+	Oid			settingoid;
+	AclMode		mode;
+	AclResult	aclresult;
+
+	roleid = GetUserId();
+	settingoid = convert_setting_name(setting);
+	mode = convert_setting_priv_string(priv_setting_text);
+
+	aclresult = pg_setting_acl_aclcheck(settingoid, roleid, mode);
+
+	PG_RETURN_BOOL(aclresult == ACLCHECK_OK);
+}
+
+/*
+ * has_setting_privilege_name_id
+ *		Check user privileges on a setting given
+ *		name usename, setting oid, and text priv name.
+ */
+Datum
+has_setting_privilege_name_id(PG_FUNCTION_ARGS)
+{
+	Name		username = PG_GETARG_NAME(0);
+	Oid			settingoid = PG_GETARG_OID(1);
+	text	   *priv_setting_text = PG_GETARG_TEXT_PP(2);
+	Oid			roleid;
+	AclMode		mode;
+	AclResult	aclresult;
+
+	roleid = get_role_oid_or_public(NameStr(*username));
+	mode = convert_setting_priv_string(priv_setting_text);
+
+	if (!SearchSysCacheExists1(SETTINGOID, ObjectIdGetDatum(settingoid)))
+		PG_RETURN_NULL();
+
+	aclresult = pg_setting_acl_aclcheck(settingoid, roleid, mode);
+
+	PG_RETURN_BOOL(aclresult == ACLCHECK_OK);
+}
+
+/*
+ * has_setting_privilege_id
+ *		Check user privileges on a setting given
+ *		setting oid, and text priv name.
+ *		current_user is assumed
+ */
+Datum
+has_setting_privilege_id(PG_FUNCTION_ARGS)
+{
+	Oid			settingoid = PG_GETARG_OID(0);
+	text	   *priv_setting_text = PG_GETARG_TEXT_PP(1);
+	Oid			roleid;
+	AclMode		mode;
+	AclResult	aclresult;
+
+	roleid = GetUserId();
+	mode = convert_setting_priv_string(priv_setting_text);
+
+	if (!SearchSysCacheExists1(SETTINGOID, ObjectIdGetDatum(settingoid)))
+		PG_RETURN_NULL();
+
+	aclresult = pg_setting_acl_aclcheck(settingoid, roleid, mode);
+
+	PG_RETURN_BOOL(aclresult == ACLCHECK_OK);
+}
+
+/*
+ * has_setting_privilege_id_name
+ *		Check user privileges on a setting given
+ *		roleid, text setting, and text priv name.
+ */
+Datum
+has_setting_privilege_id_name(PG_FUNCTION_ARGS)
+{
+	Oid			roleid = PG_GETARG_OID(0);
+	text	   *setting = PG_GETARG_TEXT_PP(1);
+	text	   *priv_setting_text = PG_GETARG_TEXT_PP(2);
+	Oid			settingoid;
+	AclMode		mode;
+	AclResult	aclresult;
+
+	settingoid = convert_setting_name(setting);
+	mode = convert_setting_priv_string(priv_setting_text);
+
+	aclresult = pg_setting_acl_aclcheck(settingoid, roleid, mode);
+
+	PG_RETURN_BOOL(aclresult == ACLCHECK_OK);
+}
+
+/*
+ * has_setting_privilege_id_id
+ *		Check user privileges on a setting given
+ *		roleid, setting oid, and text priv name.
+ */
+Datum
+has_setting_privilege_id_id(PG_FUNCTION_ARGS)
+{
+	Oid			roleid = PG_GETARG_OID(0);
+	Oid			settingoid = PG_GETARG_OID(1);
+	text	   *priv_setting_text = PG_GETARG_TEXT_PP(2);
+	AclMode		mode;
+	AclResult	aclresult;
+
+	mode = convert_setting_priv_string(priv_setting_text);
+
+	if (!SearchSysCacheExists1(SETTINGOID, ObjectIdGetDatum(settingoid)))
+		PG_RETURN_NULL();
+
+	aclresult = pg_setting_acl_aclcheck(settingoid, roleid, mode);
+
+	PG_RETURN_BOOL(aclresult == ACLCHECK_OK);
+}
+
+/*
+ *		Support routines for has_setting_privilege family.
+ */
+
+/*
+ * Given a setting name expressed as a string, look it up and return Oid
+ */
+static Oid
+convert_setting_name(text *settingname)
+{
+	Oid			oid;
+	char	   *setting = text_to_cstring(settingname);
+
+	oid = get_setting_oid(setting, true);
+
+	if (!OidIsValid(oid))
+		ereport(ERROR,
+				(errcode(ERRCODE_UNDEFINED_OBJECT),
+				 errmsg("setting \"%s\" does not exist", setting)));
+
+	return oid;
+}
+
+/*
+ * convert_setting_priv_string
+ *		Convert text string to AclMode value.
+ */
+static AclMode
+convert_setting_priv_string(text *priv_setting_text)
+{
+	static const priv_map setting_priv_map[] = {
+		{"SET VALUE", ACL_SET_VALUE},
+		{"SET VALUE WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_SET_VALUE)},
+		{"ALTER SYSTEM", ACL_ALTER_SYSTEM},
+		{"ALTER SYSTEM WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_ALTER_SYSTEM)},
+		{NULL, 0}
+	};
+
+	return convert_any_priv_string(priv_setting_text, setting_priv_map);
+}
 
 /*
  * pg_has_role variants
@@ -4670,6 +4891,43 @@ initialize_acl(void)
 	}
 }
 
+/*
+ * get_setting_oid - Given a configuration parameter name, look up the
+ * configuration parameter's OID.  Note that names which are aliases for
+ * a canonical name will be translated automatically and the OID found.
+ *
+ * If missing_ok is false, throw an error if the configuration parameter name
+ * is not found.
+ *
+ * Returns the Oid of the configuration parameter.
+ */
+Oid
+get_setting_oid(const char *setting, bool missing_ok)
+{
+	Oid			oid;
+
+	/* Check for the variable by the name we were given */
+	oid = GetSysCacheOid1(SETTINGNAME, Anum_pg_setting_acl_oid,
+						  PointerGetDatum(cstring_to_text(setting)));
+	if (!OidIsValid(oid))
+	{
+		const char *canonical;
+
+		/* Check if the variable has a different canonical spelling */
+		canonical = GetConfigOptionCanonicalName(setting);
+		if (canonical != NULL)
+			oid = GetSysCacheOid1(SETTINGNAME, Anum_pg_setting_acl_oid,
+								  PointerGetDatum(cstring_to_text(canonical)));
+
+		if (!OidIsValid(oid) && !missing_ok)
+			ereport(ERROR,
+					(errcode(ERRCODE_UNDEFINED_OBJECT),
+					 errmsg("setting \"%s\" does not exist", setting)));
+	}
+
+	return oid;
+}
+
 /*
  * RoleMembershipCacheCallback
  *		Syscache inval callback function
diff --git a/src/backend/utils/cache/lsyscache.c b/src/backend/utils/cache/lsyscache.c
index 9176514a96..0a0cbfd9f0 100644
--- a/src/backend/utils/cache/lsyscache.c
+++ b/src/backend/utils/cache/lsyscache.c
@@ -32,6 +32,7 @@
 #include "catalog/pg_operator.h"
 #include "catalog/pg_proc.h"
 #include "catalog/pg_range.h"
+#include "catalog/pg_setting_acl.h"
 #include "catalog/pg_statistic.h"
 #include "catalog/pg_transform.h"
 #include "catalog/pg_type.h"
@@ -3304,6 +3305,25 @@ free_attstatsslot(AttStatsSlot *sslot)
 		pfree(sslot->numbers_arr);
 }
 
+char *
+get_setting_name(Oid configid)
+{
+	HeapTuple	tp;
+
+	tp = SearchSysCache1(SETTINGOID, ObjectIdGetDatum(configid));
+	if (HeapTupleIsValid(tp))
+	{
+		Form_pg_setting_acl configtup = (Form_pg_setting_acl) GETSTRUCT(tp);
+		char	   *result;
+
+		result = pstrdup(text_to_cstring(&configtup->setting));
+		ReleaseSysCache(tp);
+		return result;
+	}
+	else
+		return NULL;
+}
+
 /*				---------- PG_NAMESPACE CACHE ----------				 */
 
 /*
diff --git a/src/backend/utils/cache/syscache.c b/src/backend/utils/cache/syscache.c
index 56870b46e4..00fbe5218d 100644
--- a/src/backend/utils/cache/syscache.c
+++ b/src/backend/utils/cache/syscache.c
@@ -57,6 +57,7 @@
 #include "catalog/pg_rewrite.h"
 #include "catalog/pg_seclabel.h"
 #include "catalog/pg_sequence.h"
+#include "catalog/pg_setting_acl.h"
 #include "catalog/pg_shdepend.h"
 #include "catalog/pg_shdescription.h"
 #include "catalog/pg_shseclabel.h"
@@ -762,6 +763,28 @@ static const struct cachedesc cacheinfo[] = {
 		},
 		32
 	},
+	{SettingAclRelationId,		/* SETTINGNAME */
+		SettingAclSettingIndexId,
+		1,
+		{
+			Anum_pg_setting_acl_setting,
+			0,
+			0,
+			0
+		},
+		4
+	},
+	{SettingAclRelationId,		/* SETTINGOID */
+		SettingAclOidIndexId,
+		1,
+		{
+			Anum_pg_setting_acl_oid,
+			0,
+			0,
+			0
+		},
+		4
+	},
 	{StatisticExtDataRelationId,	/* STATEXTDATASTXOID */
 		StatisticExtDataStxoidIndexId,
 		1,
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index f736e8d872..e2615138b6 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -974,7 +974,7 @@ static const unit_conversion time_unit_conversion_table[] =
 static struct config_bool ConfigureNamesBool[] =
 {
 	{
-		{"enable_seqscan", PGC_USERSET, QUERY_TUNING_METHOD,
+		{"enable_seqscan", PGC_SUSET, QUERY_TUNING_METHOD,
 			gettext_noop("Enables the planner's use of sequential-scan plans."),
 			NULL,
 			GUC_EXPLAIN
@@ -984,7 +984,7 @@ static struct config_bool ConfigureNamesBool[] =
 		NULL, NULL, NULL
 	},
 	{
-		{"enable_indexscan", PGC_USERSET, QUERY_TUNING_METHOD,
+		{"enable_indexscan", PGC_SUSET, QUERY_TUNING_METHOD,
 			gettext_noop("Enables the planner's use of index-scan plans."),
 			NULL,
 			GUC_EXPLAIN
@@ -994,7 +994,7 @@ static struct config_bool ConfigureNamesBool[] =
 		NULL, NULL, NULL
 	},
 	{
-		{"enable_indexonlyscan", PGC_USERSET, QUERY_TUNING_METHOD,
+		{"enable_indexonlyscan", PGC_SUSET, QUERY_TUNING_METHOD,
 			gettext_noop("Enables the planner's use of index-only-scan plans."),
 			NULL,
 			GUC_EXPLAIN
@@ -1004,7 +1004,7 @@ static struct config_bool ConfigureNamesBool[] =
 		NULL, NULL, NULL
 	},
 	{
-		{"enable_bitmapscan", PGC_USERSET, QUERY_TUNING_METHOD,
+		{"enable_bitmapscan", PGC_SUSET, QUERY_TUNING_METHOD,
 			gettext_noop("Enables the planner's use of bitmap-scan plans."),
 			NULL,
 			GUC_EXPLAIN
@@ -1014,7 +1014,7 @@ static struct config_bool ConfigureNamesBool[] =
 		NULL, NULL, NULL
 	},
 	{
-		{"enable_tidscan", PGC_USERSET, QUERY_TUNING_METHOD,
+		{"enable_tidscan", PGC_SUSET, QUERY_TUNING_METHOD,
 			gettext_noop("Enables the planner's use of TID scan plans."),
 			NULL,
 			GUC_EXPLAIN
@@ -1024,7 +1024,7 @@ static struct config_bool ConfigureNamesBool[] =
 		NULL, NULL, NULL
 	},
 	{
-		{"enable_sort", PGC_USERSET, QUERY_TUNING_METHOD,
+		{"enable_sort", PGC_SUSET, QUERY_TUNING_METHOD,
 			gettext_noop("Enables the planner's use of explicit sort steps."),
 			NULL,
 			GUC_EXPLAIN
@@ -1034,7 +1034,7 @@ static struct config_bool ConfigureNamesBool[] =
 		NULL, NULL, NULL
 	},
 	{
-		{"enable_incremental_sort", PGC_USERSET, QUERY_TUNING_METHOD,
+		{"enable_incremental_sort", PGC_SUSET, QUERY_TUNING_METHOD,
 			gettext_noop("Enables the planner's use of incremental sort steps."),
 			NULL,
 			GUC_EXPLAIN
@@ -1044,7 +1044,7 @@ static struct config_bool ConfigureNamesBool[] =
 		NULL, NULL, NULL
 	},
 	{
-		{"enable_hashagg", PGC_USERSET, QUERY_TUNING_METHOD,
+		{"enable_hashagg", PGC_SUSET, QUERY_TUNING_METHOD,
 			gettext_noop("Enables the planner's use of hashed aggregation plans."),
 			NULL,
 			GUC_EXPLAIN
@@ -1054,7 +1054,7 @@ static struct config_bool ConfigureNamesBool[] =
 		NULL, NULL, NULL
 	},
 	{
-		{"enable_material", PGC_USERSET, QUERY_TUNING_METHOD,
+		{"enable_material", PGC_SUSET, QUERY_TUNING_METHOD,
 			gettext_noop("Enables the planner's use of materialization."),
 			NULL,
 			GUC_EXPLAIN
@@ -1064,7 +1064,7 @@ static struct config_bool ConfigureNamesBool[] =
 		NULL, NULL, NULL
 	},
 	{
-		{"enable_memoize", PGC_USERSET, QUERY_TUNING_METHOD,
+		{"enable_memoize", PGC_SUSET, QUERY_TUNING_METHOD,
 			gettext_noop("Enables the planner's use of memoization."),
 			NULL,
 			GUC_EXPLAIN
@@ -1074,7 +1074,7 @@ static struct config_bool ConfigureNamesBool[] =
 		NULL, NULL, NULL
 	},
 	{
-		{"enable_nestloop", PGC_USERSET, QUERY_TUNING_METHOD,
+		{"enable_nestloop", PGC_SUSET, QUERY_TUNING_METHOD,
 			gettext_noop("Enables the planner's use of nested-loop join plans."),
 			NULL,
 			GUC_EXPLAIN
@@ -1084,7 +1084,7 @@ static struct config_bool ConfigureNamesBool[] =
 		NULL, NULL, NULL
 	},
 	{
-		{"enable_mergejoin", PGC_USERSET, QUERY_TUNING_METHOD,
+		{"enable_mergejoin", PGC_SUSET, QUERY_TUNING_METHOD,
 			gettext_noop("Enables the planner's use of merge join plans."),
 			NULL,
 			GUC_EXPLAIN
@@ -1094,7 +1094,7 @@ static struct config_bool ConfigureNamesBool[] =
 		NULL, NULL, NULL
 	},
 	{
-		{"enable_hashjoin", PGC_USERSET, QUERY_TUNING_METHOD,
+		{"enable_hashjoin", PGC_SUSET, QUERY_TUNING_METHOD,
 			gettext_noop("Enables the planner's use of hash join plans."),
 			NULL,
 			GUC_EXPLAIN
@@ -1104,7 +1104,7 @@ static struct config_bool ConfigureNamesBool[] =
 		NULL, NULL, NULL
 	},
 	{
-		{"enable_gathermerge", PGC_USERSET, QUERY_TUNING_METHOD,
+		{"enable_gathermerge", PGC_SUSET, QUERY_TUNING_METHOD,
 			gettext_noop("Enables the planner's use of gather merge plans."),
 			NULL,
 			GUC_EXPLAIN
@@ -1114,7 +1114,7 @@ static struct config_bool ConfigureNamesBool[] =
 		NULL, NULL, NULL
 	},
 	{
-		{"enable_partitionwise_join", PGC_USERSET, QUERY_TUNING_METHOD,
+		{"enable_partitionwise_join", PGC_SUSET, QUERY_TUNING_METHOD,
 			gettext_noop("Enables partitionwise join."),
 			NULL,
 			GUC_EXPLAIN
@@ -1124,7 +1124,7 @@ static struct config_bool ConfigureNamesBool[] =
 		NULL, NULL, NULL
 	},
 	{
-		{"enable_partitionwise_aggregate", PGC_USERSET, QUERY_TUNING_METHOD,
+		{"enable_partitionwise_aggregate", PGC_SUSET, QUERY_TUNING_METHOD,
 			gettext_noop("Enables partitionwise aggregation and grouping."),
 			NULL,
 			GUC_EXPLAIN
@@ -1134,7 +1134,7 @@ static struct config_bool ConfigureNamesBool[] =
 		NULL, NULL, NULL
 	},
 	{
-		{"enable_parallel_append", PGC_USERSET, QUERY_TUNING_METHOD,
+		{"enable_parallel_append", PGC_SUSET, QUERY_TUNING_METHOD,
 			gettext_noop("Enables the planner's use of parallel append plans."),
 			NULL,
 			GUC_EXPLAIN
@@ -1144,7 +1144,7 @@ static struct config_bool ConfigureNamesBool[] =
 		NULL, NULL, NULL
 	},
 	{
-		{"enable_parallel_hash", PGC_USERSET, QUERY_TUNING_METHOD,
+		{"enable_parallel_hash", PGC_SUSET, QUERY_TUNING_METHOD,
 			gettext_noop("Enables the planner's use of parallel hash plans."),
 			NULL,
 			GUC_EXPLAIN
@@ -1154,7 +1154,7 @@ static struct config_bool ConfigureNamesBool[] =
 		NULL, NULL, NULL
 	},
 	{
-		{"enable_partition_pruning", PGC_USERSET, QUERY_TUNING_METHOD,
+		{"enable_partition_pruning", PGC_SUSET, QUERY_TUNING_METHOD,
 			gettext_noop("Enables plan-time and execution-time partition pruning."),
 			gettext_noop("Allows the query planner and executor to compare partition "
 						 "bounds to conditions in the query to determine which "
@@ -1166,7 +1166,7 @@ static struct config_bool ConfigureNamesBool[] =
 		NULL, NULL, NULL
 	},
 	{
-		{"enable_async_append", PGC_USERSET, QUERY_TUNING_METHOD,
+		{"enable_async_append", PGC_SUSET, QUERY_TUNING_METHOD,
 			gettext_noop("Enables the planner's use of async append plans."),
 			NULL,
 			GUC_EXPLAIN
@@ -1176,7 +1176,7 @@ static struct config_bool ConfigureNamesBool[] =
 		NULL, NULL, NULL
 	},
 	{
-		{"geqo", PGC_USERSET, QUERY_TUNING_GEQO,
+		{"geqo", PGC_SUSET, QUERY_TUNING_GEQO,
 			gettext_noop("Enables genetic query optimization."),
 			gettext_noop("This algorithm attempts to do planning without "
 						 "exhaustive searching."),
@@ -1398,7 +1398,7 @@ static struct config_bool ConfigureNamesBool[] =
 	},
 
 	{
-		{"exit_on_error", PGC_USERSET, ERROR_HANDLING_OPTIONS,
+		{"exit_on_error", PGC_SUSET, ERROR_HANDLING_OPTIONS,
 			gettext_noop("Terminate session on any error."),
 			NULL
 		},
@@ -1436,7 +1436,7 @@ static struct config_bool ConfigureNamesBool[] =
 		NULL, NULL, NULL
 	},
 	{
-		{"debug_print_parse", PGC_USERSET, LOGGING_WHAT,
+		{"debug_print_parse", PGC_SUSET, LOGGING_WHAT,
 			gettext_noop("Logs each query's parse tree."),
 			NULL
 		},
@@ -1445,7 +1445,7 @@ static struct config_bool ConfigureNamesBool[] =
 		NULL, NULL, NULL
 	},
 	{
-		{"debug_print_rewritten", PGC_USERSET, LOGGING_WHAT,
+		{"debug_print_rewritten", PGC_SUSET, LOGGING_WHAT,
 			gettext_noop("Logs each query's rewritten parse tree."),
 			NULL
 		},
@@ -1454,7 +1454,7 @@ static struct config_bool ConfigureNamesBool[] =
 		NULL, NULL, NULL
 	},
 	{
-		{"debug_print_plan", PGC_USERSET, LOGGING_WHAT,
+		{"debug_print_plan", PGC_SUSET, LOGGING_WHAT,
 			gettext_noop("Logs each query's execution plan."),
 			NULL
 		},
@@ -1463,7 +1463,7 @@ static struct config_bool ConfigureNamesBool[] =
 		NULL, NULL, NULL
 	},
 	{
-		{"debug_pretty_print", PGC_USERSET, LOGGING_WHAT,
+		{"debug_pretty_print", PGC_SUSET, LOGGING_WHAT,
 			gettext_noop("Indents parse and plan tree displays."),
 			NULL
 		},
@@ -1584,7 +1584,7 @@ static struct config_bool ConfigureNamesBool[] =
 	},
 
 	{
-		{"trace_notify", PGC_USERSET, DEVELOPER_OPTIONS,
+		{"trace_notify", PGC_SUSET, DEVELOPER_OPTIONS,
 			gettext_noop("Generates debugging output for LISTEN and NOTIFY."),
 			NULL,
 			GUC_NOT_IN_SAMPLE
@@ -1668,7 +1668,7 @@ static struct config_bool ConfigureNamesBool[] =
 		NULL, NULL, NULL
 	},
 	{
-		{"transform_null_equals", PGC_USERSET, COMPAT_OPTIONS_CLIENT,
+		{"transform_null_equals", PGC_SUSET, COMPAT_OPTIONS_CLIENT,
 			gettext_noop("Treats \"expr=NULL\" as \"expr IS NULL\"."),
 			gettext_noop("When turned on, expressions of the form expr = NULL "
 						 "(or NULL = expr) are treated as expr IS NULL, that is, they "
@@ -1690,7 +1690,7 @@ static struct config_bool ConfigureNamesBool[] =
 		NULL, NULL, NULL
 	},
 	{
-		{"default_transaction_read_only", PGC_USERSET, CLIENT_CONN_STATEMENT,
+		{"default_transaction_read_only", PGC_SUSET, CLIENT_CONN_STATEMENT,
 			gettext_noop("Sets the default read-only status of new transactions."),
 			NULL,
 			GUC_REPORT
@@ -1700,7 +1700,7 @@ static struct config_bool ConfigureNamesBool[] =
 		NULL, NULL, NULL
 	},
 	{
-		{"transaction_read_only", PGC_USERSET, CLIENT_CONN_STATEMENT,
+		{"transaction_read_only", PGC_SUSET, CLIENT_CONN_STATEMENT,
 			gettext_noop("Sets the current transaction's read-only status."),
 			NULL,
 			GUC_NO_RESET_ALL | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
@@ -1710,7 +1710,7 @@ static struct config_bool ConfigureNamesBool[] =
 		check_transaction_read_only, NULL, NULL
 	},
 	{
-		{"default_transaction_deferrable", PGC_USERSET, CLIENT_CONN_STATEMENT,
+		{"default_transaction_deferrable", PGC_SUSET, CLIENT_CONN_STATEMENT,
 			gettext_noop("Sets the default deferrable status of new transactions."),
 			NULL
 		},
@@ -1719,7 +1719,7 @@ static struct config_bool ConfigureNamesBool[] =
 		NULL, NULL, NULL
 	},
 	{
-		{"transaction_deferrable", PGC_USERSET, CLIENT_CONN_STATEMENT,
+		{"transaction_deferrable", PGC_SUSET, CLIENT_CONN_STATEMENT,
 			gettext_noop("Whether to defer a read-only serializable transaction until it can be executed with no possible serialization failures."),
 			NULL,
 			GUC_NO_RESET_ALL | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
@@ -1729,7 +1729,7 @@ static struct config_bool ConfigureNamesBool[] =
 		check_transaction_deferrable, NULL, NULL
 	},
 	{
-		{"row_security", PGC_USERSET, CLIENT_CONN_STATEMENT,
+		{"row_security", PGC_SUSET, CLIENT_CONN_STATEMENT,
 			gettext_noop("Enable row security."),
 			gettext_noop("When enabled, row security will be applied to all users.")
 		},
@@ -1738,7 +1738,7 @@ static struct config_bool ConfigureNamesBool[] =
 		NULL, NULL, NULL
 	},
 	{
-		{"check_function_bodies", PGC_USERSET, CLIENT_CONN_STATEMENT,
+		{"check_function_bodies", PGC_SUSET, CLIENT_CONN_STATEMENT,
 			gettext_noop("Check routine bodies during CREATE FUNCTION and CREATE PROCEDURE."),
 			NULL
 		},
@@ -1747,7 +1747,7 @@ static struct config_bool ConfigureNamesBool[] =
 		NULL, NULL, NULL
 	},
 	{
-		{"array_nulls", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
+		{"array_nulls", PGC_SUSET, COMPAT_OPTIONS_PREVIOUS,
 			gettext_noop("Enable input of NULL elements in arrays."),
 			gettext_noop("When turned on, unquoted NULL in an array input "
 						 "value means a null value; "
@@ -1764,7 +1764,7 @@ static struct config_bool ConfigureNamesBool[] =
 	 * avoid unnecessarily breaking older dump files.
 	 */
 	{
-		{"default_with_oids", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
+		{"default_with_oids", PGC_SUSET, COMPAT_OPTIONS_PREVIOUS,
 			gettext_noop("WITH OIDS is no longer supported; this can only be false."),
 			NULL,
 			GUC_NO_SHOW_ALL | GUC_NOT_IN_SAMPLE
@@ -1794,7 +1794,7 @@ static struct config_bool ConfigureNamesBool[] =
 
 #ifdef TRACE_SORT
 	{
-		{"trace_sort", PGC_USERSET, DEVELOPER_OPTIONS,
+		{"trace_sort", PGC_SUSET, DEVELOPER_OPTIONS,
 			gettext_noop("Emit information about resource usage in sorting."),
 			NULL,
 			GUC_NOT_IN_SAMPLE
@@ -1808,7 +1808,7 @@ static struct config_bool ConfigureNamesBool[] =
 #ifdef TRACE_SYNCSCAN
 	/* this is undocumented because not exposed in a standard build */
 	{
-		{"trace_syncscan", PGC_USERSET, DEVELOPER_OPTIONS,
+		{"trace_syncscan", PGC_SUSET, DEVELOPER_OPTIONS,
 			gettext_noop("Generate debugging output for synchronized scanning."),
 			NULL,
 			GUC_NOT_IN_SAMPLE
@@ -1823,7 +1823,7 @@ static struct config_bool ConfigureNamesBool[] =
 	/* this is undocumented because not exposed in a standard build */
 	{
 		{
-			"optimize_bounded_sort", PGC_USERSET, QUERY_TUNING_METHOD,
+			"optimize_bounded_sort", PGC_SUSET, QUERY_TUNING_METHOD,
 			gettext_noop("Enable bounded sorting using heap sort."),
 			NULL,
 			GUC_NOT_IN_SAMPLE | GUC_EXPLAIN
@@ -1869,7 +1869,7 @@ static struct config_bool ConfigureNamesBool[] =
 	},
 
 	{
-		{"escape_string_warning", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
+		{"escape_string_warning", PGC_SUSET, COMPAT_OPTIONS_PREVIOUS,
 			gettext_noop("Warn about backslash escapes in ordinary string literals."),
 			NULL
 		},
@@ -1879,7 +1879,7 @@ static struct config_bool ConfigureNamesBool[] =
 	},
 
 	{
-		{"standard_conforming_strings", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
+		{"standard_conforming_strings", PGC_SUSET, COMPAT_OPTIONS_PREVIOUS,
 			gettext_noop("Causes '...' strings to treat backslashes literally."),
 			NULL,
 			GUC_REPORT
@@ -1890,7 +1890,7 @@ static struct config_bool ConfigureNamesBool[] =
 	},
 
 	{
-		{"synchronize_seqscans", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
+		{"synchronize_seqscans", PGC_SUSET, COMPAT_OPTIONS_PREVIOUS,
 			gettext_noop("Enable synchronized sequential scans."),
 			NULL
 		},
@@ -1975,7 +1975,7 @@ static struct config_bool ConfigureNamesBool[] =
 	},
 
 	{
-		{"quote_all_identifiers", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
+		{"quote_all_identifiers", PGC_SUSET, COMPAT_OPTIONS_PREVIOUS,
 			gettext_noop("When generating SQL fragments, quote all identifiers."),
 			NULL,
 		},
@@ -2016,7 +2016,7 @@ static struct config_bool ConfigureNamesBool[] =
 	},
 
 	{
-		{"parallel_leader_participation", PGC_USERSET, RESOURCES_ASYNCHRONOUS,
+		{"parallel_leader_participation", PGC_SUSET, RESOURCES_ASYNCHRONOUS,
 			gettext_noop("Controls whether Gather and Gather Merge also run subplans."),
 			gettext_noop("Should gather nodes also run subplans or just gather tuples?"),
 			GUC_EXPLAIN
@@ -2027,7 +2027,7 @@ static struct config_bool ConfigureNamesBool[] =
 	},
 
 	{
-		{"jit", PGC_USERSET, QUERY_TUNING_OTHER,
+		{"jit", PGC_SUSET, QUERY_TUNING_OTHER,
 			gettext_noop("Allow JIT compilation."),
 			NULL,
 			GUC_EXPLAIN
@@ -2066,7 +2066,7 @@ static struct config_bool ConfigureNamesBool[] =
 	},
 
 	{
-		{"jit_expressions", PGC_USERSET, DEVELOPER_OPTIONS,
+		{"jit_expressions", PGC_SUSET, DEVELOPER_OPTIONS,
 			gettext_noop("Allow JIT compilation of expressions."),
 			NULL,
 			GUC_NOT_IN_SAMPLE
@@ -2094,7 +2094,7 @@ static struct config_bool ConfigureNamesBool[] =
 	},
 
 	{
-		{"jit_tuple_deforming", PGC_USERSET, DEVELOPER_OPTIONS,
+		{"jit_tuple_deforming", PGC_SUSET, DEVELOPER_OPTIONS,
 			gettext_noop("Allow JIT compilation of tuple deforming."),
 			NULL,
 			GUC_NOT_IN_SAMPLE
@@ -2154,7 +2154,7 @@ static struct config_int ConfigureNamesInt[] =
 		NULL, NULL, NULL
 	},
 	{
-		{"default_statistics_target", PGC_USERSET, QUERY_TUNING_OTHER,
+		{"default_statistics_target", PGC_SUSET, QUERY_TUNING_OTHER,
 			gettext_noop("Sets the default statistics target."),
 			gettext_noop("This applies to table columns that have not had a "
 						 "column-specific target set via ALTER TABLE SET STATISTICS.")
@@ -2164,7 +2164,7 @@ static struct config_int ConfigureNamesInt[] =
 		NULL, NULL, NULL
 	},
 	{
-		{"from_collapse_limit", PGC_USERSET, QUERY_TUNING_OTHER,
+		{"from_collapse_limit", PGC_SUSET, QUERY_TUNING_OTHER,
 			gettext_noop("Sets the FROM-list size beyond which subqueries "
 						 "are not collapsed."),
 			gettext_noop("The planner will merge subqueries into upper "
@@ -2177,7 +2177,7 @@ static struct config_int ConfigureNamesInt[] =
 		NULL, NULL, NULL
 	},
 	{
-		{"join_collapse_limit", PGC_USERSET, QUERY_TUNING_OTHER,
+		{"join_collapse_limit", PGC_SUSET, QUERY_TUNING_OTHER,
 			gettext_noop("Sets the FROM-list size beyond which JOIN "
 						 "constructs are not flattened."),
 			gettext_noop("The planner will flatten explicit JOIN "
@@ -2190,7 +2190,7 @@ static struct config_int ConfigureNamesInt[] =
 		NULL, NULL, NULL
 	},
 	{
-		{"geqo_threshold", PGC_USERSET, QUERY_TUNING_GEQO,
+		{"geqo_threshold", PGC_SUSET, QUERY_TUNING_GEQO,
 			gettext_noop("Sets the threshold of FROM items beyond which GEQO is used."),
 			NULL,
 			GUC_EXPLAIN
@@ -2200,7 +2200,7 @@ static struct config_int ConfigureNamesInt[] =
 		NULL, NULL, NULL
 	},
 	{
-		{"geqo_effort", PGC_USERSET, QUERY_TUNING_GEQO,
+		{"geqo_effort", PGC_SUSET, QUERY_TUNING_GEQO,
 			gettext_noop("GEQO: effort is used to set the default for other GEQO parameters."),
 			NULL,
 			GUC_EXPLAIN
@@ -2210,7 +2210,7 @@ static struct config_int ConfigureNamesInt[] =
 		NULL, NULL, NULL
 	},
 	{
-		{"geqo_pool_size", PGC_USERSET, QUERY_TUNING_GEQO,
+		{"geqo_pool_size", PGC_SUSET, QUERY_TUNING_GEQO,
 			gettext_noop("GEQO: number of individuals in the population."),
 			gettext_noop("Zero selects a suitable default value."),
 			GUC_EXPLAIN
@@ -2220,7 +2220,7 @@ static struct config_int ConfigureNamesInt[] =
 		NULL, NULL, NULL
 	},
 	{
-		{"geqo_generations", PGC_USERSET, QUERY_TUNING_GEQO,
+		{"geqo_generations", PGC_SUSET, QUERY_TUNING_GEQO,
 			gettext_noop("GEQO: number of iterations of the algorithm."),
 			gettext_noop("Zero selects a suitable default value."),
 			GUC_EXPLAIN
@@ -2367,7 +2367,7 @@ static struct config_int ConfigureNamesInt[] =
 	},
 
 	{
-		{"temp_buffers", PGC_USERSET, RESOURCES_MEM,
+		{"temp_buffers", PGC_SUSET, RESOURCES_MEM,
 			gettext_noop("Sets the maximum number of temporary buffers used by each session."),
 			NULL,
 			GUC_UNIT_BLOCKS | GUC_EXPLAIN
@@ -2432,7 +2432,7 @@ static struct config_int ConfigureNamesInt[] =
 	},
 
 	{
-		{"work_mem", PGC_USERSET, RESOURCES_MEM,
+		{"work_mem", PGC_SUSET, RESOURCES_MEM,
 			gettext_noop("Sets the maximum memory to be used for query workspaces."),
 			gettext_noop("This much memory can be used by each internal "
 						 "sort operation and hash table before switching to "
@@ -2445,7 +2445,7 @@ static struct config_int ConfigureNamesInt[] =
 	},
 
 	{
-		{"maintenance_work_mem", PGC_USERSET, RESOURCES_MEM,
+		{"maintenance_work_mem", PGC_SUSET, RESOURCES_MEM,
 			gettext_noop("Sets the maximum memory to be used for maintenance operations."),
 			gettext_noop("This includes operations such as VACUUM and CREATE INDEX."),
 			GUC_UNIT_KB
@@ -2456,7 +2456,7 @@ static struct config_int ConfigureNamesInt[] =
 	},
 
 	{
-		{"logical_decoding_work_mem", PGC_USERSET, RESOURCES_MEM,
+		{"logical_decoding_work_mem", PGC_SUSET, RESOURCES_MEM,
 			gettext_noop("Sets the maximum memory to be used for logical decoding."),
 			gettext_noop("This much memory can be used by each internal "
 						 "reorder buffer before spilling to disk."),
@@ -2495,7 +2495,7 @@ static struct config_int ConfigureNamesInt[] =
 	},
 
 	{
-		{"vacuum_cost_page_hit", PGC_USERSET, RESOURCES_VACUUM_DELAY,
+		{"vacuum_cost_page_hit", PGC_SUSET, RESOURCES_VACUUM_DELAY,
 			gettext_noop("Vacuum cost for a page found in the buffer cache."),
 			NULL
 		},
@@ -2505,7 +2505,7 @@ static struct config_int ConfigureNamesInt[] =
 	},
 
 	{
-		{"vacuum_cost_page_miss", PGC_USERSET, RESOURCES_VACUUM_DELAY,
+		{"vacuum_cost_page_miss", PGC_SUSET, RESOURCES_VACUUM_DELAY,
 			gettext_noop("Vacuum cost for a page not found in the buffer cache."),
 			NULL
 		},
@@ -2515,7 +2515,7 @@ static struct config_int ConfigureNamesInt[] =
 	},
 
 	{
-		{"vacuum_cost_page_dirty", PGC_USERSET, RESOURCES_VACUUM_DELAY,
+		{"vacuum_cost_page_dirty", PGC_SUSET, RESOURCES_VACUUM_DELAY,
 			gettext_noop("Vacuum cost for a page dirtied by vacuum."),
 			NULL
 		},
@@ -2525,7 +2525,7 @@ static struct config_int ConfigureNamesInt[] =
 	},
 
 	{
-		{"vacuum_cost_limit", PGC_USERSET, RESOURCES_VACUUM_DELAY,
+		{"vacuum_cost_limit", PGC_SUSET, RESOURCES_VACUUM_DELAY,
 			gettext_noop("Vacuum cost amount available before napping."),
 			NULL
 		},
@@ -2591,7 +2591,7 @@ static struct config_int ConfigureNamesInt[] =
 #endif
 
 	{
-		{"statement_timeout", PGC_USERSET, CLIENT_CONN_STATEMENT,
+		{"statement_timeout", PGC_SUSET, CLIENT_CONN_STATEMENT,
 			gettext_noop("Sets the maximum allowed duration of any statement."),
 			gettext_noop("A value of 0 turns off the timeout."),
 			GUC_UNIT_MS
@@ -2602,7 +2602,7 @@ static struct config_int ConfigureNamesInt[] =
 	},
 
 	{
-		{"lock_timeout", PGC_USERSET, CLIENT_CONN_STATEMENT,
+		{"lock_timeout", PGC_SUSET, CLIENT_CONN_STATEMENT,
 			gettext_noop("Sets the maximum allowed duration of any wait for a lock."),
 			gettext_noop("A value of 0 turns off the timeout."),
 			GUC_UNIT_MS
@@ -2613,7 +2613,7 @@ static struct config_int ConfigureNamesInt[] =
 	},
 
 	{
-		{"idle_in_transaction_session_timeout", PGC_USERSET, CLIENT_CONN_STATEMENT,
+		{"idle_in_transaction_session_timeout", PGC_SUSET, CLIENT_CONN_STATEMENT,
 			gettext_noop("Sets the maximum allowed idle time between queries, when in a transaction."),
 			gettext_noop("A value of 0 turns off the timeout."),
 			GUC_UNIT_MS
@@ -2624,7 +2624,7 @@ static struct config_int ConfigureNamesInt[] =
 	},
 
 	{
-		{"idle_session_timeout", PGC_USERSET, CLIENT_CONN_STATEMENT,
+		{"idle_session_timeout", PGC_SUSET, CLIENT_CONN_STATEMENT,
 			gettext_noop("Sets the maximum allowed idle time between queries, when not in a transaction."),
 			gettext_noop("A value of 0 turns off the timeout."),
 			GUC_UNIT_MS
@@ -2635,7 +2635,7 @@ static struct config_int ConfigureNamesInt[] =
 	},
 
 	{
-		{"vacuum_freeze_min_age", PGC_USERSET, CLIENT_CONN_STATEMENT,
+		{"vacuum_freeze_min_age", PGC_SUSET, CLIENT_CONN_STATEMENT,
 			gettext_noop("Minimum age at which VACUUM should freeze a table row."),
 			NULL
 		},
@@ -2645,7 +2645,7 @@ static struct config_int ConfigureNamesInt[] =
 	},
 
 	{
-		{"vacuum_freeze_table_age", PGC_USERSET, CLIENT_CONN_STATEMENT,
+		{"vacuum_freeze_table_age", PGC_SUSET, CLIENT_CONN_STATEMENT,
 			gettext_noop("Age at which VACUUM should scan whole table to freeze tuples."),
 			NULL
 		},
@@ -2655,7 +2655,7 @@ static struct config_int ConfigureNamesInt[] =
 	},
 
 	{
-		{"vacuum_multixact_freeze_min_age", PGC_USERSET, CLIENT_CONN_STATEMENT,
+		{"vacuum_multixact_freeze_min_age", PGC_SUSET, CLIENT_CONN_STATEMENT,
 			gettext_noop("Minimum age at which VACUUM should freeze a MultiXactId in a table row."),
 			NULL
 		},
@@ -2665,7 +2665,7 @@ static struct config_int ConfigureNamesInt[] =
 	},
 
 	{
-		{"vacuum_multixact_freeze_table_age", PGC_USERSET, CLIENT_CONN_STATEMENT,
+		{"vacuum_multixact_freeze_table_age", PGC_SUSET, CLIENT_CONN_STATEMENT,
 			gettext_noop("Multixact age at which VACUUM should scan whole table to freeze tuples."),
 			NULL
 		},
@@ -2684,7 +2684,7 @@ static struct config_int ConfigureNamesInt[] =
 		NULL, NULL, NULL
 	},
 	{
-		{"vacuum_failsafe_age", PGC_USERSET, CLIENT_CONN_STATEMENT,
+		{"vacuum_failsafe_age", PGC_SUSET, CLIENT_CONN_STATEMENT,
 			gettext_noop("Age at which VACUUM should trigger failsafe to avoid a wraparound outage."),
 			NULL
 		},
@@ -2693,7 +2693,7 @@ static struct config_int ConfigureNamesInt[] =
 		NULL, NULL, NULL
 	},
 	{
-		{"vacuum_multixact_failsafe_age", PGC_USERSET, CLIENT_CONN_STATEMENT,
+		{"vacuum_multixact_failsafe_age", PGC_SUSET, CLIENT_CONN_STATEMENT,
 			gettext_noop("Multixact age at which VACUUM should trigger failsafe to avoid a wraparound outage."),
 			NULL
 		},
@@ -2881,7 +2881,7 @@ static struct config_int ConfigureNamesInt[] =
 	},
 
 	{
-		{"wal_skip_threshold", PGC_USERSET, WAL_SETTINGS,
+		{"wal_skip_threshold", PGC_SUSET, WAL_SETTINGS,
 			gettext_noop("Minimum size of new file to fsync instead of writing WAL."),
 			NULL,
 			GUC_UNIT_KB
@@ -2926,7 +2926,7 @@ static struct config_int ConfigureNamesInt[] =
 	},
 
 	{
-		{"wal_sender_timeout", PGC_USERSET, REPLICATION_SENDING,
+		{"wal_sender_timeout", PGC_SUSET, REPLICATION_SENDING,
 			gettext_noop("Sets the maximum time to wait for WAL replication."),
 			NULL,
 			GUC_UNIT_MS
@@ -2949,7 +2949,7 @@ static struct config_int ConfigureNamesInt[] =
 	},
 
 	{
-		{"commit_siblings", PGC_USERSET, WAL_SETTINGS,
+		{"commit_siblings", PGC_SUSET, WAL_SETTINGS,
 			gettext_noop("Sets the minimum number of concurrent open transactions "
 						 "required before performing commit_delay."),
 			NULL
@@ -2960,7 +2960,7 @@ static struct config_int ConfigureNamesInt[] =
 	},
 
 	{
-		{"extra_float_digits", PGC_USERSET, CLIENT_CONN_LOCALE,
+		{"extra_float_digits", PGC_SUSET, CLIENT_CONN_LOCALE,
 			gettext_noop("Sets the number of digits displayed for floating-point values."),
 			gettext_noop("This affects real, double precision, and geometric data types. "
 						 "A zero or negative parameter value is added to the standard "
@@ -3022,7 +3022,7 @@ static struct config_int ConfigureNamesInt[] =
 	},
 
 	{
-		{"log_parameter_max_length_on_error", PGC_USERSET, LOGGING_WHAT,
+		{"log_parameter_max_length_on_error", PGC_SUSET, LOGGING_WHAT,
 			gettext_noop("Sets the maximum length in bytes of data logged for bind "
 						 "parameter values when logging statements, on error."),
 			gettext_noop("-1 to print values in full."),
@@ -3067,7 +3067,7 @@ static struct config_int ConfigureNamesInt[] =
 
 	{
 		{"effective_io_concurrency",
-			PGC_USERSET,
+			PGC_SUSET,
 			RESOURCES_ASYNCHRONOUS,
 			gettext_noop("Number of simultaneous requests that can be handled efficiently by the disk subsystem."),
 			NULL,
@@ -3085,7 +3085,7 @@ static struct config_int ConfigureNamesInt[] =
 
 	{
 		{"maintenance_io_concurrency",
-			PGC_USERSET,
+			PGC_SUSET,
 			RESOURCES_ASYNCHRONOUS,
 			gettext_noop("A variant of effective_io_concurrency that is used for maintenance work."),
 			NULL,
@@ -3102,7 +3102,7 @@ static struct config_int ConfigureNamesInt[] =
 	},
 
 	{
-		{"backend_flush_after", PGC_USERSET, RESOURCES_ASYNCHRONOUS,
+		{"backend_flush_after", PGC_SUSET, RESOURCES_ASYNCHRONOUS,
 			gettext_noop("Number of pages after which previously performed writes are flushed to disk."),
 			NULL,
 			GUC_UNIT_BLOCKS
@@ -3334,7 +3334,7 @@ static struct config_int ConfigureNamesInt[] =
 	},
 
 	{
-		{"max_parallel_maintenance_workers", PGC_USERSET, RESOURCES_ASYNCHRONOUS,
+		{"max_parallel_maintenance_workers", PGC_SUSET, RESOURCES_ASYNCHRONOUS,
 			gettext_noop("Sets the maximum number of parallel processes per maintenance operation."),
 			NULL
 		},
@@ -3344,7 +3344,7 @@ static struct config_int ConfigureNamesInt[] =
 	},
 
 	{
-		{"max_parallel_workers_per_gather", PGC_USERSET, RESOURCES_ASYNCHRONOUS,
+		{"max_parallel_workers_per_gather", PGC_SUSET, RESOURCES_ASYNCHRONOUS,
 			gettext_noop("Sets the maximum number of parallel processes per executor node."),
 			NULL,
 			GUC_EXPLAIN
@@ -3355,7 +3355,7 @@ static struct config_int ConfigureNamesInt[] =
 	},
 
 	{
-		{"max_parallel_workers", PGC_USERSET, RESOURCES_ASYNCHRONOUS,
+		{"max_parallel_workers", PGC_SUSET, RESOURCES_ASYNCHRONOUS,
 			gettext_noop("Sets the maximum number of parallel workers that can be active at one time."),
 			NULL,
 			GUC_EXPLAIN
@@ -3388,7 +3388,7 @@ static struct config_int ConfigureNamesInt[] =
 	},
 
 	{
-		{"tcp_keepalives_idle", PGC_USERSET, CONN_AUTH_SETTINGS,
+		{"tcp_keepalives_idle", PGC_SUSET, CONN_AUTH_SETTINGS,
 			gettext_noop("Time between issuing TCP keepalives."),
 			gettext_noop("A value of 0 uses the system default."),
 			GUC_UNIT_S
@@ -3399,7 +3399,7 @@ static struct config_int ConfigureNamesInt[] =
 	},
 
 	{
-		{"tcp_keepalives_interval", PGC_USERSET, CONN_AUTH_SETTINGS,
+		{"tcp_keepalives_interval", PGC_SUSET, CONN_AUTH_SETTINGS,
 			gettext_noop("Time between TCP keepalive retransmits."),
 			gettext_noop("A value of 0 uses the system default."),
 			GUC_UNIT_S
@@ -3410,7 +3410,7 @@ static struct config_int ConfigureNamesInt[] =
 	},
 
 	{
-		{"ssl_renegotiation_limit", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
+		{"ssl_renegotiation_limit", PGC_SUSET, COMPAT_OPTIONS_PREVIOUS,
 			gettext_noop("SSL renegotiation is no longer supported; this can only be 0."),
 			NULL,
 			GUC_NO_SHOW_ALL | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE,
@@ -3421,7 +3421,7 @@ static struct config_int ConfigureNamesInt[] =
 	},
 
 	{
-		{"tcp_keepalives_count", PGC_USERSET, CONN_AUTH_SETTINGS,
+		{"tcp_keepalives_count", PGC_SUSET, CONN_AUTH_SETTINGS,
 			gettext_noop("Maximum number of TCP keepalive retransmits."),
 			gettext_noop("This controls the number of consecutive keepalive retransmits that can be "
 						 "lost before a connection is considered dead. A value of 0 uses the "
@@ -3433,7 +3433,7 @@ static struct config_int ConfigureNamesInt[] =
 	},
 
 	{
-		{"gin_fuzzy_search_limit", PGC_USERSET, CLIENT_CONN_OTHER,
+		{"gin_fuzzy_search_limit", PGC_SUSET, CLIENT_CONN_OTHER,
 			gettext_noop("Sets the maximum allowed result for exact search by GIN."),
 			NULL,
 			0
@@ -3444,7 +3444,7 @@ static struct config_int ConfigureNamesInt[] =
 	},
 
 	{
-		{"effective_cache_size", PGC_USERSET, QUERY_TUNING_COST,
+		{"effective_cache_size", PGC_SUSET, QUERY_TUNING_COST,
 			gettext_noop("Sets the planner's assumption about the total size of the data caches."),
 			gettext_noop("That is, the total size of the caches (kernel cache and shared buffers) used for PostgreSQL data files. "
 						 "This is measured in disk pages, which are normally 8 kB each."),
@@ -3456,7 +3456,7 @@ static struct config_int ConfigureNamesInt[] =
 	},
 
 	{
-		{"min_parallel_table_scan_size", PGC_USERSET, QUERY_TUNING_COST,
+		{"min_parallel_table_scan_size", PGC_SUSET, QUERY_TUNING_COST,
 			gettext_noop("Sets the minimum amount of table data for a parallel scan."),
 			gettext_noop("If the planner estimates that it will read a number of table pages too small to reach this limit, a parallel scan will not be considered."),
 			GUC_UNIT_BLOCKS | GUC_EXPLAIN,
@@ -3467,7 +3467,7 @@ static struct config_int ConfigureNamesInt[] =
 	},
 
 	{
-		{"min_parallel_index_scan_size", PGC_USERSET, QUERY_TUNING_COST,
+		{"min_parallel_index_scan_size", PGC_SUSET, QUERY_TUNING_COST,
 			gettext_noop("Sets the minimum amount of index data for a parallel scan."),
 			gettext_noop("If the planner estimates that it will read a number of index pages too small to reach this limit, a parallel scan will not be considered."),
 			GUC_UNIT_BLOCKS | GUC_EXPLAIN,
@@ -3512,7 +3512,7 @@ static struct config_int ConfigureNamesInt[] =
 	},
 
 	{
-		{"gin_pending_list_limit", PGC_USERSET, CLIENT_CONN_STATEMENT,
+		{"gin_pending_list_limit", PGC_SUSET, CLIENT_CONN_STATEMENT,
 			gettext_noop("Sets the maximum size of the pending list for GIN index."),
 			NULL,
 			GUC_UNIT_KB
@@ -3523,7 +3523,7 @@ static struct config_int ConfigureNamesInt[] =
 	},
 
 	{
-		{"tcp_user_timeout", PGC_USERSET, CONN_AUTH_SETTINGS,
+		{"tcp_user_timeout", PGC_SUSET, CONN_AUTH_SETTINGS,
 			gettext_noop("TCP user timeout."),
 			gettext_noop("A value of 0 uses the system default."),
 			GUC_UNIT_MS
@@ -3568,7 +3568,7 @@ static struct config_int ConfigureNamesInt[] =
 	},
 
 	{
-		{"client_connection_check_interval", PGC_USERSET, CONN_AUTH_SETTINGS,
+		{"client_connection_check_interval", PGC_SUSET, CONN_AUTH_SETTINGS,
 			gettext_noop("Sets the time interval between checks for disconnection while running queries."),
 			NULL,
 			GUC_UNIT_MS
@@ -3600,7 +3600,7 @@ static struct config_int ConfigureNamesInt[] =
 static struct config_real ConfigureNamesReal[] =
 {
 	{
-		{"seq_page_cost", PGC_USERSET, QUERY_TUNING_COST,
+		{"seq_page_cost", PGC_SUSET, QUERY_TUNING_COST,
 			gettext_noop("Sets the planner's estimate of the cost of a "
 						 "sequentially fetched disk page."),
 			NULL,
@@ -3611,7 +3611,7 @@ static struct config_real ConfigureNamesReal[] =
 		NULL, NULL, NULL
 	},
 	{
-		{"random_page_cost", PGC_USERSET, QUERY_TUNING_COST,
+		{"random_page_cost", PGC_SUSET, QUERY_TUNING_COST,
 			gettext_noop("Sets the planner's estimate of the cost of a "
 						 "nonsequentially fetched disk page."),
 			NULL,
@@ -3622,7 +3622,7 @@ static struct config_real ConfigureNamesReal[] =
 		NULL, NULL, NULL
 	},
 	{
-		{"cpu_tuple_cost", PGC_USERSET, QUERY_TUNING_COST,
+		{"cpu_tuple_cost", PGC_SUSET, QUERY_TUNING_COST,
 			gettext_noop("Sets the planner's estimate of the cost of "
 						 "processing each tuple (row)."),
 			NULL,
@@ -3633,7 +3633,7 @@ static struct config_real ConfigureNamesReal[] =
 		NULL, NULL, NULL
 	},
 	{
-		{"cpu_index_tuple_cost", PGC_USERSET, QUERY_TUNING_COST,
+		{"cpu_index_tuple_cost", PGC_SUSET, QUERY_TUNING_COST,
 			gettext_noop("Sets the planner's estimate of the cost of "
 						 "processing each index entry during an index scan."),
 			NULL,
@@ -3644,7 +3644,7 @@ static struct config_real ConfigureNamesReal[] =
 		NULL, NULL, NULL
 	},
 	{
-		{"cpu_operator_cost", PGC_USERSET, QUERY_TUNING_COST,
+		{"cpu_operator_cost", PGC_SUSET, QUERY_TUNING_COST,
 			gettext_noop("Sets the planner's estimate of the cost of "
 						 "processing each operator or function call."),
 			NULL,
@@ -3655,7 +3655,7 @@ static struct config_real ConfigureNamesReal[] =
 		NULL, NULL, NULL
 	},
 	{
-		{"parallel_tuple_cost", PGC_USERSET, QUERY_TUNING_COST,
+		{"parallel_tuple_cost", PGC_SUSET, QUERY_TUNING_COST,
 			gettext_noop("Sets the planner's estimate of the cost of "
 						 "passing each tuple (row) from worker to leader backend."),
 			NULL,
@@ -3666,7 +3666,7 @@ static struct config_real ConfigureNamesReal[] =
 		NULL, NULL, NULL
 	},
 	{
-		{"parallel_setup_cost", PGC_USERSET, QUERY_TUNING_COST,
+		{"parallel_setup_cost", PGC_SUSET, QUERY_TUNING_COST,
 			gettext_noop("Sets the planner's estimate of the cost of "
 						 "starting up worker processes for parallel query."),
 			NULL,
@@ -3678,7 +3678,7 @@ static struct config_real ConfigureNamesReal[] =
 	},
 
 	{
-		{"jit_above_cost", PGC_USERSET, QUERY_TUNING_COST,
+		{"jit_above_cost", PGC_SUSET, QUERY_TUNING_COST,
 			gettext_noop("Perform JIT compilation if query is more expensive."),
 			gettext_noop("-1 disables JIT compilation."),
 			GUC_EXPLAIN
@@ -3689,7 +3689,7 @@ static struct config_real ConfigureNamesReal[] =
 	},
 
 	{
-		{"jit_optimize_above_cost", PGC_USERSET, QUERY_TUNING_COST,
+		{"jit_optimize_above_cost", PGC_SUSET, QUERY_TUNING_COST,
 			gettext_noop("Optimize JIT-compiled functions if query is more expensive."),
 			gettext_noop("-1 disables optimization."),
 			GUC_EXPLAIN
@@ -3700,7 +3700,7 @@ static struct config_real ConfigureNamesReal[] =
 	},
 
 	{
-		{"jit_inline_above_cost", PGC_USERSET, QUERY_TUNING_COST,
+		{"jit_inline_above_cost", PGC_SUSET, QUERY_TUNING_COST,
 			gettext_noop("Perform JIT inlining if query is more expensive."),
 			gettext_noop("-1 disables inlining."),
 			GUC_EXPLAIN
@@ -3711,7 +3711,7 @@ static struct config_real ConfigureNamesReal[] =
 	},
 
 	{
-		{"cursor_tuple_fraction", PGC_USERSET, QUERY_TUNING_OTHER,
+		{"cursor_tuple_fraction", PGC_SUSET, QUERY_TUNING_OTHER,
 			gettext_noop("Sets the planner's estimate of the fraction of "
 						 "a cursor's rows that will be retrieved."),
 			NULL,
@@ -3723,7 +3723,7 @@ static struct config_real ConfigureNamesReal[] =
 	},
 
 	{
-		{"geqo_selection_bias", PGC_USERSET, QUERY_TUNING_GEQO,
+		{"geqo_selection_bias", PGC_SUSET, QUERY_TUNING_GEQO,
 			gettext_noop("GEQO: selective pressure within the population."),
 			NULL,
 			GUC_EXPLAIN
@@ -3734,7 +3734,7 @@ static struct config_real ConfigureNamesReal[] =
 		NULL, NULL, NULL
 	},
 	{
-		{"geqo_seed", PGC_USERSET, QUERY_TUNING_GEQO,
+		{"geqo_seed", PGC_SUSET, QUERY_TUNING_GEQO,
 			gettext_noop("GEQO: seed for random path selection."),
 			NULL,
 			GUC_EXPLAIN
@@ -3745,7 +3745,7 @@ static struct config_real ConfigureNamesReal[] =
 	},
 
 	{
-		{"hash_mem_multiplier", PGC_USERSET, RESOURCES_MEM,
+		{"hash_mem_multiplier", PGC_SUSET, RESOURCES_MEM,
 			gettext_noop("Multiple of work_mem to use for hash tables."),
 			NULL,
 			GUC_EXPLAIN
@@ -3766,7 +3766,7 @@ static struct config_real ConfigureNamesReal[] =
 	},
 
 	{
-		{"seed", PGC_USERSET, UNGROUPED,
+		{"seed", PGC_SUSET, UNGROUPED,
 			gettext_noop("Sets the seed for random-number generation."),
 			NULL,
 			GUC_NO_SHOW_ALL | GUC_NO_RESET_ALL | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
@@ -3777,7 +3777,7 @@ static struct config_real ConfigureNamesReal[] =
 	},
 
 	{
-		{"vacuum_cost_delay", PGC_USERSET, RESOURCES_VACUUM_DELAY,
+		{"vacuum_cost_delay", PGC_SUSET, RESOURCES_VACUUM_DELAY,
 			gettext_noop("Vacuum cost delay in milliseconds."),
 			NULL,
 			GUC_UNIT_MS
@@ -4027,7 +4027,7 @@ static struct config_string ConfigureNamesString[] =
 	},
 
 	{
-		{"DateStyle", PGC_USERSET, CLIENT_CONN_LOCALE,
+		{"DateStyle", PGC_SUSET, CLIENT_CONN_LOCALE,
 			gettext_noop("Sets the display format for date and time values."),
 			gettext_noop("Also controls interpretation of ambiguous "
 						 "date inputs."),
@@ -4039,7 +4039,7 @@ static struct config_string ConfigureNamesString[] =
 	},
 
 	{
-		{"default_table_access_method", PGC_USERSET, CLIENT_CONN_STATEMENT,
+		{"default_table_access_method", PGC_SUSET, CLIENT_CONN_STATEMENT,
 			gettext_noop("Sets the default table access method for new tables."),
 			NULL,
 			GUC_IS_NAME
@@ -4050,7 +4050,7 @@ static struct config_string ConfigureNamesString[] =
 	},
 
 	{
-		{"default_tablespace", PGC_USERSET, CLIENT_CONN_STATEMENT,
+		{"default_tablespace", PGC_SUSET, CLIENT_CONN_STATEMENT,
 			gettext_noop("Sets the default tablespace to create tables and indexes in."),
 			gettext_noop("An empty string selects the database's default tablespace."),
 			GUC_IS_NAME
@@ -4061,7 +4061,7 @@ static struct config_string ConfigureNamesString[] =
 	},
 
 	{
-		{"temp_tablespaces", PGC_USERSET, CLIENT_CONN_STATEMENT,
+		{"temp_tablespaces", PGC_SUSET, CLIENT_CONN_STATEMENT,
 			gettext_noop("Sets the tablespace(s) to use for temporary tables and sort files."),
 			NULL,
 			GUC_LIST_INPUT | GUC_LIST_QUOTE
@@ -4141,7 +4141,7 @@ static struct config_string ConfigureNamesString[] =
 	},
 
 	{
-		{"lc_monetary", PGC_USERSET, CLIENT_CONN_LOCALE,
+		{"lc_monetary", PGC_SUSET, CLIENT_CONN_LOCALE,
 			gettext_noop("Sets the locale for formatting monetary amounts."),
 			NULL
 		},
@@ -4151,7 +4151,7 @@ static struct config_string ConfigureNamesString[] =
 	},
 
 	{
-		{"lc_numeric", PGC_USERSET, CLIENT_CONN_LOCALE,
+		{"lc_numeric", PGC_SUSET, CLIENT_CONN_LOCALE,
 			gettext_noop("Sets the locale for formatting numbers."),
 			NULL
 		},
@@ -4161,7 +4161,7 @@ static struct config_string ConfigureNamesString[] =
 	},
 
 	{
-		{"lc_time", PGC_USERSET, CLIENT_CONN_LOCALE,
+		{"lc_time", PGC_SUSET, CLIENT_CONN_LOCALE,
 			gettext_noop("Sets the locale for formatting date and time values."),
 			NULL
 		},
@@ -4193,7 +4193,7 @@ static struct config_string ConfigureNamesString[] =
 	},
 
 	{
-		{"local_preload_libraries", PGC_USERSET, CLIENT_CONN_PRELOAD,
+		{"local_preload_libraries", PGC_SUSET, CLIENT_CONN_PRELOAD,
 			gettext_noop("Lists unprivileged shared libraries to preload into each backend."),
 			NULL,
 			GUC_LIST_INPUT | GUC_LIST_QUOTE
@@ -4204,7 +4204,7 @@ static struct config_string ConfigureNamesString[] =
 	},
 
 	{
-		{"search_path", PGC_USERSET, CLIENT_CONN_STATEMENT,
+		{"search_path", PGC_SUSET, CLIENT_CONN_STATEMENT,
 			gettext_noop("Sets the schema search order for names that are not schema-qualified."),
 			NULL,
 			GUC_LIST_INPUT | GUC_LIST_QUOTE | GUC_EXPLAIN
@@ -4240,7 +4240,7 @@ static struct config_string ConfigureNamesString[] =
 
 	{
 		/* Not for general use --- used by SET ROLE */
-		{"role", PGC_USERSET, UNGROUPED,
+		{"role", PGC_SUSET, UNGROUPED,
 			gettext_noop("Sets the current role."),
 			NULL,
 			GUC_IS_NAME | GUC_NO_SHOW_ALL | GUC_NO_RESET_ALL | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE | GUC_NOT_WHILE_SEC_REST
@@ -4319,7 +4319,7 @@ static struct config_string ConfigureNamesString[] =
 	},
 
 	{
-		{"TimeZone", PGC_USERSET, CLIENT_CONN_LOCALE,
+		{"TimeZone", PGC_SUSET, CLIENT_CONN_LOCALE,
 			gettext_noop("Sets the time zone for displaying and interpreting time stamps."),
 			NULL,
 			GUC_REPORT
@@ -4329,7 +4329,7 @@ static struct config_string ConfigureNamesString[] =
 		check_timezone, assign_timezone, show_timezone
 	},
 	{
-		{"timezone_abbreviations", PGC_USERSET, CLIENT_CONN_LOCALE,
+		{"timezone_abbreviations", PGC_SUSET, CLIENT_CONN_LOCALE,
 			gettext_noop("Selects a file of time zone abbreviations."),
 			NULL
 		},
@@ -4522,7 +4522,7 @@ static struct config_string ConfigureNamesString[] =
 	},
 
 	{
-		{"default_text_search_config", PGC_USERSET, CLIENT_CONN_LOCALE,
+		{"default_text_search_config", PGC_SUSET, CLIENT_CONN_LOCALE,
 			gettext_noop("Sets default text search configuration."),
 			NULL
 		},
@@ -4584,7 +4584,7 @@ static struct config_string ConfigureNamesString[] =
 	},
 
 	{
-		{"application_name", PGC_USERSET, LOGGING_WHAT,
+		{"application_name", PGC_SUSET, LOGGING_WHAT,
 			gettext_noop("Sets the application name to be reported in statistics and logs."),
 			NULL,
 			GUC_IS_NAME | GUC_REPORT | GUC_NOT_IN_SAMPLE
@@ -4648,7 +4648,7 @@ static struct config_string ConfigureNamesString[] =
 static struct config_enum ConfigureNamesEnum[] =
 {
 	{
-		{"backslash_quote", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
+		{"backslash_quote", PGC_SUSET, COMPAT_OPTIONS_PREVIOUS,
 			gettext_noop("Sets whether \"\\'\" is allowed in string literals."),
 			NULL
 		},
@@ -4658,7 +4658,7 @@ static struct config_enum ConfigureNamesEnum[] =
 	},
 
 	{
-		{"bytea_output", PGC_USERSET, CLIENT_CONN_STATEMENT,
+		{"bytea_output", PGC_SUSET, CLIENT_CONN_STATEMENT,
 			gettext_noop("Sets the output format for bytea."),
 			NULL
 		},
@@ -4668,7 +4668,7 @@ static struct config_enum ConfigureNamesEnum[] =
 	},
 
 	{
-		{"client_min_messages", PGC_USERSET, CLIENT_CONN_STATEMENT,
+		{"client_min_messages", PGC_SUSET, CLIENT_CONN_STATEMENT,
 			gettext_noop("Sets the message levels that are sent to the client."),
 			gettext_noop("Each level includes all the levels that follow it. The later"
 						 " the level, the fewer messages are sent.")
@@ -4689,7 +4689,7 @@ static struct config_enum ConfigureNamesEnum[] =
 	},
 
 	{
-		{"constraint_exclusion", PGC_USERSET, QUERY_TUNING_OTHER,
+		{"constraint_exclusion", PGC_SUSET, QUERY_TUNING_OTHER,
 			gettext_noop("Enables the planner to use constraints to optimize queries."),
 			gettext_noop("Table scans will be skipped if their constraints"
 						 " guarantee that no rows match the query."),
@@ -4701,7 +4701,7 @@ static struct config_enum ConfigureNamesEnum[] =
 	},
 
 	{
-		{"default_toast_compression", PGC_USERSET, CLIENT_CONN_STATEMENT,
+		{"default_toast_compression", PGC_SUSET, CLIENT_CONN_STATEMENT,
 			gettext_noop("Sets the default compression method for compressible values."),
 			NULL
 		},
@@ -4712,7 +4712,7 @@ static struct config_enum ConfigureNamesEnum[] =
 	},
 
 	{
-		{"default_transaction_isolation", PGC_USERSET, CLIENT_CONN_STATEMENT,
+		{"default_transaction_isolation", PGC_SUSET, CLIENT_CONN_STATEMENT,
 			gettext_noop("Sets the transaction isolation level of each new transaction."),
 			NULL
 		},
@@ -4722,7 +4722,7 @@ static struct config_enum ConfigureNamesEnum[] =
 	},
 
 	{
-		{"transaction_isolation", PGC_USERSET, CLIENT_CONN_STATEMENT,
+		{"transaction_isolation", PGC_SUSET, CLIENT_CONN_STATEMENT,
 			gettext_noop("Sets the current transaction's isolation level."),
 			NULL,
 			GUC_NO_RESET_ALL | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
@@ -4733,7 +4733,7 @@ static struct config_enum ConfigureNamesEnum[] =
 	},
 
 	{
-		{"IntervalStyle", PGC_USERSET, CLIENT_CONN_LOCALE,
+		{"IntervalStyle", PGC_SUSET, CLIENT_CONN_LOCALE,
 			gettext_noop("Sets the display format for interval values."),
 			NULL,
 			GUC_REPORT
@@ -4811,7 +4811,7 @@ static struct config_enum ConfigureNamesEnum[] =
 	},
 
 	{
-		{"synchronous_commit", PGC_USERSET, WAL_SETTINGS,
+		{"synchronous_commit", PGC_SUSET, WAL_SETTINGS,
 			gettext_noop("Sets the current transaction's synchronization level."),
 			NULL
 		},
@@ -4918,7 +4918,7 @@ static struct config_enum ConfigureNamesEnum[] =
 	},
 
 	{
-		{"xmlbinary", PGC_USERSET, CLIENT_CONN_STATEMENT,
+		{"xmlbinary", PGC_SUSET, CLIENT_CONN_STATEMENT,
 			gettext_noop("Sets how binary values are to be encoded in XML."),
 			NULL
 		},
@@ -4928,7 +4928,7 @@ static struct config_enum ConfigureNamesEnum[] =
 	},
 
 	{
-		{"xmloption", PGC_USERSET, CLIENT_CONN_STATEMENT,
+		{"xmloption", PGC_SUSET, CLIENT_CONN_STATEMENT,
 			gettext_noop("Sets whether XML data in implicit parsing and serialization "
 						 "operations is to be considered as documents or content fragments."),
 			NULL
@@ -4949,7 +4949,7 @@ static struct config_enum ConfigureNamesEnum[] =
 	},
 
 	{
-		{"force_parallel_mode", PGC_USERSET, DEVELOPER_OPTIONS,
+		{"force_parallel_mode", PGC_SUSET, DEVELOPER_OPTIONS,
 			gettext_noop("Forces use of parallel query facilities."),
 			gettext_noop("If possible, run query using a parallel worker and with parallel restrictions."),
 			GUC_NOT_IN_SAMPLE | GUC_EXPLAIN
@@ -4960,7 +4960,7 @@ static struct config_enum ConfigureNamesEnum[] =
 	},
 
 	{
-		{"password_encryption", PGC_USERSET, CONN_AUTH_AUTH,
+		{"password_encryption", PGC_SUSET, CONN_AUTH_AUTH,
 			gettext_noop("Chooses the algorithm for encrypting passwords."),
 			NULL
 		},
@@ -4970,7 +4970,7 @@ static struct config_enum ConfigureNamesEnum[] =
 	},
 
 	{
-		{"plan_cache_mode", PGC_USERSET, QUERY_TUNING_OTHER,
+		{"plan_cache_mode", PGC_SUSET, QUERY_TUNING_OTHER,
 			gettext_noop("Controls the planner's selection of custom or generic plan."),
 			gettext_noop("Prepared statements can have custom and generic plans, and the planner "
 						 "will attempt to choose which is better.  This can be set to override "
@@ -5029,6 +5029,10 @@ static struct config_enum ConfigureNamesEnum[] =
  * the following mappings to any unrecognized name.  Note that an old name
  * should be mapped to a new one only if the new variable has very similar
  * semantics to the old.
+ *
+ * If you deprecate a name in favor of a new spelling, be sure to consider what
+ * upgrade support will be needed, if any, for existing pg_setting_acl
+ * entries.
  */
 static const char *const map_old_guc_names[] = {
 	"sort_mem", "work_mem",
@@ -5428,25 +5432,29 @@ add_guc_variable(struct config_generic *var, int elevel)
 }
 
 /*
- * Decide whether a proposed custom variable name is allowed.
+ * Decide whether a proposed variable name is allowed.
  *
- * It must be two or more identifiers separated by dots, where the rules
- * for what is an identifier agree with scan.l.  (If you change this rule,
- * adjust the errdetail in find_option().)
+ * It must be one or more identifiers separated by zero or more dots, where the
+ * rules for what is an identifier agree with scan.l.  (If you change this
+ * rule, adjust the errdetail in find_option().)
+ *
+ * partcnt: returns by reference the number of dot separated identifiers.
  */
-static bool
-valid_custom_variable_name(const char *name)
+bool
+valid_variable_name(const char *name, int *partcnt)
 {
-	bool		saw_sep = false;
+	int			parts = 1;
 	bool		name_start = true;
 
+	if (partcnt)
+		*partcnt = -1;
 	for (const char *p = name; *p; p++)
 	{
 		if (*p == GUC_QUALIFIER_SEPARATOR)
 		{
 			if (name_start)
 				return false;	/* empty name component */
-			saw_sep = true;
+			parts++;
 			name_start = true;
 		}
 		else if (strchr("ABCDEFGHIJKLMNOPQRSTUVWXYZ"
@@ -5463,8 +5471,24 @@ valid_custom_variable_name(const char *name)
 	}
 	if (name_start)
 		return false;			/* empty name component */
-	/* OK if we found at least one separator */
-	return saw_sep;
+	if (partcnt)
+		*partcnt = parts;
+	return true;
+}
+
+/*
+ * Decide whether a proposed custom variable name is allowed.
+ *
+ * It must be two or more identifiers separated by dots, where the rules
+ * for what is an identifier agree with scan.l.  (If you change this rule,
+ * adjust the errdetail in find_option().)
+ */
+static bool
+valid_custom_variable_name(const char *name)
+{
+	int			partcnt;
+
+	return (valid_variable_name(name, &partcnt) && partcnt > 1);
 }
 
 /*
@@ -7492,6 +7516,24 @@ set_config_option(const char *name, const char *value,
 		case PGC_SUSET:
 			if (context == PGC_USERSET || context == PGC_BACKEND)
 			{
+				/*
+				 * Check whether the current user has granted privilege to set
+				 * this GUC.
+				 */
+				Oid			settingid = get_setting_oid(name, true);
+
+				if (OidIsValid(settingid))
+				{
+					AclResult	aclresult;
+
+					aclresult = pg_setting_acl_aclcheck(settingid, GetUserId(),
+														ACL_SET_VALUE);
+
+					if (aclresult == ACLCHECK_OK)
+						break;		/* okay */
+				}
+
+				/* No granted privilege */
 				ereport(elevel,
 						(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
 						 errmsg("permission denied to set parameter \"%s\"",
@@ -8541,16 +8583,32 @@ AlterSystemSetConfigFile(AlterSystemStmt *altersysstmt)
 	char		AutoConfFileName[MAXPGPATH];
 	char		AutoConfTmpFileName[MAXPGPATH];
 
-	if (!superuser())
-		ereport(ERROR,
-				(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
-				 errmsg("must be superuser to execute ALTER SYSTEM command")));
-
 	/*
 	 * Extract statement arguments
 	 */
 	name = altersysstmt->setstmt->name;
 
+	/*
+	 * Check permission to run ALTER SYSTEM on the target variable registered.
+	 */
+	if (!superuser())
+	{
+		AclResult	aclresult;
+		Oid			settingId;
+
+		settingId = get_setting_oid(name, true);
+		if (!OidIsValid(settingId))
+			ereport(ERROR,
+					(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
+					 errmsg("permission denied to set parameter \"%s\"",
+							name)));
+
+		aclresult = pg_setting_acl_aclcheck(settingId, GetUserId(),
+											 ACL_ALTER_SYSTEM);
+		if (aclresult != ACLCHECK_OK)
+			aclcheck_error(aclresult, OBJECT_SETTING, name);
+	}
+
 	switch (altersysstmt->setstmt->kind)
 	{
 		case VAR_SET_VALUE:
@@ -8743,6 +8801,9 @@ void
 ExecSetVariableStmt(VariableSetStmt *stmt, bool isTopLevel)
 {
 	GucAction	action = stmt->is_local ? GUC_ACTION_LOCAL : GUC_ACTION_SET;
+	GucContext	context;
+	AclResult	aclresult;
+	Oid			settingId;
 
 	/*
 	 * Workers synchronize these parameters at the start of the parallel
@@ -8753,6 +8814,21 @@ ExecSetVariableStmt(VariableSetStmt *stmt, bool isTopLevel)
 				(errcode(ERRCODE_INVALID_TRANSACTION_STATE),
 				 errmsg("cannot set parameters during a parallel operation")));
 
+	/*
+	 * Superusers and users who have been granted SET privilege can set with
+	 * PGC_SUSET context.  All others have only PGC_USERSET.
+	 */
+	context = PGC_USERSET;
+	if (superuser())
+		context = PGC_SUSET;
+	else if (OidIsValid(settingId = get_setting_oid(stmt->name, true)))
+	{
+		aclresult = pg_setting_acl_aclcheck(settingId, GetUserId(),
+											ACL_SET_VALUE);
+		if (aclresult == ACLCHECK_OK)
+			context = PGC_SUSET;
+	}
+
 	switch (stmt->kind)
 	{
 		case VAR_SET_VALUE:
@@ -8761,7 +8837,7 @@ ExecSetVariableStmt(VariableSetStmt *stmt, bool isTopLevel)
 				WarnNoTransactionBlock(isTopLevel, "SET LOCAL");
 			(void) set_config_option(stmt->name,
 									 ExtractSetVariableArgs(stmt),
-									 (superuser() ? PGC_SUSET : PGC_USERSET),
+									 context,
 									 PGC_S_SESSION,
 									 action, true, 0, false);
 			check_reserved_prefixes(stmt->name);
@@ -8847,7 +8923,7 @@ ExecSetVariableStmt(VariableSetStmt *stmt, bool isTopLevel)
 
 			(void) set_config_option(stmt->name,
 									 NULL,
-									 (superuser() ? PGC_SUSET : PGC_USERSET),
+									 context,
 									 PGC_S_SESSION,
 									 action, true, 0, false);
 
@@ -9631,6 +9707,22 @@ get_explain_guc_options(int *num)
 	return result;
 }
 
+/*
+ * Return GUC variable canonical name, or NULL if no variable by the given
+ * name or alias exists.
+ */
+const char *
+GetConfigOptionCanonicalName(const char *alias)
+{
+	struct config_generic *record;
+
+	record = find_option(alias, false, true, LOG);
+	if (record == NULL)
+		return NULL;
+
+	return record->name;
+}
+
 /*
  * Return GUC variable value by name; optionally return canonical form of
  * name.  If the GUC is unset, then throw an error unless missing_ok is true,
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
index 03b80f9575..fc421a894c 100644
--- a/src/bin/initdb/initdb.c
+++ b/src/bin/initdb/initdb.c
@@ -163,6 +163,7 @@ static char *features_file;
 static char *system_constraints_file;
 static char *system_functions_file;
 static char *system_views_file;
+static char *setting_privileges_file;
 static bool success = false;
 static bool made_new_pgdata = false;
 static bool found_existing_pgdata = false;
@@ -2441,6 +2442,7 @@ setup_data_file_paths(void)
 	set_input(&system_constraints_file, "system_constraints.sql");
 	set_input(&system_functions_file, "system_functions.sql");
 	set_input(&system_views_file, "system_views.sql");
+	set_input(&setting_privileges_file, "setting_privileges.sql");
 
 	if (show_setting || debug)
 	{
@@ -2469,6 +2471,7 @@ setup_data_file_paths(void)
 	check_input(system_constraints_file);
 	check_input(system_functions_file);
 	check_input(system_views_file);
+	check_input(setting_privileges_file);
 }
 
 
@@ -2816,6 +2819,8 @@ initialize_data_directory(void)
 
 	setup_run_file(cmdfd, system_views_file);
 
+	setup_run_file(cmdfd, setting_privileges_file);
+
 	setup_description(cmdfd);
 
 	setup_collation(cmdfd);
diff --git a/src/bin/pg_dump/dumputils.c b/src/bin/pg_dump/dumputils.c
index dfc96bc98b..2a44e6ffec 100644
--- a/src/bin/pg_dump/dumputils.c
+++ b/src/bin/pg_dump/dumputils.c
@@ -37,7 +37,7 @@ static void AddAcl(PQExpBuffer aclbuf, const char *keyword,
  *	nspname: the namespace the object is in (NULL if none); not pre-quoted
  *	type: the object type (as seen in GRANT command: must be one of
  *		TABLE, SEQUENCE, FUNCTION, PROCEDURE, LANGUAGE, SCHEMA, DATABASE, TABLESPACE,
- *		FOREIGN DATA WRAPPER, SERVER, or LARGE OBJECT)
+ *		FOREIGN DATA WRAPPER, SERVER, SETTING or LARGE OBJECT)
  *	acls: the ACL string fetched from the database
  *	baseacls: the initial ACL string for this object; can be
  *		NULL or empty string to indicate "not available from server"
@@ -539,6 +539,11 @@ do { \
 		CONVERT_PRIV('U', "USAGE");
 	else if (strcmp(type, "FOREIGN TABLE") == 0)
 		CONVERT_PRIV('r', "SELECT");
+	else if (strcmp(type, "SETTING") == 0)
+	{
+		CONVERT_PRIV('s', "SET VALUE");
+		CONVERT_PRIV('A', "ALTER SYSTEM");
+	}
 	else if (strcmp(type, "LARGE OBJECT") == 0)
 	{
 		CONVERT_PRIV('r', "SELECT");
diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c
index 8903a694ae..2b8e70ff43 100644
--- a/src/bin/pg_dump/pg_backup_archiver.c
+++ b/src/bin/pg_dump/pg_backup_archiver.c
@@ -3410,6 +3410,7 @@ _getObjectDescription(PQExpBuffer buf, TocEntry *te)
 		strcmp(type, "SCHEMA") == 0 ||
 		strcmp(type, "EVENT TRIGGER") == 0 ||
 		strcmp(type, "FOREIGN DATA WRAPPER") == 0 ||
+		strcmp(type, "SETTING") == 0 ||
 		strcmp(type, "SERVER") == 0 ||
 		strcmp(type, "PUBLICATION") == 0 ||
 		strcmp(type, "SUBSCRIPTION") == 0 ||
@@ -3593,6 +3594,7 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, bool isData)
 			strcmp(te->desc, "TEXT SEARCH DICTIONARY") == 0 ||
 			strcmp(te->desc, "TEXT SEARCH CONFIGURATION") == 0 ||
 			strcmp(te->desc, "FOREIGN DATA WRAPPER") == 0 ||
+			strcmp(te->desc, "SETTING") == 0 ||
 			strcmp(te->desc, "SERVER") == 0 ||
 			strcmp(te->desc, "STATISTICS") == 0 ||
 			strcmp(te->desc, "PUBLICATION") == 0 ||
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 326441a76a..e075f03dbd 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -14147,6 +14147,9 @@ dumpDefaultACL(Archive *fout, const DefaultACLInfo *daclinfo)
 		case DEFACLOBJ_NAMESPACE:
 			type = "SCHEMAS";
 			break;
+		case DEFACLOBJ_SETTING:
+			type = "SETTINGS";
+			break;
 		default:
 			/* shouldn't get here */
 			fatal("unrecognized object type in default privileges: %d",
@@ -14190,7 +14193,7 @@ dumpDefaultACL(Archive *fout, const DefaultACLInfo *daclinfo)
  *		or InvalidDumpId if there is no need for a second dependency.
  * 'type' must be one of
  *		TABLE, SEQUENCE, FUNCTION, LANGUAGE, SCHEMA, DATABASE, TABLESPACE,
- *		FOREIGN DATA WRAPPER, SERVER, or LARGE OBJECT.
+ *		FOREIGN DATA WRAPPER, SERVER, SETTING or LARGE OBJECT.
  * 'name' is the formatted name of the object.  Must be quoted etc. already.
  * 'subname' is the formatted name of the sub-object, if any.  Must be quoted.
  *		(Currently we assume that subname is only provided for table columns.)
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index 9ff0c091a9..2e198ba94d 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -36,6 +36,7 @@ static void help(void);
 static void dropRoles(PGconn *conn);
 static void dumpRoles(PGconn *conn);
 static void dumpRoleMembership(PGconn *conn);
+static void dumpRoleGUCPrivs(PGconn *conn);
 static void dropTablespaces(PGconn *conn);
 static void dumpTablespaces(PGconn *conn);
 static void dropDBs(PGconn *conn);
@@ -581,6 +582,10 @@ main(int argc, char *argv[])
 
 			/* Dump role memberships */
 			dumpRoleMembership(conn);
+
+			/* Dump role guc privileges */
+			if (server_version >= 150000)
+				dumpRoleGUCPrivs(conn);
 		}
 
 		/* Dump tablespaces */
@@ -1019,6 +1024,72 @@ dropTablespaces(PGconn *conn)
 	fprintf(OPF, "\n\n");
 }
 
+/*
+ * Dump role configuration parameter privileges.  This code is used for 15.0
+ * and later servers.
+ *
+ * Note: we expect dumpRoles already created all the roles, but there are
+ * no per-role configuration parameter privileges yet..
+ */
+static void
+dumpRoleGUCPrivs(PGconn *conn)
+{
+	PQExpBuffer buf = createPQExpBuffer();
+	PGresult   *res;
+	int			i;
+
+	printfPQExpBuffer(buf, "SELECT string_agg(acl.privilege_type, ', ' ORDER BY acl.privilege_type), "
+					  "set_acl.setting, "
+					  "grantee.rolname AS grantee, "
+					  "acl.is_grantable, "
+					  "grantor.rolname AS grantor "
+					  "FROM pg_catalog.pg_setting_acl set_acl, "
+					  "LATERAL (SELECT * FROM aclexplode(set_acl.setacl)) acl "
+					  "JOIN pg_catalog.pg_authid grantee "
+					  "ON acl.grantee = grantee.oid "
+					  "LEFT JOIN pg_catalog.pg_authid grantor ON "
+					  "acl.grantor = grantor.oid "
+					  "WHERE acl.grantee > 0 "
+					  "GROUP BY setting, grantee.rolname, is_grantable, grantor.rolname"
+					  );
+
+	res = executeQuery(conn, buf->data);
+
+	if (PQntuples(res) > 0)
+		fprintf(OPF, "--\n-- Role privileges on configuration parameters\n--\n\n");
+
+	for (i = 0; i < PQntuples(res); i++)
+	{
+		char	   *privilege = PQgetvalue(res, i, 0);
+		char	   *setting = PQgetvalue(res, i, 1);
+		char	   *grantee = PQgetvalue(res, i, 2);
+		char	   *grantable = PQgetvalue(res, i, 3);
+
+		fprintf(OPF, "GRANT %s", privilege);
+		fprintf(OPF, " ON %s", setting);
+		fprintf(OPF, " TO %s", fmtId(grantee));
+		if (*grantable == 't')
+			fprintf(OPF, " WITH GRANT OPTION");
+
+		/*
+		 * We don't track the grantor very carefully in the backend, so cope
+		 * with the possibility that it has been dropped.
+		 */
+		if (!PQgetisnull(res, i, 4))
+		{
+			char	   *grantor = PQgetvalue(res, i, 4);
+
+			fprintf(OPF, " GRANTED BY %s", fmtId(grantor));
+		}
+		fprintf(OPF, ";\n");
+	}
+
+	PQclear(res);
+	destroyPQExpBuffer(buf);
+
+	fprintf(OPF, "\n\n");
+}
+
 /*
  * Dump tablespaces.
  */
diff --git a/src/include/catalog/dependency.h b/src/include/catalog/dependency.h
index 3eca295ff4..a800f0b544 100644
--- a/src/include/catalog/dependency.h
+++ b/src/include/catalog/dependency.h
@@ -92,6 +92,7 @@ typedef enum ObjectClass
 	OCLASS_TYPE,				/* pg_type */
 	OCLASS_CAST,				/* pg_cast */
 	OCLASS_COLLATION,			/* pg_collation */
+	OCLASS_SETTING,				/* pg_setting_acl */
 	OCLASS_CONSTRAINT,			/* pg_constraint */
 	OCLASS_CONVERSION,			/* pg_conversion */
 	OCLASS_DEFAULT,				/* pg_attrdef */
diff --git a/src/include/catalog/pg_default_acl.h b/src/include/catalog/pg_default_acl.h
index eb72dd6293..08a2dcee41 100644
--- a/src/include/catalog/pg_default_acl.h
+++ b/src/include/catalog/pg_default_acl.h
@@ -66,6 +66,7 @@ DECLARE_UNIQUE_INDEX_PKEY(pg_default_acl_oid_index, 828, DefaultAclOidIndexId, o
 #define DEFACLOBJ_FUNCTION		'f' /* function */
 #define DEFACLOBJ_TYPE			'T' /* type */
 #define DEFACLOBJ_NAMESPACE		'n' /* namespace */
+#define DEFACLOBJ_SETTING	'c' /* configuration parameter */
 
 #endif							/* EXPOSE_TO_CLIENT_CODE */
 
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 4d992dc224..5443aad4bd 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -7196,6 +7196,25 @@
   proname => 'has_type_privilege', provolatile => 's', prorettype => 'bool',
   proargtypes => 'oid text', prosrc => 'has_type_privilege_id' },
 
+{ oid => '8050', descr => 'user privilege on setting by username, setting name',
+  proname => 'has_setting_privilege', provolatile => 's', prorettype => 'bool',
+  proargtypes => 'name text text', prosrc => 'has_setting_privilege_name_name' },
+{ oid => '8051', descr => 'user privilege on setting by username, setting oid',
+  proname => 'has_setting_privilege', provolatile => 's', prorettype => 'bool',
+  proargtypes => 'name oid text', prosrc => 'has_setting_privilege_name_id' },
+{ oid => '8052', descr => 'user privilege on setting by user oid, setting name',
+  proname => 'has_setting_privilege', provolatile => 's', prorettype => 'bool',
+  proargtypes => 'oid text text', prosrc => 'has_setting_privilege_id_name' },
+{ oid => '8053', descr => 'user privilege on setting by user oid, setting oid',
+  proname => 'has_setting_privilege', provolatile => 's', prorettype => 'bool',
+  proargtypes => 'oid oid text', prosrc => 'has_setting_privilege_id_id' },
+{ oid => '8054', descr => 'current user privilege on setting by setting name',
+  proname => 'has_setting_privilege', provolatile => 's', prorettype => 'bool',
+  proargtypes => 'text text', prosrc => 'has_setting_privilege_name' },
+{ oid => '8055', descr => 'current user privilege on setting by setting oid',
+  proname => 'has_setting_privilege', provolatile => 's', prorettype => 'bool',
+  proargtypes => 'oid text', prosrc => 'has_setting_privilege_id' },
+
 { oid => '2705', descr => 'user privilege on role by username, role name',
   proname => 'pg_has_role', provolatile => 's', prorettype => 'bool',
   proargtypes => 'name name text', prosrc => 'pg_has_role_name_name' },
diff --git a/src/include/catalog/pg_setting_acl.h b/src/include/catalog/pg_setting_acl.h
new file mode 100644
index 0000000000..b7dee55e5c
--- /dev/null
+++ b/src/include/catalog/pg_setting_acl.h
@@ -0,0 +1,63 @@
+/*-------------------------------------------------------------------------
+ *
+ * pg_setting_acl.h
+ *	  definition of the "configuration parameter" system catalog
+ *	  (pg_setting_acl).
+ *
+ *
+ * Portions Copyright (c) 1996-2021, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1994, Regents of the University of California
+ *
+ * src/include/catalog/pg_setting_acl.h
+ *
+ * NOTES
+ *	  The Catalog.pm module reads this file and derives schema
+ *	  information.
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef PG_SETTING_ACL_H
+#define PG_SETTING_ACL_H
+
+#include "catalog/genbki.h"
+#include "catalog/pg_setting_acl_d.h"
+
+/* ----------------
+ *		pg_setting_acl definition.  cpp turns this into
+ *		typedef struct FormData_pg_setting_acl
+ * ----------------
+ */
+CATALOG(pg_setting_acl,8924,SettingAclRelationId) BKI_SHARED_RELATION
+{
+	Oid			oid;			/* oid */
+	/*
+
+	 * Variable-length fields start here, but we allow direct access to
+	 * setting.
+	 */
+	text		setting BKI_FORCE_NOT_NULL;
+
+#ifdef CATALOG_VARLEN
+	/* Access privileges */
+	aclitem		setacl[1] BKI_DEFAULT(_null_);
+#endif
+} FormData_pg_setting_acl;
+
+
+/* ----------------
+ *		Form_pg_setting_acl corresponds to a pointer to a tuple with
+ *		the format of pg_setting_acl relation.
+ * ----------------
+ */
+typedef FormData_pg_setting_acl *Form_pg_setting_acl;
+
+DECLARE_TOAST(pg_setting_acl, 8925, 8926);
+#define PgSettingAclToastTable 8925
+#define PgSettingAclToastIndex 8926
+
+DECLARE_UNIQUE_INDEX(pg_setting_acl_setting_index, 8927, SettingAclSettingIndexId, on pg_setting_acl using btree(setting text_ops));
+DECLARE_UNIQUE_INDEX_PKEY(pg_setting_acl_oid_index, 8928, SettingAclOidIndexId, on pg_setting_acl using btree(oid oid_ops));
+
+extern Oid	SettingAclCreate(const char *setting, bool if_not_exists);
+
+#endif							/* PG_SETTING_ACL_H */
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index 4c5a8a39bf..1cd57d5552 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -92,7 +92,9 @@ typedef uint32 AclMode;			/* a bitmask of privilege bits */
 #define ACL_CREATE		(1<<9)	/* for namespaces and databases */
 #define ACL_CREATE_TEMP (1<<10) /* for databases */
 #define ACL_CONNECT		(1<<11) /* for databases */
-#define N_ACL_RIGHTS	12		/* 1 plus the last 1<<x */
+#define ACL_SET_VALUE	(1<<12) /* for configuration parameters */
+#define ACL_ALTER_SYSTEM (1<<13) /* for configuration parameters */
+#define N_ACL_RIGHTS	14		/* 1 plus the last 1<<x */
 #define ACL_NO_RIGHTS	0
 /* Currently, SELECT ... FOR [KEY] UPDATE/SHARE requires UPDATE privileges */
 #define ACL_SELECT_FOR_UPDATE	ACL_UPDATE
@@ -1794,6 +1796,7 @@ typedef enum ObjectType
 	OBJECT_CAST,
 	OBJECT_COLUMN,
 	OBJECT_COLLATION,
+	OBJECT_SETTING,
 	OBJECT_CONVERSION,
 	OBJECT_DATABASE,
 	OBJECT_DEFAULT,
diff --git a/src/include/parser/kwlist.h b/src/include/parser/kwlist.h
index f836acf876..527e723b39 100644
--- a/src/include/parser/kwlist.h
+++ b/src/include/parser/kwlist.h
@@ -307,6 +307,7 @@ PG_KEYWORD("overriding", OVERRIDING, UNRESERVED_KEYWORD, BARE_LABEL)
 PG_KEYWORD("owned", OWNED, UNRESERVED_KEYWORD, BARE_LABEL)
 PG_KEYWORD("owner", OWNER, UNRESERVED_KEYWORD, BARE_LABEL)
 PG_KEYWORD("parallel", PARALLEL, UNRESERVED_KEYWORD, BARE_LABEL)
+PG_KEYWORD("parameter", PARAMETER, UNRESERVED_KEYWORD, BARE_LABEL)
 PG_KEYWORD("parser", PARSER, UNRESERVED_KEYWORD, BARE_LABEL)
 PG_KEYWORD("partial", PARTIAL, UNRESERVED_KEYWORD, BARE_LABEL)
 PG_KEYWORD("partition", PARTITION, UNRESERVED_KEYWORD, BARE_LABEL)
diff --git a/src/include/utils/acl.h b/src/include/utils/acl.h
index af771c901d..70a6d83336 100644
--- a/src/include/utils/acl.h
+++ b/src/include/utils/acl.h
@@ -146,9 +146,11 @@ typedef struct ArrayType Acl;
 #define ACL_CREATE_CHR			'C'
 #define ACL_CREATE_TEMP_CHR		'T'
 #define ACL_CONNECT_CHR			'c'
+#define ACL_SET_VALUE_CHR		's'
+#define ACL_ALTER_SYSTEM_CHR	'A'
 
 /* string holding all privilege code chars, in order by bitmask position */
-#define ACL_ALL_RIGHTS_STR	"arwdDxtXUCTc"
+#define ACL_ALL_RIGHTS_STR	"arwdDxtXUCTcsA"
 
 /*
  * Bitmasks defining "all rights" for each supported object type
@@ -165,6 +167,7 @@ typedef struct ArrayType Acl;
 #define ACL_ALL_RIGHTS_SCHEMA		(ACL_USAGE|ACL_CREATE)
 #define ACL_ALL_RIGHTS_TABLESPACE	(ACL_CREATE)
 #define ACL_ALL_RIGHTS_TYPE			(ACL_USAGE)
+#define ACL_ALL_RIGHTS_SETTING	(ACL_SET_VALUE|ACL_ALTER_SYSTEM)
 
 /* operation codes for pg_*_aclmask */
 typedef enum
@@ -223,6 +226,8 @@ extern void select_best_grantor(Oid roleId, AclMode privileges,
 
 extern void initialize_acl(void);
 
+extern Oid	get_setting_oid(const char *setting, bool missing_ok);
+
 /*
  * prototypes for functions in aclchk.c
  */
@@ -243,6 +248,8 @@ extern AclMode pg_class_aclmask_ext(Oid table_oid, Oid roleid,
 									bool *is_missing);
 extern AclMode pg_database_aclmask(Oid db_oid, Oid roleid,
 								   AclMode mask, AclMaskHow how);
+extern AclMode pg_setting_acl_aclmask(Oid config_oid, Oid roleid,
+								   AclMode mask, AclMaskHow how);
 extern AclMode pg_proc_aclmask(Oid proc_oid, Oid roleid,
 							   AclMode mask, AclMaskHow how);
 extern AclMode pg_language_aclmask(Oid lang_oid, Oid roleid,
@@ -271,6 +278,7 @@ extern AclResult pg_class_aclcheck(Oid table_oid, Oid roleid, AclMode mode);
 extern AclResult pg_class_aclcheck_ext(Oid table_oid, Oid roleid,
 									   AclMode mode, bool *is_missing);
 extern AclResult pg_database_aclcheck(Oid db_oid, Oid roleid, AclMode mode);
+extern AclResult pg_setting_acl_aclcheck(Oid config_oid, Oid roleid, AclMode mode);
 extern AclResult pg_proc_aclcheck(Oid proc_oid, Oid roleid, AclMode mode);
 extern AclResult pg_language_aclcheck(Oid lang_oid, Oid roleid, AclMode mode);
 extern AclResult pg_largeobject_aclcheck_snapshot(Oid lang_oid, Oid roleid,
diff --git a/src/include/utils/guc.h b/src/include/utils/guc.h
index aa18d304ac..fb2fe193c5 100644
--- a/src/include/utils/guc.h
+++ b/src/include/utils/guc.h
@@ -379,6 +379,8 @@ extern int	set_config_option(const char *name, const char *value,
 							  GucAction action, bool changeVal, int elevel,
 							  bool is_reload);
 extern void AlterSystemSetConfigFile(AlterSystemStmt *altersysstmt);
+extern bool valid_variable_name(const char *name, int *partcnt);
+extern const char *GetConfigOptionCanonicalName(const char *alias);
 extern char *GetConfigOptionByName(const char *name, const char **varname,
 								   bool missing_ok);
 extern void GetConfigOptionByNum(int varnum, const char **values, bool *noshow);
diff --git a/src/include/utils/lsyscache.h b/src/include/utils/lsyscache.h
index 77871aaefc..a620eb6dca 100644
--- a/src/include/utils/lsyscache.h
+++ b/src/include/utils/lsyscache.h
@@ -188,6 +188,7 @@ extern int32 get_attavgwidth(Oid relid, AttrNumber attnum);
 extern bool get_attstatsslot(AttStatsSlot *sslot, HeapTuple statstuple,
 							 int reqkind, Oid reqop, int flags);
 extern void free_attstatsslot(AttStatsSlot *sslot);
+extern char *get_setting_name(Oid configid);
 extern char *get_namespace_name(Oid nspid);
 extern char *get_namespace_name_or_temp(Oid nspid);
 extern Oid	get_range_subtype(Oid rangeOid);
diff --git a/src/include/utils/syscache.h b/src/include/utils/syscache.h
index c8cfbc30f6..27cf1c6088 100644
--- a/src/include/utils/syscache.h
+++ b/src/include/utils/syscache.h
@@ -89,6 +89,8 @@ enum SysCacheIdentifier
 	REPLORIGNAME,
 	RULERELNAME,
 	SEQRELID,
+	SETTINGNAME,
+	SETTINGOID,
 	STATEXTDATASTXOID,
 	STATEXTNAMENSP,
 	STATEXTOID,
diff --git a/src/test/modules/test_pg_dump/t/001_base.pl b/src/test/modules/test_pg_dump/t/001_base.pl
index 16f7610883..f8071eca00 100644
--- a/src/test/modules/test_pg_dump/t/001_base.pl
+++ b/src/test/modules/test_pg_dump/t/001_base.pl
@@ -317,6 +317,53 @@ my %tests = (
 		like         => { pg_dumpall_globals => 1, },
 	},
 
+	'GRANT ALTER SYSTEM ON ignore_checksum_failure' => {
+		create_order => 2,
+		create_sql   =>
+			'GRANT ALTER SYSTEM ON ignore_checksum_failure TO regress_dump_test_role;',
+		regexp       =>
+			qr/^GRANT ALTER SYSTEM ON ignore_checksum_failure TO regress_dump_test_role GRANTED BY /m,
+		like         => { pg_dumpall_globals => 1, },
+	},
+
+	'GRANT SET VALUE ON my.missing.guc' => {
+		create_order => 2,
+		create_sql   =>
+			'GRANT SET VALUE ON my.missing.guc TO regress_dump_test_role;',
+		regexp       =>
+			qr/^GRANT SET VALUE ON my\.missing\.guc TO regress_dump_test_role GRANTED BY /m,
+		like         => { pg_dumpall_globals => 1, },
+	},
+
+	'GRANT SET VALUE, ALTER SYSTEM ON something WITH GRANT OPTION' => {
+		create_order => 2,
+		create_sql =>
+			'GRANT SET VALUE, ALTER SYSTEM ON something TO regress_dump_test_role WITH GRANT OPTION;',
+		regexp =>
+			qr/^GRANT ALTER SYSTEM, SET VALUE ON something TO regress_dump_test_role WITH GRANT OPTION GRANTED BY /m,
+		like => { pg_dumpall_globals => 1, },
+	},
+
+	'GRANT ALTER SYSTEM ON MyReallyLong.ButValidCustom.GucNameThatCannotFit.InNamedata64Byte.Format' => {
+		create_order => 2,
+		create_sql =>
+			# configuration parameters get cased folded
+			'GRANT ALTER SYSTEM ON MyReallyLong.ButValidCustom.GucNameThatCannotFit.InNamedata64Byte.Format TO regress_dump_test_role;',
+		regexp =>
+			qr/^GRANT ALTER SYSTEM ON myreallylong\.butvalidcustom\.gucnamethatcannotfit\.innamedata64byte\.format TO regress_dump_test_role GRANTED BY /m,
+		like => { pg_dumpall_globals => 1, },
+	},
+
+	'GRANT ALTER SYSTEM, SET VALUE ON my.guc TO regress_dump_test_role GRANTED BY CURRENT_ROLE' => {
+		create_order => 2,
+		create_sql =>
+			# GRANTED BY CURRENT_ROLE is allowed for SQL compatibility, but is ignored
+			'GRANT ALTER SYSTEM, SET VALUE ON my.guc TO regress_dump_test_role GRANTED BY CURRENT_ROLE;',
+		regexp =>
+			qr/^GRANT ALTER SYSTEM, SET VALUE ON my\.guc TO regress_dump_test_role GRANTED BY /m,
+		like => { pg_dumpall_globals => 1, },
+	},
+
 	'CREATE SCHEMA public' => {
 		regexp => qr/^CREATE SCHEMA public;/m,
 		like   => {
diff --git a/src/test/regress/expected/guc_privs.out b/src/test/regress/expected/guc_privs.out
new file mode 100644
index 0000000000..c2033e77d1
--- /dev/null
+++ b/src/test/regress/expected/guc_privs.out
@@ -0,0 +1,780 @@
+-- Test superuser
+-- Superuser DBA
+CREATE ROLE regress_admin SUPERUSER;
+-- Perform all operations as user 'regress_admin' --
+SET SESSION AUTHORIZATION regress_admin;
+-- PGC_BACKEND
+SET ignore_system_indexes = OFF;  -- fail, cannot be set after connection start
+ERROR:  parameter "ignore_system_indexes" cannot be set after connection start
+RESET ignore_system_indexes;  -- fail, cannot be set after connection start
+ERROR:  parameter "ignore_system_indexes" cannot be set after connection start
+ALTER SYSTEM SET ignore_system_indexes = OFF;  -- ok
+ALTER SYSTEM RESET ignore_system_indexes;  -- ok
+-- PGC_INTERNAL
+SET block_size = 50;  -- fail, cannot be changed
+ERROR:  parameter "block_size" cannot be changed
+RESET block_size;  -- fail, cannot be changed
+ERROR:  parameter "block_size" cannot be changed
+ALTER SYSTEM SET block_size = 50;  -- fail, cannot be changed
+ERROR:  parameter "block_size" cannot be changed
+ALTER SYSTEM RESET block_size;  -- fail, cannot be changed
+ERROR:  parameter "block_size" cannot be changed
+-- PGC_POSTMASTER
+SET autovacuum_freeze_max_age = 1000050000;  -- fail, requires restart
+ERROR:  parameter "autovacuum_freeze_max_age" cannot be changed without restarting the server
+RESET autovacuum_freeze_max_age;  -- fail, requires restart
+ERROR:  parameter "autovacuum_freeze_max_age" cannot be changed without restarting the server
+ALTER SYSTEM SET autovacuum_freeze_max_age = 1000050000;  -- ok
+ALTER SYSTEM RESET autovacuum_freeze_max_age;  -- ok
+ALTER SYSTEM SET config_file = '/usr/local/data/postgresql.conf';  -- fail, cannot be changed
+ERROR:  parameter "config_file" cannot be changed
+ALTER SYSTEM RESET config_file;  -- fail, cannot be changed
+ERROR:  parameter "config_file" cannot be changed
+-- PGC_SIGHUP
+SET autovacuum = OFF;  -- fail, requires reload
+ERROR:  parameter "autovacuum" cannot be changed now
+RESET autovacuum;  -- fail, requires reload
+ERROR:  parameter "autovacuum" cannot be changed now
+ALTER SYSTEM SET autovacuum = OFF;  -- ok
+ALTER SYSTEM RESET autovacuum;  -- ok
+-- PGC_SUSET
+SET lc_messages = 'C';  -- ok
+RESET lc_messages;  -- ok
+ALTER SYSTEM SET lc_messages = 'C';  -- ok
+ALTER SYSTEM RESET lc_messages;  -- ok
+-- PGC_SU_BACKEND
+SET jit_debugging_support = OFF;  -- fail, cannot be set after connection start
+ERROR:  parameter "jit_debugging_support" cannot be set after connection start
+RESET jit_debugging_support;  -- fail, cannot be set after connection start
+ERROR:  parameter "jit_debugging_support" cannot be set after connection start
+ALTER SYSTEM SET jit_debugging_support = OFF;  -- ok
+ALTER SYSTEM RESET jit_debugging_support;  -- ok
+-- PGC_USERSET
+SET DateStyle = 'ISO, MDY';  -- ok
+RESET DateStyle;  -- ok
+ALTER SYSTEM SET DateStyle = 'ISO, MDY';  -- ok
+ALTER SYSTEM RESET DateStyle;  -- ok
+ALTER SYSTEM SET ssl_renegotiation_limit = 0;  -- fail, cannot be changed
+ERROR:  parameter "ssl_renegotiation_limit" cannot be changed
+ALTER SYSTEM RESET ssl_renegotiation_limit;  -- fail, cannot be changed
+ERROR:  parameter "ssl_renegotiation_limit" cannot be changed
+-- Finished testing superuser
+RESET statement_timeout;
+-- Check setting privileges prior to creating any
+SELECT grantee, setting, privilege_type, is_grantable
+	FROM pg_catalog.pg_setting_privileges
+	ORDER BY grantee, setting, privilege_type;
+ grantee |               setting               | privilege_type | is_grantable 
+---------+-------------------------------------+----------------+--------------
+         | DateStyle                           | SET VALUE      | f
+         | IntervalStyle                       | SET VALUE      | f
+         | TimeZone                            | SET VALUE      | f
+         | application_name                    | SET VALUE      | f
+         | array_nulls                         | SET VALUE      | f
+         | backend_flush_after                 | SET VALUE      | f
+         | backslash_quote                     | SET VALUE      | f
+         | bytea_output                        | SET VALUE      | f
+         | check_function_bodies               | SET VALUE      | f
+         | client_connection_check_interval    | SET VALUE      | f
+         | client_min_messages                 | SET VALUE      | f
+         | commit_siblings                     | SET VALUE      | f
+         | constraint_exclusion                | SET VALUE      | f
+         | cpu_index_tuple_cost                | SET VALUE      | f
+         | cpu_operator_cost                   | SET VALUE      | f
+         | cpu_tuple_cost                      | SET VALUE      | f
+         | cursor_tuple_fraction               | SET VALUE      | f
+         | debug_pretty_print                  | SET VALUE      | f
+         | debug_print_parse                   | SET VALUE      | f
+         | debug_print_plan                    | SET VALUE      | f
+         | debug_print_rewritten               | SET VALUE      | f
+         | default_statistics_target           | SET VALUE      | f
+         | default_table_access_method         | SET VALUE      | f
+         | default_tablespace                  | SET VALUE      | f
+         | default_text_search_config          | SET VALUE      | f
+         | default_toast_compression           | SET VALUE      | f
+         | default_transaction_deferrable      | SET VALUE      | f
+         | default_transaction_isolation       | SET VALUE      | f
+         | default_transaction_read_only       | SET VALUE      | f
+         | default_with_oids                   | SET VALUE      | f
+         | effective_cache_size                | SET VALUE      | f
+         | effective_io_concurrency            | SET VALUE      | f
+         | enable_async_append                 | SET VALUE      | f
+         | enable_bitmapscan                   | SET VALUE      | f
+         | enable_gathermerge                  | SET VALUE      | f
+         | enable_hashagg                      | SET VALUE      | f
+         | enable_hashjoin                     | SET VALUE      | f
+         | enable_incremental_sort             | SET VALUE      | f
+         | enable_indexonlyscan                | SET VALUE      | f
+         | enable_indexscan                    | SET VALUE      | f
+         | enable_material                     | SET VALUE      | f
+         | enable_memoize                      | SET VALUE      | f
+         | enable_mergejoin                    | SET VALUE      | f
+         | enable_nestloop                     | SET VALUE      | f
+         | enable_parallel_append              | SET VALUE      | f
+         | enable_parallel_hash                | SET VALUE      | f
+         | enable_partition_pruning            | SET VALUE      | f
+         | enable_partitionwise_aggregate      | SET VALUE      | f
+         | enable_partitionwise_join           | SET VALUE      | f
+         | enable_seqscan                      | SET VALUE      | f
+         | enable_sort                         | SET VALUE      | f
+         | enable_tidscan                      | SET VALUE      | f
+         | escape_string_warning               | SET VALUE      | f
+         | exit_on_error                       | SET VALUE      | f
+         | extra_float_digits                  | SET VALUE      | f
+         | force_parallel_mode                 | SET VALUE      | f
+         | from_collapse_limit                 | SET VALUE      | f
+         | geqo                                | SET VALUE      | f
+         | geqo_effort                         | SET VALUE      | f
+         | geqo_generations                    | SET VALUE      | f
+         | geqo_pool_size                      | SET VALUE      | f
+         | geqo_seed                           | SET VALUE      | f
+         | geqo_selection_bias                 | SET VALUE      | f
+         | geqo_threshold                      | SET VALUE      | f
+         | gin_fuzzy_search_limit              | SET VALUE      | f
+         | gin_pending_list_limit              | SET VALUE      | f
+         | hash_mem_multiplier                 | SET VALUE      | f
+         | idle_in_transaction_session_timeout | SET VALUE      | f
+         | idle_session_timeout                | SET VALUE      | f
+         | jit                                 | SET VALUE      | f
+         | jit_above_cost                      | SET VALUE      | f
+         | jit_expressions                     | SET VALUE      | f
+         | jit_inline_above_cost               | SET VALUE      | f
+         | jit_optimize_above_cost             | SET VALUE      | f
+         | jit_tuple_deforming                 | SET VALUE      | f
+         | join_collapse_limit                 | SET VALUE      | f
+         | lc_monetary                         | SET VALUE      | f
+         | lc_numeric                          | SET VALUE      | f
+         | lc_time                             | SET VALUE      | f
+         | local_preload_libraries             | SET VALUE      | f
+         | lock_timeout                        | SET VALUE      | f
+         | log_parameter_max_length_on_error   | SET VALUE      | f
+         | logical_decoding_work_mem           | SET VALUE      | f
+         | maintenance_io_concurrency          | SET VALUE      | f
+         | maintenance_work_mem                | SET VALUE      | f
+         | max_parallel_maintenance_workers    | SET VALUE      | f
+         | max_parallel_workers                | SET VALUE      | f
+         | max_parallel_workers_per_gather     | SET VALUE      | f
+         | min_parallel_index_scan_size        | SET VALUE      | f
+         | min_parallel_table_scan_size        | SET VALUE      | f
+         | optimize_bounded_sort               | SET VALUE      | f
+         | parallel_leader_participation       | SET VALUE      | f
+         | parallel_setup_cost                 | SET VALUE      | f
+         | parallel_tuple_cost                 | SET VALUE      | f
+         | password_encryption                 | SET VALUE      | f
+         | plan_cache_mode                     | SET VALUE      | f
+         | quote_all_identifiers               | SET VALUE      | f
+         | random_page_cost                    | SET VALUE      | f
+         | role                                | SET VALUE      | f
+         | row_security                        | SET VALUE      | f
+         | search_path                         | SET VALUE      | f
+         | seed                                | SET VALUE      | f
+         | seq_page_cost                       | SET VALUE      | f
+         | ssl_renegotiation_limit             | SET VALUE      | f
+         | standard_conforming_strings         | SET VALUE      | f
+         | statement_timeout                   | SET VALUE      | f
+         | synchronize_seqscans                | SET VALUE      | f
+         | synchronous_commit                  | SET VALUE      | f
+         | tcp_keepalives_count                | SET VALUE      | f
+         | tcp_keepalives_idle                 | SET VALUE      | f
+         | tcp_keepalives_interval             | SET VALUE      | f
+         | tcp_user_timeout                    | SET VALUE      | f
+         | temp_buffers                        | SET VALUE      | f
+         | temp_tablespaces                    | SET VALUE      | f
+         | timezone_abbreviations              | SET VALUE      | f
+         | trace_notify                        | SET VALUE      | f
+         | trace_sort                          | SET VALUE      | f
+         | trace_syncscan                      | SET VALUE      | f
+         | transaction_deferrable              | SET VALUE      | f
+         | transaction_isolation               | SET VALUE      | f
+         | transaction_read_only               | SET VALUE      | f
+         | transform_null_equals               | SET VALUE      | f
+         | vacuum_cost_delay                   | SET VALUE      | f
+         | vacuum_cost_limit                   | SET VALUE      | f
+         | vacuum_cost_page_dirty              | SET VALUE      | f
+         | vacuum_cost_page_hit                | SET VALUE      | f
+         | vacuum_cost_page_miss               | SET VALUE      | f
+         | vacuum_failsafe_age                 | SET VALUE      | f
+         | vacuum_freeze_min_age               | SET VALUE      | f
+         | vacuum_freeze_table_age             | SET VALUE      | f
+         | vacuum_multixact_failsafe_age       | SET VALUE      | f
+         | vacuum_multixact_freeze_min_age     | SET VALUE      | f
+         | vacuum_multixact_freeze_table_age   | SET VALUE      | f
+         | wal_sender_timeout                  | SET VALUE      | f
+         | wal_skip_threshold                  | SET VALUE      | f
+         | work_mem                            | SET VALUE      | f
+         | xmlbinary                           | SET VALUE      | f
+         | xmloption                           | SET VALUE      | f
+(138 rows)
+
+-- Create non-superuser with privileges to configure host resource usage
+CREATE ROLE regress_host_resource_admin NOSUPERUSER;
+-- Check the new role does not yet have privileges on settings
+SELECT has_setting_privilege('regress_host_resource_admin', 'work_mem', 'SET VALUE, ALTER SYSTEM');
+ has_setting_privilege 
+-----------------------
+ t
+(1 row)
+
+SELECT has_setting_privilege('regress_host_resource_admin', 'work_mem', 'SET VALUE');
+ has_setting_privilege 
+-----------------------
+ t
+(1 row)
+
+SELECT has_setting_privilege('regress_host_resource_admin', 'work_mem', 'ALTER SYSTEM');
+ has_setting_privilege 
+-----------------------
+ f
+(1 row)
+
+-- Check inappropriate and nonsense privilege types
+SELECT has_setting_privilege('regress_host_resource_admin', 'work_mem', 'SELECT, UPDATE, CREATE');
+ERROR:  unrecognized privilege type: "SELECT"
+SELECT has_setting_privilege('regress_host_resource_admin', 'work_mem', 'USAGE');
+ERROR:  unrecognized privilege type: "USAGE"
+SELECT has_setting_privilege('regress_host_resource_admin', 'work_mem', 'WHATEVER');
+ERROR:  unrecognized privilege type: "WHATEVER"
+-- Grant privileges on settings to the new non-superuser role
+GRANT SET VALUE, ALTER SYSTEM ON
+	autovacuum_work_mem, hash_mem_multiplier, logical_decoding_work_mem,
+	maintenance_work_mem, max_stack_depth, min_dynamic_shared_memory,
+	shared_buffers, temp_buffers, temp_file_limit, work_mem
+TO regress_host_resource_admin;
+-- Check setting privileges after creating some
+SELECT grantee, setting, privilege_type, is_grantable
+	FROM pg_catalog.pg_setting_privileges
+	ORDER BY grantee, setting, privilege_type;
+           grantee           |               setting               | privilege_type | is_grantable 
+-----------------------------+-------------------------------------+----------------+--------------
+ regress_host_resource_admin | autovacuum_work_mem                 | ALTER SYSTEM   | f
+ regress_host_resource_admin | autovacuum_work_mem                 | SET VALUE      | f
+ regress_host_resource_admin | hash_mem_multiplier                 | ALTER SYSTEM   | f
+ regress_host_resource_admin | hash_mem_multiplier                 | SET VALUE      | f
+ regress_host_resource_admin | logical_decoding_work_mem           | ALTER SYSTEM   | f
+ regress_host_resource_admin | logical_decoding_work_mem           | SET VALUE      | f
+ regress_host_resource_admin | maintenance_work_mem                | ALTER SYSTEM   | f
+ regress_host_resource_admin | maintenance_work_mem                | SET VALUE      | f
+ regress_host_resource_admin | max_stack_depth                     | ALTER SYSTEM   | f
+ regress_host_resource_admin | max_stack_depth                     | SET VALUE      | f
+ regress_host_resource_admin | min_dynamic_shared_memory           | ALTER SYSTEM   | f
+ regress_host_resource_admin | min_dynamic_shared_memory           | SET VALUE      | f
+ regress_host_resource_admin | shared_buffers                      | ALTER SYSTEM   | f
+ regress_host_resource_admin | shared_buffers                      | SET VALUE      | f
+ regress_host_resource_admin | temp_buffers                        | ALTER SYSTEM   | f
+ regress_host_resource_admin | temp_buffers                        | SET VALUE      | f
+ regress_host_resource_admin | temp_file_limit                     | ALTER SYSTEM   | f
+ regress_host_resource_admin | temp_file_limit                     | SET VALUE      | f
+ regress_host_resource_admin | work_mem                            | ALTER SYSTEM   | f
+ regress_host_resource_admin | work_mem                            | SET VALUE      | f
+                             | DateStyle                           | SET VALUE      | f
+                             | IntervalStyle                       | SET VALUE      | f
+                             | TimeZone                            | SET VALUE      | f
+                             | application_name                    | SET VALUE      | f
+                             | array_nulls                         | SET VALUE      | f
+                             | backend_flush_after                 | SET VALUE      | f
+                             | backslash_quote                     | SET VALUE      | f
+                             | bytea_output                        | SET VALUE      | f
+                             | check_function_bodies               | SET VALUE      | f
+                             | client_connection_check_interval    | SET VALUE      | f
+                             | client_min_messages                 | SET VALUE      | f
+                             | commit_siblings                     | SET VALUE      | f
+                             | constraint_exclusion                | SET VALUE      | f
+                             | cpu_index_tuple_cost                | SET VALUE      | f
+                             | cpu_operator_cost                   | SET VALUE      | f
+                             | cpu_tuple_cost                      | SET VALUE      | f
+                             | cursor_tuple_fraction               | SET VALUE      | f
+                             | debug_pretty_print                  | SET VALUE      | f
+                             | debug_print_parse                   | SET VALUE      | f
+                             | debug_print_plan                    | SET VALUE      | f
+                             | debug_print_rewritten               | SET VALUE      | f
+                             | default_statistics_target           | SET VALUE      | f
+                             | default_table_access_method         | SET VALUE      | f
+                             | default_tablespace                  | SET VALUE      | f
+                             | default_text_search_config          | SET VALUE      | f
+                             | default_toast_compression           | SET VALUE      | f
+                             | default_transaction_deferrable      | SET VALUE      | f
+                             | default_transaction_isolation       | SET VALUE      | f
+                             | default_transaction_read_only       | SET VALUE      | f
+                             | default_with_oids                   | SET VALUE      | f
+                             | effective_cache_size                | SET VALUE      | f
+                             | effective_io_concurrency            | SET VALUE      | f
+                             | enable_async_append                 | SET VALUE      | f
+                             | enable_bitmapscan                   | SET VALUE      | f
+                             | enable_gathermerge                  | SET VALUE      | f
+                             | enable_hashagg                      | SET VALUE      | f
+                             | enable_hashjoin                     | SET VALUE      | f
+                             | enable_incremental_sort             | SET VALUE      | f
+                             | enable_indexonlyscan                | SET VALUE      | f
+                             | enable_indexscan                    | SET VALUE      | f
+                             | enable_material                     | SET VALUE      | f
+                             | enable_memoize                      | SET VALUE      | f
+                             | enable_mergejoin                    | SET VALUE      | f
+                             | enable_nestloop                     | SET VALUE      | f
+                             | enable_parallel_append              | SET VALUE      | f
+                             | enable_parallel_hash                | SET VALUE      | f
+                             | enable_partition_pruning            | SET VALUE      | f
+                             | enable_partitionwise_aggregate      | SET VALUE      | f
+                             | enable_partitionwise_join           | SET VALUE      | f
+                             | enable_seqscan                      | SET VALUE      | f
+                             | enable_sort                         | SET VALUE      | f
+                             | enable_tidscan                      | SET VALUE      | f
+                             | escape_string_warning               | SET VALUE      | f
+                             | exit_on_error                       | SET VALUE      | f
+                             | extra_float_digits                  | SET VALUE      | f
+                             | force_parallel_mode                 | SET VALUE      | f
+                             | from_collapse_limit                 | SET VALUE      | f
+                             | geqo                                | SET VALUE      | f
+                             | geqo_effort                         | SET VALUE      | f
+                             | geqo_generations                    | SET VALUE      | f
+                             | geqo_pool_size                      | SET VALUE      | f
+                             | geqo_seed                           | SET VALUE      | f
+                             | geqo_selection_bias                 | SET VALUE      | f
+                             | geqo_threshold                      | SET VALUE      | f
+                             | gin_fuzzy_search_limit              | SET VALUE      | f
+                             | gin_pending_list_limit              | SET VALUE      | f
+                             | hash_mem_multiplier                 | SET VALUE      | f
+                             | idle_in_transaction_session_timeout | SET VALUE      | f
+                             | idle_session_timeout                | SET VALUE      | f
+                             | jit                                 | SET VALUE      | f
+                             | jit_above_cost                      | SET VALUE      | f
+                             | jit_expressions                     | SET VALUE      | f
+                             | jit_inline_above_cost               | SET VALUE      | f
+                             | jit_optimize_above_cost             | SET VALUE      | f
+                             | jit_tuple_deforming                 | SET VALUE      | f
+                             | join_collapse_limit                 | SET VALUE      | f
+                             | lc_monetary                         | SET VALUE      | f
+                             | lc_numeric                          | SET VALUE      | f
+                             | lc_time                             | SET VALUE      | f
+                             | local_preload_libraries             | SET VALUE      | f
+                             | lock_timeout                        | SET VALUE      | f
+                             | log_parameter_max_length_on_error   | SET VALUE      | f
+                             | logical_decoding_work_mem           | SET VALUE      | f
+                             | maintenance_io_concurrency          | SET VALUE      | f
+                             | maintenance_work_mem                | SET VALUE      | f
+                             | max_parallel_maintenance_workers    | SET VALUE      | f
+                             | max_parallel_workers                | SET VALUE      | f
+                             | max_parallel_workers_per_gather     | SET VALUE      | f
+                             | min_parallel_index_scan_size        | SET VALUE      | f
+                             | min_parallel_table_scan_size        | SET VALUE      | f
+                             | optimize_bounded_sort               | SET VALUE      | f
+                             | parallel_leader_participation       | SET VALUE      | f
+                             | parallel_setup_cost                 | SET VALUE      | f
+                             | parallel_tuple_cost                 | SET VALUE      | f
+                             | password_encryption                 | SET VALUE      | f
+                             | plan_cache_mode                     | SET VALUE      | f
+                             | quote_all_identifiers               | SET VALUE      | f
+                             | random_page_cost                    | SET VALUE      | f
+                             | role                                | SET VALUE      | f
+                             | row_security                        | SET VALUE      | f
+                             | search_path                         | SET VALUE      | f
+                             | seed                                | SET VALUE      | f
+                             | seq_page_cost                       | SET VALUE      | f
+                             | ssl_renegotiation_limit             | SET VALUE      | f
+                             | standard_conforming_strings         | SET VALUE      | f
+                             | statement_timeout                   | SET VALUE      | f
+                             | synchronize_seqscans                | SET VALUE      | f
+                             | synchronous_commit                  | SET VALUE      | f
+                             | tcp_keepalives_count                | SET VALUE      | f
+                             | tcp_keepalives_idle                 | SET VALUE      | f
+                             | tcp_keepalives_interval             | SET VALUE      | f
+                             | tcp_user_timeout                    | SET VALUE      | f
+                             | temp_buffers                        | SET VALUE      | f
+                             | temp_tablespaces                    | SET VALUE      | f
+                             | timezone_abbreviations              | SET VALUE      | f
+                             | trace_notify                        | SET VALUE      | f
+                             | trace_sort                          | SET VALUE      | f
+                             | trace_syncscan                      | SET VALUE      | f
+                             | transaction_deferrable              | SET VALUE      | f
+                             | transaction_isolation               | SET VALUE      | f
+                             | transaction_read_only               | SET VALUE      | f
+                             | transform_null_equals               | SET VALUE      | f
+                             | vacuum_cost_delay                   | SET VALUE      | f
+                             | vacuum_cost_limit                   | SET VALUE      | f
+                             | vacuum_cost_page_dirty              | SET VALUE      | f
+                             | vacuum_cost_page_hit                | SET VALUE      | f
+                             | vacuum_cost_page_miss               | SET VALUE      | f
+                             | vacuum_failsafe_age                 | SET VALUE      | f
+                             | vacuum_freeze_min_age               | SET VALUE      | f
+                             | vacuum_freeze_table_age             | SET VALUE      | f
+                             | vacuum_multixact_failsafe_age       | SET VALUE      | f
+                             | vacuum_multixact_freeze_min_age     | SET VALUE      | f
+                             | vacuum_multixact_freeze_table_age   | SET VALUE      | f
+                             | wal_sender_timeout                  | SET VALUE      | f
+                             | wal_skip_threshold                  | SET VALUE      | f
+                             | work_mem                            | SET VALUE      | f
+                             | xmlbinary                           | SET VALUE      | f
+                             | xmloption                           | SET VALUE      | f
+(158 rows)
+
+-- Check the new role now has privilges on settings
+SELECT has_setting_privilege('regress_host_resource_admin', 'work_mem', 'SET VALUE, ALTER SYSTEM');
+ has_setting_privilege 
+-----------------------
+ t
+(1 row)
+
+SELECT has_setting_privilege('regress_host_resource_admin', 'work_mem', 'SET VALUE');
+ has_setting_privilege 
+-----------------------
+ t
+(1 row)
+
+SELECT has_setting_privilege('regress_host_resource_admin', 'work_mem', 'ALTER SYSTEM');
+ has_setting_privilege 
+-----------------------
+ t
+(1 row)
+
+SELECT has_setting_privilege('regress_host_resource_admin', 'work_mem', 'SET VALUE WITH GRANT OPTION, ALTER SYSTEM WITH GRANT OPTION');
+ has_setting_privilege 
+-----------------------
+ f
+(1 row)
+
+-- Check again the inappropriate and nonsense privilege types.  The prior similar check
+-- was performed before any entry for work_mem existed.
+SELECT has_setting_privilege('regress_host_resource_admin', 'work_mem', 'SELECT, UPDATE, CREATE');
+ERROR:  unrecognized privilege type: "SELECT"
+SELECT has_setting_privilege('regress_host_resource_admin', 'work_mem', 'USAGE');
+ERROR:  unrecognized privilege type: "USAGE"
+SELECT has_setting_privilege('regress_host_resource_admin', 'work_mem', 'WHATEVER');
+ERROR:  unrecognized privilege type: "WHATEVER"
+SELECT has_setting_privilege('regress_host_resource_admin', 'work_mem', 'WHATEVER WITH GRANT OPTION');
+ERROR:  unrecognized privilege type: "WHATEVER WITH GRANT OPTION"
+-- Check other function signatures
+SELECT has_setting_privilege('regress_host_resource_admin',
+							 (SELECT oid FROM pg_catalog.pg_setting_acl WHERE setting = 'max_stack_depth'),
+							 'SET VALUE');
+ has_setting_privilege 
+-----------------------
+ t
+(1 row)
+
+SELECT has_setting_privilege((SELECT oid FROM pg_catalog.pg_authid WHERE rolname = 'regress_host_resource_admin'),
+							 'max_stack_depth',
+							 'SET VALUE');
+ has_setting_privilege 
+-----------------------
+ t
+(1 row)
+
+SELECT has_setting_privilege((SELECT oid FROM pg_catalog.pg_authid WHERE rolname = 'regress_host_resource_admin'),
+							 (SELECT oid FROM pg_catalog.pg_setting_acl WHERE setting = 'max_stack_depth'),
+							 'SET VALUE');
+ has_setting_privilege 
+-----------------------
+ t
+(1 row)
+
+SELECT has_setting_privilege('hash_mem_multiplier', 'set value');
+ has_setting_privilege 
+-----------------------
+ t
+(1 row)
+
+SELECT has_setting_privilege((SELECT oid FROM pg_catalog.pg_setting_acl WHERE setting = 'work_mem'),
+							 'alter system with grant option');
+ has_setting_privilege 
+-----------------------
+ t
+(1 row)
+
+-- Check setting privileges show up in view
+SELECT grantee, setting, privilege_type, is_grantable
+	FROM pg_catalog.pg_setting_privileges
+	ORDER BY grantee, setting, privilege_type;
+           grantee           |               setting               | privilege_type | is_grantable 
+-----------------------------+-------------------------------------+----------------+--------------
+ regress_host_resource_admin | autovacuum_work_mem                 | ALTER SYSTEM   | f
+ regress_host_resource_admin | autovacuum_work_mem                 | SET VALUE      | f
+ regress_host_resource_admin | hash_mem_multiplier                 | ALTER SYSTEM   | f
+ regress_host_resource_admin | hash_mem_multiplier                 | SET VALUE      | f
+ regress_host_resource_admin | logical_decoding_work_mem           | ALTER SYSTEM   | f
+ regress_host_resource_admin | logical_decoding_work_mem           | SET VALUE      | f
+ regress_host_resource_admin | maintenance_work_mem                | ALTER SYSTEM   | f
+ regress_host_resource_admin | maintenance_work_mem                | SET VALUE      | f
+ regress_host_resource_admin | max_stack_depth                     | ALTER SYSTEM   | f
+ regress_host_resource_admin | max_stack_depth                     | SET VALUE      | f
+ regress_host_resource_admin | min_dynamic_shared_memory           | ALTER SYSTEM   | f
+ regress_host_resource_admin | min_dynamic_shared_memory           | SET VALUE      | f
+ regress_host_resource_admin | shared_buffers                      | ALTER SYSTEM   | f
+ regress_host_resource_admin | shared_buffers                      | SET VALUE      | f
+ regress_host_resource_admin | temp_buffers                        | ALTER SYSTEM   | f
+ regress_host_resource_admin | temp_buffers                        | SET VALUE      | f
+ regress_host_resource_admin | temp_file_limit                     | ALTER SYSTEM   | f
+ regress_host_resource_admin | temp_file_limit                     | SET VALUE      | f
+ regress_host_resource_admin | work_mem                            | ALTER SYSTEM   | f
+ regress_host_resource_admin | work_mem                            | SET VALUE      | f
+                             | DateStyle                           | SET VALUE      | f
+                             | IntervalStyle                       | SET VALUE      | f
+                             | TimeZone                            | SET VALUE      | f
+                             | application_name                    | SET VALUE      | f
+                             | array_nulls                         | SET VALUE      | f
+                             | backend_flush_after                 | SET VALUE      | f
+                             | backslash_quote                     | SET VALUE      | f
+                             | bytea_output                        | SET VALUE      | f
+                             | check_function_bodies               | SET VALUE      | f
+                             | client_connection_check_interval    | SET VALUE      | f
+                             | client_min_messages                 | SET VALUE      | f
+                             | commit_siblings                     | SET VALUE      | f
+                             | constraint_exclusion                | SET VALUE      | f
+                             | cpu_index_tuple_cost                | SET VALUE      | f
+                             | cpu_operator_cost                   | SET VALUE      | f
+                             | cpu_tuple_cost                      | SET VALUE      | f
+                             | cursor_tuple_fraction               | SET VALUE      | f
+                             | debug_pretty_print                  | SET VALUE      | f
+                             | debug_print_parse                   | SET VALUE      | f
+                             | debug_print_plan                    | SET VALUE      | f
+                             | debug_print_rewritten               | SET VALUE      | f
+                             | default_statistics_target           | SET VALUE      | f
+                             | default_table_access_method         | SET VALUE      | f
+                             | default_tablespace                  | SET VALUE      | f
+                             | default_text_search_config          | SET VALUE      | f
+                             | default_toast_compression           | SET VALUE      | f
+                             | default_transaction_deferrable      | SET VALUE      | f
+                             | default_transaction_isolation       | SET VALUE      | f
+                             | default_transaction_read_only       | SET VALUE      | f
+                             | default_with_oids                   | SET VALUE      | f
+                             | effective_cache_size                | SET VALUE      | f
+                             | effective_io_concurrency            | SET VALUE      | f
+                             | enable_async_append                 | SET VALUE      | f
+                             | enable_bitmapscan                   | SET VALUE      | f
+                             | enable_gathermerge                  | SET VALUE      | f
+                             | enable_hashagg                      | SET VALUE      | f
+                             | enable_hashjoin                     | SET VALUE      | f
+                             | enable_incremental_sort             | SET VALUE      | f
+                             | enable_indexonlyscan                | SET VALUE      | f
+                             | enable_indexscan                    | SET VALUE      | f
+                             | enable_material                     | SET VALUE      | f
+                             | enable_memoize                      | SET VALUE      | f
+                             | enable_mergejoin                    | SET VALUE      | f
+                             | enable_nestloop                     | SET VALUE      | f
+                             | enable_parallel_append              | SET VALUE      | f
+                             | enable_parallel_hash                | SET VALUE      | f
+                             | enable_partition_pruning            | SET VALUE      | f
+                             | enable_partitionwise_aggregate      | SET VALUE      | f
+                             | enable_partitionwise_join           | SET VALUE      | f
+                             | enable_seqscan                      | SET VALUE      | f
+                             | enable_sort                         | SET VALUE      | f
+                             | enable_tidscan                      | SET VALUE      | f
+                             | escape_string_warning               | SET VALUE      | f
+                             | exit_on_error                       | SET VALUE      | f
+                             | extra_float_digits                  | SET VALUE      | f
+                             | force_parallel_mode                 | SET VALUE      | f
+                             | from_collapse_limit                 | SET VALUE      | f
+                             | geqo                                | SET VALUE      | f
+                             | geqo_effort                         | SET VALUE      | f
+                             | geqo_generations                    | SET VALUE      | f
+                             | geqo_pool_size                      | SET VALUE      | f
+                             | geqo_seed                           | SET VALUE      | f
+                             | geqo_selection_bias                 | SET VALUE      | f
+                             | geqo_threshold                      | SET VALUE      | f
+                             | gin_fuzzy_search_limit              | SET VALUE      | f
+                             | gin_pending_list_limit              | SET VALUE      | f
+                             | hash_mem_multiplier                 | SET VALUE      | f
+                             | idle_in_transaction_session_timeout | SET VALUE      | f
+                             | idle_session_timeout                | SET VALUE      | f
+                             | jit                                 | SET VALUE      | f
+                             | jit_above_cost                      | SET VALUE      | f
+                             | jit_expressions                     | SET VALUE      | f
+                             | jit_inline_above_cost               | SET VALUE      | f
+                             | jit_optimize_above_cost             | SET VALUE      | f
+                             | jit_tuple_deforming                 | SET VALUE      | f
+                             | join_collapse_limit                 | SET VALUE      | f
+                             | lc_monetary                         | SET VALUE      | f
+                             | lc_numeric                          | SET VALUE      | f
+                             | lc_time                             | SET VALUE      | f
+                             | local_preload_libraries             | SET VALUE      | f
+                             | lock_timeout                        | SET VALUE      | f
+                             | log_parameter_max_length_on_error   | SET VALUE      | f
+                             | logical_decoding_work_mem           | SET VALUE      | f
+                             | maintenance_io_concurrency          | SET VALUE      | f
+                             | maintenance_work_mem                | SET VALUE      | f
+                             | max_parallel_maintenance_workers    | SET VALUE      | f
+                             | max_parallel_workers                | SET VALUE      | f
+                             | max_parallel_workers_per_gather     | SET VALUE      | f
+                             | min_parallel_index_scan_size        | SET VALUE      | f
+                             | min_parallel_table_scan_size        | SET VALUE      | f
+                             | optimize_bounded_sort               | SET VALUE      | f
+                             | parallel_leader_participation       | SET VALUE      | f
+                             | parallel_setup_cost                 | SET VALUE      | f
+                             | parallel_tuple_cost                 | SET VALUE      | f
+                             | password_encryption                 | SET VALUE      | f
+                             | plan_cache_mode                     | SET VALUE      | f
+                             | quote_all_identifiers               | SET VALUE      | f
+                             | random_page_cost                    | SET VALUE      | f
+                             | role                                | SET VALUE      | f
+                             | row_security                        | SET VALUE      | f
+                             | search_path                         | SET VALUE      | f
+                             | seed                                | SET VALUE      | f
+                             | seq_page_cost                       | SET VALUE      | f
+                             | ssl_renegotiation_limit             | SET VALUE      | f
+                             | standard_conforming_strings         | SET VALUE      | f
+                             | statement_timeout                   | SET VALUE      | f
+                             | synchronize_seqscans                | SET VALUE      | f
+                             | synchronous_commit                  | SET VALUE      | f
+                             | tcp_keepalives_count                | SET VALUE      | f
+                             | tcp_keepalives_idle                 | SET VALUE      | f
+                             | tcp_keepalives_interval             | SET VALUE      | f
+                             | tcp_user_timeout                    | SET VALUE      | f
+                             | temp_buffers                        | SET VALUE      | f
+                             | temp_tablespaces                    | SET VALUE      | f
+                             | timezone_abbreviations              | SET VALUE      | f
+                             | trace_notify                        | SET VALUE      | f
+                             | trace_sort                          | SET VALUE      | f
+                             | trace_syncscan                      | SET VALUE      | f
+                             | transaction_deferrable              | SET VALUE      | f
+                             | transaction_isolation               | SET VALUE      | f
+                             | transaction_read_only               | SET VALUE      | f
+                             | transform_null_equals               | SET VALUE      | f
+                             | vacuum_cost_delay                   | SET VALUE      | f
+                             | vacuum_cost_limit                   | SET VALUE      | f
+                             | vacuum_cost_page_dirty              | SET VALUE      | f
+                             | vacuum_cost_page_hit                | SET VALUE      | f
+                             | vacuum_cost_page_miss               | SET VALUE      | f
+                             | vacuum_failsafe_age                 | SET VALUE      | f
+                             | vacuum_freeze_min_age               | SET VALUE      | f
+                             | vacuum_freeze_table_age             | SET VALUE      | f
+                             | vacuum_multixact_failsafe_age       | SET VALUE      | f
+                             | vacuum_multixact_freeze_min_age     | SET VALUE      | f
+                             | vacuum_multixact_freeze_table_age   | SET VALUE      | f
+                             | wal_sender_timeout                  | SET VALUE      | f
+                             | wal_skip_threshold                  | SET VALUE      | f
+                             | work_mem                            | SET VALUE      | f
+                             | xmlbinary                           | SET VALUE      | f
+                             | xmloption                           | SET VALUE      | f
+(158 rows)
+
+-- Perform all operations as user 'regress_host_resource_admin' --
+SET SESSION AUTHORIZATION regress_host_resource_admin;
+ALTER SYSTEM SET autovacuum_work_mem = 32;  -- ok, privileges have been granted
+ALTER SYSTEM SET ignore_system_indexes = OFF;  -- fail, insufficient privileges
+ERROR:  permission denied to set parameter "ignore_system_indexes"
+ALTER SYSTEM RESET autovacuum_multixact_freeze_max_age;  -- fail, insufficient privileges
+ERROR:  permission denied to set parameter "autovacuum_multixact_freeze_max_age"
+SET jit_provider = 'llvmjit';  -- fail, insufficient privileges
+ERROR:  parameter "jit_provider" cannot be changed without restarting the server
+ALTER SYSTEM SET shared_buffers = 50;  -- ok
+ALTER SYSTEM RESET shared_buffers;  -- ok
+SET autovacuum_work_mem = 50;  -- cannot be changed now
+ERROR:  parameter "autovacuum_work_mem" cannot be changed now
+ALTER SYSTEM RESET temp_file_limit;  -- ok
+SET TimeZone = 'Europe/Helsinki';  -- ok
+ALTER SYSTEM RESET autovacuum_work_mem;  -- ok, privileges have been granted
+RESET TimeZone;  -- ok
+SET SESSION AUTHORIZATION regress_admin;
+DROP ROLE regress_host_resource_admin;  -- fail, privileges remain
+ERROR:  role "regress_host_resource_admin" cannot be dropped because some objects depend on it
+DETAIL:  privileges for setting temp_buffers
+privileges for setting work_mem
+privileges for setting maintenance_work_mem
+privileges for setting logical_decoding_work_mem
+privileges for setting hash_mem_multiplier
+privileges for setting autovacuum_work_mem
+privileges for setting max_stack_depth
+privileges for setting min_dynamic_shared_memory
+privileges for setting shared_buffers
+privileges for setting temp_file_limit
+-- Use "revoke" to remove the privileges and allow the role to be dropped
+REVOKE SET VALUE, ALTER SYSTEM ON
+	autovacuum_work_mem, hash_mem_multiplier, logical_decoding_work_mem,
+	maintenance_work_mem, max_stack_depth, min_dynamic_shared_memory,
+	shared_buffers, temp_buffers, temp_file_limit, work_mem
+FROM regress_host_resource_admin;
+DROP ROLE regress_host_resource_admin;  -- ok
+-- Try that again, but use "drop owned by" instead of "revoke"
+CREATE ROLE regress_host_resource_admin NOSUPERUSER;
+SET SESSION AUTHORIZATION regress_host_resource_admin;
+ALTER SYSTEM SET autovacuum_work_mem = 32;  -- fail, privileges not yet granted
+ERROR:  permission denied to set parameter "autovacuum_work_mem"
+SET SESSION AUTHORIZATION regress_admin;
+GRANT SET VALUE, ALTER SYSTEM ON
+	autovacuum_work_mem, hash_mem_multiplier, logical_decoding_work_mem,
+	maintenance_work_mem, max_stack_depth, min_dynamic_shared_memory,
+	shared_buffers, temp_buffers, temp_file_limit, work_mem
+TO regress_host_resource_admin;
+DROP ROLE regress_host_resource_admin;  -- fail, privileges remain
+ERROR:  role "regress_host_resource_admin" cannot be dropped because some objects depend on it
+DETAIL:  privileges for setting temp_buffers
+privileges for setting work_mem
+privileges for setting maintenance_work_mem
+privileges for setting logical_decoding_work_mem
+privileges for setting hash_mem_multiplier
+privileges for setting autovacuum_work_mem
+privileges for setting max_stack_depth
+privileges for setting min_dynamic_shared_memory
+privileges for setting shared_buffers
+privileges for setting temp_file_limit
+DROP OWNED BY regress_host_resource_admin RESTRICT; -- cascade should not be needed
+SET SESSION AUTHORIZATION regress_host_resource_admin;
+ALTER SYSTEM SET autovacuum_work_mem = 32;  -- fail, "drop owned" has dropped privileges
+ERROR:  permission denied to set parameter "autovacuum_work_mem"
+SET SESSION AUTHORIZATION regress_admin;
+DROP ROLE regress_host_resource_admin;  -- ok
+-- Try that again, but use "reassign owned by" this time
+CREATE ROLE regress_host_resource_admin NOSUPERUSER;
+CREATE ROLE regress_host_resource_newadmin NOSUPERUSER;
+GRANT SET VALUE, ALTER SYSTEM ON
+	autovacuum_work_mem, hash_mem_multiplier, logical_decoding_work_mem,
+	maintenance_work_mem, max_stack_depth, min_dynamic_shared_memory,
+	shared_buffers, temp_buffers, temp_file_limit, work_mem
+TO regress_host_resource_admin;
+REASSIGN OWNED BY regress_host_resource_admin TO regress_host_resource_newadmin;
+SET SESSION AUTHORIZATION regress_host_resource_admin;
+ALTER SYSTEM SET autovacuum_work_mem = 32;  -- ok, "reassign owned" did not change privileges
+SET SESSION AUTHORIZATION regress_admin;
+DROP ROLE regress_host_resource_admin;  -- fail, privileges remain
+ERROR:  role "regress_host_resource_admin" cannot be dropped because some objects depend on it
+DETAIL:  privileges for setting temp_buffers
+privileges for setting work_mem
+privileges for setting maintenance_work_mem
+privileges for setting logical_decoding_work_mem
+privileges for setting hash_mem_multiplier
+privileges for setting autovacuum_work_mem
+privileges for setting max_stack_depth
+privileges for setting min_dynamic_shared_memory
+privileges for setting shared_buffers
+privileges for setting temp_file_limit
+DROP ROLE regress_host_resource_newadmin;  -- ok, nothing was transferred
+-- Use "drop owned by" so we can drop the role
+DROP OWNED BY regress_host_resource_admin;  -- ok
+DROP ROLE regress_host_resource_admin;  -- ok
+-- Create non-superuser with privileges to configure plgsql custom variables
+CREATE ROLE regress_plpgsql_admin NOSUPERUSER;
+-- Perform all operations as user 'regress_plpgsql_admin' --
+SET SESSION AUTHORIZATION regress_plpgsql_admin;
+SET plpgsql.extra_errors TO 'all';
+SET plpgsql.extra_warnings TO 'all';
+RESET plpgsql.extra_errors;
+RESET plpgsql.extra_warnings;
+ALTER SYSTEM SET plpgsql.extra_errors TO 'all';
+ERROR:  permission denied to set parameter "plpgsql.extra_errors"
+ALTER SYSTEM SET plpgsql.extra_warnings TO 'all';
+ERROR:  permission denied to set parameter "plpgsql.extra_warnings"
+ALTER SYSTEM RESET plpgsql.extra_errors;
+ERROR:  permission denied to set parameter "plpgsql.extra_errors"
+ALTER SYSTEM RESET plpgsql.extra_warnings;
+ERROR:  permission denied to set parameter "plpgsql.extra_warnings"
+SET SESSION AUTHORIZATION regress_admin;
+GRANT SET VALUE, ALTER SYSTEM ON
+	plpgsql.extra_warnings, plpgsql.extra_errors
+TO regress_plpgsql_admin;
+-- Perform all operations as user 'regress_plpgsql_admin' --
+SET SESSION AUTHORIZATION regress_plpgsql_admin;  -- ok
+SET plpgsql.extra_errors TO 'all';  -- ok
+SET plpgsql.extra_warnings TO 'all';  -- ok
+RESET plpgsql.extra_errors;  -- ok
+RESET plpgsql.extra_warnings;  -- ok
+ALTER SYSTEM SET plpgsql.extra_errors TO 'all';  -- ok
+ALTER SYSTEM SET plpgsql.extra_warnings TO 'all';  -- ok
+ALTER SYSTEM RESET plpgsql.extra_errors;  -- ok
+ALTER SYSTEM RESET plpgsql.extra_warnings;  -- ok
+SET SESSION AUTHORIZATION regress_admin;
+DROP ROLE regress_plpgsql_admin;  -- fail, privileges remain
+ERROR:  role "regress_plpgsql_admin" cannot be dropped because some objects depend on it
+DETAIL:  privileges for setting plpgsql.extra_warnings
+privileges for setting plpgsql.extra_errors
+REVOKE SET VALUE, ALTER SYSTEM ON
+	plpgsql.extra_warnings, plpgsql.extra_errors
+FROM regress_plpgsql_admin;
+DROP ROLE regress_plpgsql_admin;  -- ok
diff --git a/src/test/regress/expected/privileges.out b/src/test/regress/expected/privileges.out
index 0bc79be03d..6c8afdba57 100644
--- a/src/test/regress/expected/privileges.out
+++ b/src/test/regress/expected/privileges.out
@@ -54,6 +54,33 @@ REVOKE pg_read_all_settings FROM regress_priv_user8;
 DROP USER regress_priv_user10;
 DROP USER regress_priv_user9;
 DROP USER regress_priv_user8;
+GRANT SET VALUE ON enable_memoize TO regress_priv_user6;
+GRANT SET VALUE ON enable_nestloop TO regress_priv_user6;
+SET ROLE regress_priv_user6;
+SET enable_memoize TO false;
+SET enable_nestloop TO false;
+RESET enable_memoize;
+RESET enable_nestloop;
+RESET ROLE;
+GRANT ALTER SYSTEM ON enable_seqscan TO regress_priv_user7; -- ok
+GRANT ALTER SYSTEM ON sort_mem TO regress_priv_user7; -- old name for "work_mem"
+GRANT ALTER SYSTEM ON maintenance_work_mem TO regress_priv_user7; -- ok
+GRANT ALTER SYSTEM ON no_such_param TO regress_priv_user7; -- ok
+GRANT ALTER SYSTEM ON no_such_extension.no_such_param TO regress_priv_user7; -- ok
+GRANT ALTER SYSTEM ON no_such_extension.no_such_param.longer.than.maximum.namedata.length TO regress_priv_user7; -- ok
+GRANT ALTER SYSTEM ON "" TO regress_priv_user7; -- bad name
+ERROR:  zero-length delimited identifier at or near """"
+LINE 1: GRANT ALTER SYSTEM ON "" TO regress_priv_user7;
+                              ^
+GRANT ALTER SYSTEM ON " " TO regress_priv_user7; -- bad name
+ERROR:  invalid setting name " "
+GRANT ALTER SYSTEM ON " foo " TO regress_priv_user7; -- bad name
+ERROR:  invalid setting name " foo "
+GRANT SELECT ON public.persons2 TO regress_priv_user7;
+SET ROLE regress_priv_user7;
+ALTER SYSTEM SET enable_seqscan = OFF;
+ALTER SYSTEM RESET enable_seqscan;
+RESET ROLE;
 CREATE GROUP regress_priv_group1;
 CREATE GROUP regress_priv_group2 WITH USER regress_priv_user1, regress_priv_user2;
 ALTER GROUP regress_priv_group1 ADD USER regress_priv_user4;
@@ -2357,10 +2384,32 @@ DROP USER regress_priv_user2;
 DROP USER regress_priv_user3;
 DROP USER regress_priv_user4;
 DROP USER regress_priv_user5;
-DROP USER regress_priv_user6;
-DROP USER regress_priv_user7;
+DROP USER regress_priv_user6; -- privileges remain
+ERROR:  role "regress_priv_user6" cannot be dropped because some objects depend on it
+DETAIL:  privileges for setting enable_memoize
+privileges for setting enable_nestloop
+DROP USER regress_priv_user7; -- privileges remain
+ERROR:  role "regress_priv_user7" cannot be dropped because some objects depend on it
+DETAIL:  privileges for setting enable_seqscan
+privileges for setting work_mem
+privileges for setting maintenance_work_mem
+privileges for table persons2
+privileges for setting no_such_param
+privileges for setting no_such_extension.no_such_param
+privileges for setting no_such_extension.no_such_param.longer.than.maximum.namedata.length
 DROP USER regress_priv_user8; -- does not exist
 ERROR:  role "regress_priv_user8" does not exist
+REVOKE SELECT ON public.persons2 FROM regress_priv_user7;
+REVOKE ALTER SYSTEM ON enable_seqscan FROM regress_priv_user7; -- ok
+REVOKE ALTER SYSTEM ON work_mem FROM regress_priv_user7; -- ok, use new name
+REVOKE ALTER SYSTEM ON vacuum_mem FROM regress_priv_user7; -- ok, use old name
+REVOKE ALTER SYSTEM ON no_such_param FROM regress_priv_user7; -- ok
+REVOKE ALTER SYSTEM ON no_such_extension.no_such_param FROM regress_priv_user7; -- ok
+REVOKE ALTER SYSTEM ON no_such_extension.no_such_param.longer.than.maximum.namedata.length FROM regress_priv_user7; -- ok
+DROP USER regress_priv_user7; -- ok
+REVOKE SET VALUE ON enable_memoize FROM regress_priv_user6;
+REVOKE SET VALUE ON enable_nestloop FROM regress_priv_user6;
+DROP USER regress_priv_user6; -- ok
 -- permissions with LOCK TABLE
 CREATE USER regress_locktable_user;
 CREATE TABLE lock_table (a int);
diff --git a/src/test/regress/expected/rules.out b/src/test/regress/expected/rules.out
index b58b062b10..e262035269 100644
--- a/src/test/regress/expected/rules.out
+++ b/src/test/regress/expected/rules.out
@@ -1708,6 +1708,19 @@ pg_sequences| SELECT n.nspname AS schemaname,
      JOIN pg_class c ON ((c.oid = s.seqrelid)))
      LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace)))
   WHERE ((NOT pg_is_other_temp_schema(n.oid)) AND (c.relkind = 'S'::"char"));
+pg_setting_privileges| SELECT grantor.rolname AS grantor,
+    grantee.rolname AS grantee,
+    set_acl.setting,
+    acl.privilege_type,
+    acl.is_grantable
+   FROM pg_setting_acl set_acl,
+    ((LATERAL ( SELECT aclexplode.grantor,
+            aclexplode.grantee,
+            aclexplode.privilege_type,
+            aclexplode.is_grantable
+           FROM aclexplode(set_acl.setacl) aclexplode(grantor, grantee, privilege_type, is_grantable)) acl
+     LEFT JOIN pg_authid grantee ON ((acl.grantee = grantee.oid)))
+     LEFT JOIN pg_authid grantor ON ((acl.grantor = grantor.oid)));
 pg_settings| SELECT a.name,
     a.setting,
     a.unit,
diff --git a/src/test/regress/expected/sanity_check.out b/src/test/regress/expected/sanity_check.out
index 63706a28cc..4a8208c789 100644
--- a/src/test/regress/expected/sanity_check.out
+++ b/src/test/regress/expected/sanity_check.out
@@ -147,6 +147,7 @@ pg_replication_origin|t
 pg_rewrite|t
 pg_seclabel|t
 pg_sequence|t
+pg_setting_acl|t
 pg_shdepend|t
 pg_shdescription|t
 pg_shseclabel|t
diff --git a/src/test/regress/parallel_schedule b/src/test/regress/parallel_schedule
index 017e962fed..b45a203eb6 100644
--- a/src/test/regress/parallel_schedule
+++ b/src/test/regress/parallel_schedule
@@ -86,7 +86,7 @@ test: brin_bloom brin_multi
 # ----------
 # Another group of parallel tests
 # ----------
-test: create_table_like alter_generic alter_operator misc async dbsize misc_functions sysviews tsrf tid tidscan tidrangescan collate.icu.utf8 incremental_sort
+test: create_table_like alter_generic alter_operator misc async dbsize misc_functions sysviews tsrf tid tidscan tidrangescan collate.icu.utf8 incremental_sort guc_privs
 
 # rules cannot run concurrently with any test that creates
 # a view or rule in the public schema
diff --git a/src/test/regress/sql/guc_privs.sql b/src/test/regress/sql/guc_privs.sql
new file mode 100644
index 0000000000..076c136563
--- /dev/null
+++ b/src/test/regress/sql/guc_privs.sql
@@ -0,0 +1,185 @@
+-- Test superuser
+-- Superuser DBA
+CREATE ROLE regress_admin SUPERUSER;
+-- Perform all operations as user 'regress_admin' --
+SET SESSION AUTHORIZATION regress_admin;
+-- PGC_BACKEND
+SET ignore_system_indexes = OFF;  -- fail, cannot be set after connection start
+RESET ignore_system_indexes;  -- fail, cannot be set after connection start
+ALTER SYSTEM SET ignore_system_indexes = OFF;  -- ok
+ALTER SYSTEM RESET ignore_system_indexes;  -- ok
+-- PGC_INTERNAL
+SET block_size = 50;  -- fail, cannot be changed
+RESET block_size;  -- fail, cannot be changed
+ALTER SYSTEM SET block_size = 50;  -- fail, cannot be changed
+ALTER SYSTEM RESET block_size;  -- fail, cannot be changed
+-- PGC_POSTMASTER
+SET autovacuum_freeze_max_age = 1000050000;  -- fail, requires restart
+RESET autovacuum_freeze_max_age;  -- fail, requires restart
+ALTER SYSTEM SET autovacuum_freeze_max_age = 1000050000;  -- ok
+ALTER SYSTEM RESET autovacuum_freeze_max_age;  -- ok
+ALTER SYSTEM SET config_file = '/usr/local/data/postgresql.conf';  -- fail, cannot be changed
+ALTER SYSTEM RESET config_file;  -- fail, cannot be changed
+-- PGC_SIGHUP
+SET autovacuum = OFF;  -- fail, requires reload
+RESET autovacuum;  -- fail, requires reload
+ALTER SYSTEM SET autovacuum = OFF;  -- ok
+ALTER SYSTEM RESET autovacuum;  -- ok
+-- PGC_SUSET
+SET lc_messages = 'C';  -- ok
+RESET lc_messages;  -- ok
+ALTER SYSTEM SET lc_messages = 'C';  -- ok
+ALTER SYSTEM RESET lc_messages;  -- ok
+-- PGC_SU_BACKEND
+SET jit_debugging_support = OFF;  -- fail, cannot be set after connection start
+RESET jit_debugging_support;  -- fail, cannot be set after connection start
+ALTER SYSTEM SET jit_debugging_support = OFF;  -- ok
+ALTER SYSTEM RESET jit_debugging_support;  -- ok
+-- PGC_USERSET
+SET DateStyle = 'ISO, MDY';  -- ok
+RESET DateStyle;  -- ok
+ALTER SYSTEM SET DateStyle = 'ISO, MDY';  -- ok
+ALTER SYSTEM RESET DateStyle;  -- ok
+ALTER SYSTEM SET ssl_renegotiation_limit = 0;  -- fail, cannot be changed
+ALTER SYSTEM RESET ssl_renegotiation_limit;  -- fail, cannot be changed
+-- Finished testing superuser
+RESET statement_timeout;
+-- Check setting privileges prior to creating any
+SELECT grantee, setting, privilege_type, is_grantable
+	FROM pg_catalog.pg_setting_privileges
+	ORDER BY grantee, setting, privilege_type;
+-- Create non-superuser with privileges to configure host resource usage
+CREATE ROLE regress_host_resource_admin NOSUPERUSER;
+-- Check the new role does not yet have privileges on settings
+SELECT has_setting_privilege('regress_host_resource_admin', 'work_mem', 'SET VALUE, ALTER SYSTEM');
+SELECT has_setting_privilege('regress_host_resource_admin', 'work_mem', 'SET VALUE');
+SELECT has_setting_privilege('regress_host_resource_admin', 'work_mem', 'ALTER SYSTEM');
+-- Check inappropriate and nonsense privilege types
+SELECT has_setting_privilege('regress_host_resource_admin', 'work_mem', 'SELECT, UPDATE, CREATE');
+SELECT has_setting_privilege('regress_host_resource_admin', 'work_mem', 'USAGE');
+SELECT has_setting_privilege('regress_host_resource_admin', 'work_mem', 'WHATEVER');
+-- Grant privileges on settings to the new non-superuser role
+GRANT SET VALUE, ALTER SYSTEM ON
+	autovacuum_work_mem, hash_mem_multiplier, logical_decoding_work_mem,
+	maintenance_work_mem, max_stack_depth, min_dynamic_shared_memory,
+	shared_buffers, temp_buffers, temp_file_limit, work_mem
+TO regress_host_resource_admin;
+-- Check setting privileges after creating some
+SELECT grantee, setting, privilege_type, is_grantable
+	FROM pg_catalog.pg_setting_privileges
+	ORDER BY grantee, setting, privilege_type;
+-- Check the new role now has privilges on settings
+SELECT has_setting_privilege('regress_host_resource_admin', 'work_mem', 'SET VALUE, ALTER SYSTEM');
+SELECT has_setting_privilege('regress_host_resource_admin', 'work_mem', 'SET VALUE');
+SELECT has_setting_privilege('regress_host_resource_admin', 'work_mem', 'ALTER SYSTEM');
+SELECT has_setting_privilege('regress_host_resource_admin', 'work_mem', 'SET VALUE WITH GRANT OPTION, ALTER SYSTEM WITH GRANT OPTION');
+-- Check again the inappropriate and nonsense privilege types.  The prior similar check
+-- was performed before any entry for work_mem existed.
+SELECT has_setting_privilege('regress_host_resource_admin', 'work_mem', 'SELECT, UPDATE, CREATE');
+SELECT has_setting_privilege('regress_host_resource_admin', 'work_mem', 'USAGE');
+SELECT has_setting_privilege('regress_host_resource_admin', 'work_mem', 'WHATEVER');
+SELECT has_setting_privilege('regress_host_resource_admin', 'work_mem', 'WHATEVER WITH GRANT OPTION');
+-- Check other function signatures
+SELECT has_setting_privilege('regress_host_resource_admin',
+							 (SELECT oid FROM pg_catalog.pg_setting_acl WHERE setting = 'max_stack_depth'),
+							 'SET VALUE');
+SELECT has_setting_privilege((SELECT oid FROM pg_catalog.pg_authid WHERE rolname = 'regress_host_resource_admin'),
+							 'max_stack_depth',
+							 'SET VALUE');
+SELECT has_setting_privilege((SELECT oid FROM pg_catalog.pg_authid WHERE rolname = 'regress_host_resource_admin'),
+							 (SELECT oid FROM pg_catalog.pg_setting_acl WHERE setting = 'max_stack_depth'),
+							 'SET VALUE');
+SELECT has_setting_privilege('hash_mem_multiplier', 'set value');
+SELECT has_setting_privilege((SELECT oid FROM pg_catalog.pg_setting_acl WHERE setting = 'work_mem'),
+							 'alter system with grant option');
+-- Check setting privileges show up in view
+SELECT grantee, setting, privilege_type, is_grantable
+	FROM pg_catalog.pg_setting_privileges
+	ORDER BY grantee, setting, privilege_type;
+-- Perform all operations as user 'regress_host_resource_admin' --
+SET SESSION AUTHORIZATION regress_host_resource_admin;
+ALTER SYSTEM SET autovacuum_work_mem = 32;  -- ok, privileges have been granted
+ALTER SYSTEM SET ignore_system_indexes = OFF;  -- fail, insufficient privileges
+ALTER SYSTEM RESET autovacuum_multixact_freeze_max_age;  -- fail, insufficient privileges
+SET jit_provider = 'llvmjit';  -- fail, insufficient privileges
+ALTER SYSTEM SET shared_buffers = 50;  -- ok
+ALTER SYSTEM RESET shared_buffers;  -- ok
+SET autovacuum_work_mem = 50;  -- cannot be changed now
+ALTER SYSTEM RESET temp_file_limit;  -- ok
+SET TimeZone = 'Europe/Helsinki';  -- ok
+ALTER SYSTEM RESET autovacuum_work_mem;  -- ok, privileges have been granted
+RESET TimeZone;  -- ok
+SET SESSION AUTHORIZATION regress_admin;
+DROP ROLE regress_host_resource_admin;  -- fail, privileges remain
+-- Use "revoke" to remove the privileges and allow the role to be dropped
+REVOKE SET VALUE, ALTER SYSTEM ON
+	autovacuum_work_mem, hash_mem_multiplier, logical_decoding_work_mem,
+	maintenance_work_mem, max_stack_depth, min_dynamic_shared_memory,
+	shared_buffers, temp_buffers, temp_file_limit, work_mem
+FROM regress_host_resource_admin;
+DROP ROLE regress_host_resource_admin;  -- ok
+-- Try that again, but use "drop owned by" instead of "revoke"
+CREATE ROLE regress_host_resource_admin NOSUPERUSER;
+SET SESSION AUTHORIZATION regress_host_resource_admin;
+ALTER SYSTEM SET autovacuum_work_mem = 32;  -- fail, privileges not yet granted
+SET SESSION AUTHORIZATION regress_admin;
+GRANT SET VALUE, ALTER SYSTEM ON
+	autovacuum_work_mem, hash_mem_multiplier, logical_decoding_work_mem,
+	maintenance_work_mem, max_stack_depth, min_dynamic_shared_memory,
+	shared_buffers, temp_buffers, temp_file_limit, work_mem
+TO regress_host_resource_admin;
+DROP ROLE regress_host_resource_admin;  -- fail, privileges remain
+DROP OWNED BY regress_host_resource_admin RESTRICT; -- cascade should not be needed
+SET SESSION AUTHORIZATION regress_host_resource_admin;
+ALTER SYSTEM SET autovacuum_work_mem = 32;  -- fail, "drop owned" has dropped privileges
+SET SESSION AUTHORIZATION regress_admin;
+DROP ROLE regress_host_resource_admin;  -- ok
+-- Try that again, but use "reassign owned by" this time
+CREATE ROLE regress_host_resource_admin NOSUPERUSER;
+CREATE ROLE regress_host_resource_newadmin NOSUPERUSER;
+GRANT SET VALUE, ALTER SYSTEM ON
+	autovacuum_work_mem, hash_mem_multiplier, logical_decoding_work_mem,
+	maintenance_work_mem, max_stack_depth, min_dynamic_shared_memory,
+	shared_buffers, temp_buffers, temp_file_limit, work_mem
+TO regress_host_resource_admin;
+REASSIGN OWNED BY regress_host_resource_admin TO regress_host_resource_newadmin;
+SET SESSION AUTHORIZATION regress_host_resource_admin;
+ALTER SYSTEM SET autovacuum_work_mem = 32;  -- ok, "reassign owned" did not change privileges
+SET SESSION AUTHORIZATION regress_admin;
+DROP ROLE regress_host_resource_admin;  -- fail, privileges remain
+DROP ROLE regress_host_resource_newadmin;  -- ok, nothing was transferred
+-- Use "drop owned by" so we can drop the role
+DROP OWNED BY regress_host_resource_admin;  -- ok
+DROP ROLE regress_host_resource_admin;  -- ok
+-- Create non-superuser with privileges to configure plgsql custom variables
+CREATE ROLE regress_plpgsql_admin NOSUPERUSER;
+-- Perform all operations as user 'regress_plpgsql_admin' --
+SET SESSION AUTHORIZATION regress_plpgsql_admin;
+SET plpgsql.extra_errors TO 'all';
+SET plpgsql.extra_warnings TO 'all';
+RESET plpgsql.extra_errors;
+RESET plpgsql.extra_warnings;
+ALTER SYSTEM SET plpgsql.extra_errors TO 'all';
+ALTER SYSTEM SET plpgsql.extra_warnings TO 'all';
+ALTER SYSTEM RESET plpgsql.extra_errors;
+ALTER SYSTEM RESET plpgsql.extra_warnings;
+SET SESSION AUTHORIZATION regress_admin;
+GRANT SET VALUE, ALTER SYSTEM ON
+	plpgsql.extra_warnings, plpgsql.extra_errors
+TO regress_plpgsql_admin;
+-- Perform all operations as user 'regress_plpgsql_admin' --
+SET SESSION AUTHORIZATION regress_plpgsql_admin;  -- ok
+SET plpgsql.extra_errors TO 'all';  -- ok
+SET plpgsql.extra_warnings TO 'all';  -- ok
+RESET plpgsql.extra_errors;  -- ok
+RESET plpgsql.extra_warnings;  -- ok
+ALTER SYSTEM SET plpgsql.extra_errors TO 'all';  -- ok
+ALTER SYSTEM SET plpgsql.extra_warnings TO 'all';  -- ok
+ALTER SYSTEM RESET plpgsql.extra_errors;  -- ok
+ALTER SYSTEM RESET plpgsql.extra_warnings;  -- ok
+SET SESSION AUTHORIZATION regress_admin;
+DROP ROLE regress_plpgsql_admin;  -- fail, privileges remain
+REVOKE SET VALUE, ALTER SYSTEM ON
+	plpgsql.extra_warnings, plpgsql.extra_errors
+FROM regress_plpgsql_admin;
+DROP ROLE regress_plpgsql_admin;  -- ok
diff --git a/src/test/regress/sql/privileges.sql b/src/test/regress/sql/privileges.sql
index c8c545b64c..ddbf6afa44 100644
--- a/src/test/regress/sql/privileges.sql
+++ b/src/test/regress/sql/privileges.sql
@@ -66,6 +66,33 @@ DROP USER regress_priv_user10;
 DROP USER regress_priv_user9;
 DROP USER regress_priv_user8;
 
+GRANT SET VALUE ON enable_memoize TO regress_priv_user6;
+GRANT SET VALUE ON enable_nestloop TO regress_priv_user6;
+
+SET ROLE regress_priv_user6;
+SET enable_memoize TO false;
+SET enable_nestloop TO false;
+RESET enable_memoize;
+RESET enable_nestloop;
+RESET ROLE;
+
+GRANT ALTER SYSTEM ON enable_seqscan TO regress_priv_user7; -- ok
+GRANT ALTER SYSTEM ON sort_mem TO regress_priv_user7; -- old name for "work_mem"
+GRANT ALTER SYSTEM ON maintenance_work_mem TO regress_priv_user7; -- ok
+GRANT ALTER SYSTEM ON no_such_param TO regress_priv_user7; -- ok
+GRANT ALTER SYSTEM ON no_such_extension.no_such_param TO regress_priv_user7; -- ok
+GRANT ALTER SYSTEM ON no_such_extension.no_such_param.longer.than.maximum.namedata.length TO regress_priv_user7; -- ok
+GRANT ALTER SYSTEM ON "" TO regress_priv_user7; -- bad name
+GRANT ALTER SYSTEM ON " " TO regress_priv_user7; -- bad name
+GRANT ALTER SYSTEM ON " foo " TO regress_priv_user7; -- bad name
+
+GRANT SELECT ON public.persons2 TO regress_priv_user7;
+
+SET ROLE regress_priv_user7;
+ALTER SYSTEM SET enable_seqscan = OFF;
+ALTER SYSTEM RESET enable_seqscan;
+RESET ROLE;
+
 CREATE GROUP regress_priv_group1;
 CREATE GROUP regress_priv_group2 WITH USER regress_priv_user1, regress_priv_user2;
 
@@ -1426,10 +1453,23 @@ DROP USER regress_priv_user2;
 DROP USER regress_priv_user3;
 DROP USER regress_priv_user4;
 DROP USER regress_priv_user5;
-DROP USER regress_priv_user6;
-DROP USER regress_priv_user7;
+DROP USER regress_priv_user6; -- privileges remain
+DROP USER regress_priv_user7; -- privileges remain
 DROP USER regress_priv_user8; -- does not exist
 
+REVOKE SELECT ON public.persons2 FROM regress_priv_user7;
+REVOKE ALTER SYSTEM ON enable_seqscan FROM regress_priv_user7; -- ok
+REVOKE ALTER SYSTEM ON work_mem FROM regress_priv_user7; -- ok, use new name
+REVOKE ALTER SYSTEM ON vacuum_mem FROM regress_priv_user7; -- ok, use old name
+REVOKE ALTER SYSTEM ON no_such_param FROM regress_priv_user7; -- ok
+REVOKE ALTER SYSTEM ON no_such_extension.no_such_param FROM regress_priv_user7; -- ok
+REVOKE ALTER SYSTEM ON no_such_extension.no_such_param.longer.than.maximum.namedata.length FROM regress_priv_user7; -- ok
+DROP USER regress_priv_user7; -- ok
+
+REVOKE SET VALUE ON enable_memoize FROM regress_priv_user6;
+REVOKE SET VALUE ON enable_nestloop FROM regress_priv_user6;
+
+DROP USER regress_priv_user6; -- ok
 
 -- permissions with LOCK TABLE
 CREATE USER regress_locktable_user;
-- 
2.21.1 (Apple Git-122.3)

