From 2b28e4bc147bbf47bc6912986b4400d634f17131 Mon Sep 17 00:00:00 2001
From: Jeff Davis <jeff@j-davis.com>
Date: Sat, 14 Mar 2026 15:07:52 -0700
Subject: [PATCH v22 6/6] Add pg_dump tests related to CREATE SUBSCRIPTION ...
 SERVER.

Suggested-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Discussion: https://postgr.es/m/CAExHW5vV5znEvecX=ra2-v7UBj9-M6qvdDzuB78M-TxbYD1PEA@mail.gmail.com
---
 src/bin/pg_dump/t/002_pg_dump.pl | 49 ++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_dump.pl
index 6d1d38128fc..11a944dd5f8 100644
--- a/src/bin/pg_dump/t/002_pg_dump.pl
+++ b/src/bin/pg_dump/t/002_pg_dump.pl
@@ -2846,6 +2846,40 @@ my %tests = (
 		like => { %full_runs, section_pre_data => 1, },
 	},
 
+	'CREATE FUNCTION public.test_fdw_connection(oid, oid, internal)' => {
+		create_order => 37,
+		create_sql => "CREATE FUNCTION public.test_fdw_connection(oid, oid, internal) RETURNS text AS '\$libdir/regress', 'test_fdw_connection' LANGUAGE C;",
+		regexp => qr/^
+			\QCREATE FUNCTION public.test_fdw_connection(oid, oid, internal) \E
+			\QRETURNS text\E
+			\n\s+\QLANGUAGE c\E
+			\n\s+AS\ \'\$
+			\Qlibdir\/regress', 'test_fdw_connection';\E
+			/xm,
+		like => { %full_runs, section_pre_data => 1, },
+	},
+
+	'CREATE FOREIGN DATA WRAPPER test_fdw CONNECTION public.test_fdw_connection' => {
+		create_order => 38,
+		create_sql => 'CREATE FOREIGN DATA WRAPPER test_fdw CONNECTION public.test_fdw_connection;',
+		regexp => qr/CREATE FOREIGN DATA WRAPPER test_fdw CONNECTION public.test_fdw_connection;/m,
+		like => { %full_runs, section_pre_data => 1, },
+	},
+
+	'CREATE SERVER s2 FOREIGN DATA WRAPPER test_fdw' => {
+		create_order => 39,
+		create_sql => 'CREATE SERVER s2 FOREIGN DATA WRAPPER test_fdw;',
+		regexp => qr/CREATE SERVER s2 FOREIGN DATA WRAPPER test_fdw;/m,
+		like => { %full_runs, section_pre_data => 1, },
+	},
+
+	'CREATE USER MAPPING FOR public SERVER s2' => {
+		create_order => 40,
+		create_sql => 'CREATE USER MAPPING FOR public SERVER s2;',
+		regexp => qr/CREATE USER MAPPING FOR public SERVER s2;/m,
+		like => { %full_runs, section_pre_data => 1, },
+	},
+
 	'CREATE FOREIGN TABLE dump_test.foreign_table SERVER s1' => {
 		create_order => 88,
 		create_sql =>
@@ -3275,6 +3309,21 @@ my %tests = (
 		},
 	},
 
+	'CREATE SUBSCRIPTION sub4 SERVER s2' => {
+		create_order => 50,
+		create_sql => 'CREATE SUBSCRIPTION sub4
+						 SERVER s2 PUBLICATION pub1
+						 WITH (connect = false, slot_name = NONE, origin = any, streaming = on);',
+		regexp => qr/^
+			\QCREATE SUBSCRIPTION sub4 SERVER s2 PUBLICATION pub1 WITH (connect = false, slot_name = NONE, streaming = on);\E
+			/xm,
+		like => { %full_runs, section_post_data => 1, },
+		unlike => {
+			no_subscriptions => 1,
+			no_subscriptions_restore => 1,
+		},
+	},
+
 
 	# Regardless of whether the table or schema is excluded, publications must
 	# still be dumped, as excluded objects do not apply to publications. We
-- 
2.43.0

