aboutsummaryrefslogtreecommitdiff
path: root/src/bin/pg_dump/t/002_pg_dump.pl
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/pg_dump/t/002_pg_dump.pl')
-rw-r--r--src/bin/pg_dump/t/002_pg_dump.pl109
1 files changed, 108 insertions, 1 deletions
diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_dump.pl
index b52cfe9f735..2c0167fdc5f 100644
--- a/src/bin/pg_dump/t/002_pg_dump.pl
+++ b/src/bin/pg_dump/t/002_pg_dump.pl
@@ -3602,7 +3602,7 @@ $node->psql('postgres', 'create database regress_pg_dump_test;');
# Start with number of command_fails_like()*2 tests below (each
# command_fails_like is actually 2 tests)
-my $num_tests = 12;
+my $num_tests = 42;
foreach my $run (sort keys %pgdump_runs)
{
@@ -3776,6 +3776,113 @@ command_fails_like(
'no matching tables');
#########################################
+# Test invalid multipart database names
+
+command_fails_like(
+ [ 'pg_dumpall', '-p', "$port", '--exclude-database', '.' ],
+ qr/pg_dumpall: error: improper qualified name \(too many dotted names\): \./,
+ 'pg_dumpall: option --exclude-database rejects multipart pattern "."'
+);
+
+command_fails_like(
+ [ 'pg_dumpall', '-p', "$port", '--exclude-database', '.*' ],
+ qr/pg_dumpall: error: improper qualified name \(too many dotted names\): \.\*/,
+ 'pg_dumpall: option --exclude-database rejects multipart pattern ".*"'
+);
+
+command_fails_like(
+ [ 'pg_dumpall', '-p', "$port", '--exclude-database', '*.*' ],
+ qr/pg_dumpall: error: improper qualified name \(too many dotted names\): \*\.\*/,
+ 'pg_dumpall: option --exclude-database rejects multipart pattern "*.*"'
+);
+
+command_fails_like(
+ [ 'pg_dumpall', '-p', "$port", '--exclude-database', 'myhost.mydb' ],
+ qr/pg_dumpall: error: improper qualified name \(too many dotted names\): myhost\.mydb/,
+ 'pg_dumpall: option --exclude-database rejects multipart database names'
+);
+
+#########################################
+# Test valid database exclusion patterns
+
+$node->command_ok(
+ [ 'pg_dumpall', '-p', "$port", '--exclude-database', '"myhost.mydb"' ],
+ 'pg_dumpall: option --exclude-database handles database names with embedded dots'
+);
+
+$node->command_ok(
+ [ 'pg_dumpall', '-p', "$port", '--exclude-database', '??*' ],
+ 'pg_dumpall: option --exclude-database handles database name patterns'
+);
+
+
+#########################################
+# Test invalid multipart schema names
+
+command_fails_like(
+ [ 'pg_dump', '-p', "$port", '--schema', 'myhost.mydb.myschema' ],
+ qr/pg_dump: error: improper qualified name \(too many dotted names\): myhost\.mydb\.myschema/,
+ 'pg_dump: option --schema rejects three-part schema names'
+);
+
+command_fails_like(
+ [ 'pg_dump', '-p', "$port", '--schema', 'otherdb.myschema' ],
+ qr/pg_dump: error: cross-database references are not implemented: otherdb\.myschema/,
+ 'pg_dump: option --schema rejects cross-database multipart schema names'
+);
+
+command_fails_like(
+ [ 'pg_dump', '-p', "$port", '--schema', '"some.other.db".myschema' ],
+ qr/pg_dump: error: cross-database references are not implemented: "some\.other\.db"\.myschema/,
+ 'pg_dump: option --schema rejects cross-database multipart schema names with embedded dots'
+);
+
+command_fails_like(
+ [ 'pg_dump', '-p', "$port", '--schema', '.' ],
+ qr/pg_dump: error: cross-database references are not implemented: \./,
+ 'pg_dump: option --schema rejects degenerate two-part schema name: "."'
+);
+
+command_fails_like(
+ [ 'pg_dump', '-p', "$port", '--schema', '.*' ],
+ qr/pg_dump: error: cross-database references are not implemented: \.\*/,
+ 'pg_dump: option --schema rejects degenerate two-part schema name: ".*"'
+);
+
+command_fails_like(
+ [ 'pg_dump', '-p', "$port", '--schema', '..' ],
+ qr/pg_dump: error: improper qualified name \(too many dotted names\): \.\./,
+ 'pg_dump: option --schema rejects degenerate three-part schema name: ".."'
+);
+
+command_fails_like(
+ [ 'pg_dump', '-p', "$port", '--schema', '.*.*' ],
+ qr/pg_dump: error: improper qualified name \(too many dotted names\): \.\*\.\*/,
+ 'pg_dump: option --schema rejects degenerate three-part schema pattern: ".*.*"'
+);
+
+#########################################
+# Test invalid multipart relation names
+
+command_fails_like(
+ [ 'pg_dump', '-p', "$port", '--table', 'myhost.mydb.myschema.mytable' ],
+ qr/pg_dump: error: improper relation name \(too many dotted names\): myhost\.mydb\.myschema\.mytable/,
+ 'pg_dump: option --table rejects four-part table names'
+);
+
+command_fails_like(
+ [ 'pg_dump', '-p', "$port", '--table', 'otherdb.pg_catalog.pg_class' ],
+ qr/pg_dump: error: cross-database references are not implemented: otherdb\.pg_catalog\.pg_class/,
+ 'pg_dump: option --table rejects cross-database three part table names'
+);
+
+command_fails_like(
+ [ 'pg_dump', '-p', "$port", '--table', '"some.other.db".pg_catalog.pg_class' ],
+ qr/pg_dump: error: cross-database references are not implemented: "some\.other\.db"\.pg_catalog\.pg_class/,
+ 'pg_dump: option --table rejects cross-database three part table names with embedded dots'
+);
+
+#########################################
# Run all runs
foreach my $run (sort keys %pgdump_runs)