CREATE SUBSCRIPTION ... SERVER.

Jeff Davis <jdavis@postgresql.org>

Commit: 8185bb53476378443240d57f7d844347d5fae1bf
Author: Jeff Davis <jdavis@postgresql.org>
Date: 2026-03-06T16:27:56Z
CREATE SUBSCRIPTION ... SERVER.

Allow CREATE SUBSCRIPTION to accept a foreign server using the SERVER
clause instead of a raw connection string using the CONNECTION clause.

  * Enables a user with sufficient privileges to create a subscription
    using a foreign server by name without specifying the connection
    details.

  * Integrates with user mappings (and other FDW infrastructure) using
    the subscription owner.

  * Provides a layer of indirection to manage multiple subscriptions
    to the same remote server more easily.

Also add CREATE FOREIGN DATA WRAPPER ... CONNECTION clause to specify
a connection_function. To be eligible for a subscription, the foreign
server's foreign data wrapper must specify a connection_function.

Add connection_function support to postgres_fdw, and bump postgres_fdw
version to 1.3.

Bump catversion.

Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Reviewed-by: Shlok Kyal <shlok.kyal.oss@gmail.com>
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Discussion: https://postgr.es/m/61831790a0a937038f78ce09f8dd4cef7de7456a.camel@j-davis.com

Files

PathChange+/−
contrib/postgres_fdw/connection.c modified +184 −115
contrib/postgres_fdw/expected/postgres_fdw.out modified +8 −0
contrib/postgres_fdw/Makefile modified +1 −1
contrib/postgres_fdw/meson.build modified +2 −0
contrib/postgres_fdw/postgres_fdw--1.2--1.3.sql added +12 −0
contrib/postgres_fdw/postgres_fdw.control modified +1 −1
contrib/postgres_fdw/sql/postgres_fdw.sql modified +7 −0
contrib/postgres_fdw/t/010_subscription.pl added +71 −0
doc/src/sgml/logical-replication.sgml modified +3 −1
doc/src/sgml/postgres-fdw.sgml modified +26 −0
doc/src/sgml/ref/alter_foreign_data_wrapper.sgml modified +20 −0
doc/src/sgml/ref/alter_subscription.sgml modified +15 −3
doc/src/sgml/ref/create_foreign_data_wrapper.sgml modified +20 −0
doc/src/sgml/ref/create_server.sgml modified +7 −0
doc/src/sgml/ref/create_subscription.sgml modified +15 −1
src/backend/catalog/dependency.c modified +11 −0
src/backend/catalog/pg_subscription.c modified +33 −5
src/backend/catalog/system_views.sql modified +1 −1
src/backend/commands/foreigncmds.c modified +55 −3
src/backend/commands/subscriptioncmds.c modified +187 −16
src/backend/foreign/foreign.c modified +86 −0
src/backend/parser/gram.y modified +22 −0
src/backend/replication/logical/worker.c modified +21 −3
src/bin/pg_dump/pg_dump.c modified +33 −6
src/bin/pg_dump/pg_dump.h modified +1 −0
src/bin/psql/describe.c modified +5 −1
src/bin/psql/tab-complete.in.c modified +9 −2
src/include/catalog/catversion.h modified +1 −1
src/include/catalog/pg_foreign_data_wrapper.h modified +3 −0
src/include/catalog/pg_subscription.h modified +6 −2
src/include/foreign/foreign.h modified +3 −0
src/include/nodes/parsenodes.h modified +3 −0
src/test/regress/expected/oidjoins.out modified +2 −0
src/test/regress/expected/subscription.out modified +134 −88
src/test/regress/regress.c modified +7 −0
src/test/regress/sql/subscription.sql modified +55 −0

Discussion