pgsql: Add new predefined role pg_create_subscription.

From: Robert Haas <rhaas(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Add new predefined role pg_create_subscription.
Date: 2023-03-30 16:03:49
Message-ID: E1phuke-000Ukd-IP@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Add new predefined role pg_create_subscription.

This role can be granted to non-superusers to allow them to issue
CREATE SUBSCRIPTION. The non-superuser must additionally have CREATE
permissions on the database in which the subscription is to be
created.

Most forms of ALTER SUBSCRIPTION, including ALTER SUBSCRIPTION .. SKIP,
now require only that the role performing the operation own the
subscription, or inherit the privileges of the owner. However, to
use ALTER SUBSCRIPTION ... RENAME or ALTER SUBSCRIPTION ... OWNER TO,
you also need CREATE permission on the database. This is similar to
what we do for schemas. To change the owner of a schema, you must also
have permission to SET ROLE to the new owner, similar to what we do
for other object types.

Non-superusers are required to specify a password for authentication
and the remote side must use the password, similar to what is required
for postgres_fdw and dblink. A superuser who wants a non-superuser to
own a subscription that does not rely on password authentication may
set the new password_required=false property on that subscription. A
non-superuser may not set password_required=false and may not modify a
subscription that already has password_required=false.

This new password_required subscription property works much like the
eponymous postgres_fdw property. In both cases, the actual semantics
are that a password is not required if either (1) the property is set
to false or (2) the relevant user is the superuser.

Patch by me, reviewed by Andres Freund, Jeff Davis, Mark Dilger,
and Stephen Frost (but some of those people did not fully endorse
all of the decisions that the patch makes).

Discussion: http://postgr.es/m/CA+TgmoaDH=0Xj7OBiQnsHTKcF2c4L+=gzPBUKSJLh8zed2_+Dg@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/c3afe8cf5a1e465bd71e48e4bc717f5bfdc7a7d6

Modified Files
--------------
doc/src/sgml/ref/alter_subscription.sgml | 16 +--
doc/src/sgml/ref/create_subscription.sgml | 22 +++-
doc/src/sgml/ref/drop_subscription.sgml | 2 +-
doc/src/sgml/user-manag.sgml | 6 +
src/backend/catalog/pg_subscription.c | 1 +
src/backend/catalog/system_views.sql | 1 +
src/backend/commands/alter.c | 24 ++++
src/backend/commands/subscriptioncmds.c | 138 +++++++++++++++++----
.../libpqwalreceiver/libpqwalreceiver.c | 65 ++++++++--
src/backend/replication/logical/tablesync.c | 9 +-
src/backend/replication/logical/worker.c | 6 +
src/backend/replication/walreceiver.c | 2 +-
src/bin/pg_dump/pg_dump.c | 16 ++-
src/bin/pg_dump/pg_dump.h | 1 +
src/include/catalog/catversion.h | 2 +-
src/include/catalog/pg_authid.dat | 5 +
src/include/catalog/pg_subscription.h | 3 +
src/include/replication/walreceiver.h | 12 +-
src/test/regress/expected/subscription.out | 57 +++++++--
src/test/regress/sql/subscription.sql | 54 +++++++-
src/test/subscription/t/027_nosuperuser.pl | 2 +-
21 files changed, 384 insertions(+), 60 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Robert Haas 2023-03-30 16:07:10 pgsql: Fix documentation build for c3afe8cf5a1e465bd71e48e4bc717f5bfdc7
Previous Message Tom Lane 2023-03-30 15:27:42 pgsql: Avoid overflow in width_bucket_float8().