Move routines to manipulate WAL into PostgreSQL::Test::Cluster
[pgsql.git] / src / bin / pg_dump / t / 003_pg_dump_with_server.pl
blob929a57e1e59e8825435e5df2b28362d541839482
2 # Copyright (c) 2021-2025, PostgreSQL Global Development Group
4 use strict;
5 use warnings FATAL => 'all';
7 use PostgreSQL::Test::Cluster;
8 use PostgreSQL::Test::Utils;
9 use Test::More;
11 my $tempdir = PostgreSQL::Test::Utils::tempdir;
13 my $node = PostgreSQL::Test::Cluster->new('main');
14 my $port = $node->port;
16 $node->init;
17 $node->start;
19 #########################################
20 # Verify that dumping foreign data includes only foreign tables of
21 # matching servers
23 $node->safe_psql('postgres', "CREATE FOREIGN DATA WRAPPER dummy");
24 $node->safe_psql('postgres', "CREATE SERVER s0 FOREIGN DATA WRAPPER dummy");
25 $node->safe_psql('postgres', "CREATE SERVER s1 FOREIGN DATA WRAPPER dummy");
26 $node->safe_psql('postgres', "CREATE SERVER s2 FOREIGN DATA WRAPPER dummy");
27 $node->safe_psql('postgres', "CREATE FOREIGN TABLE t0 (a int) SERVER s0");
28 $node->safe_psql('postgres', "CREATE FOREIGN TABLE t1 (a int) SERVER s1");
30 command_fails_like(
31 [ "pg_dump", '-p', $port, '--include-foreign-data=s0', 'postgres' ],
32 qr/foreign-data wrapper \"dummy\" has no handler\r?\npg_dump: detail: Query was: .*t0/,
33 "correctly fails to dump a foreign table from a dummy FDW");
35 command_ok(
36 [ "pg_dump", '-p', $port, '-a', '--include-foreign-data=s2', 'postgres' ],
37 "dump foreign server with no tables");
39 done_testing();