From: Stephen Frost <sfrost@snowman.net>
Date: Sun, 19 Mar 2017 20:56:14 +0000 (-0400)
Subject: pg_dump: Skip COLLATION-related regression tests
X-Git-Tag: REL_10_BETA1~592
X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=de34123834c3fa465b97f65ded171888edbfbccf;p=postgresql

pg_dump: Skip COLLATION-related regression tests

Not every platform supports non-default collations, as pointed out by
the buildfarm, so skip collation-related regression tests in pg_dump
when they aren't supported.
---

diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_dump.pl
index 3cac4a9ae0..a4e260a4e4 100644
--- a/src/bin/pg_dump/t/002_pg_dump.pl
+++ b/src/bin/pg_dump/t/002_pg_dump.pl
@@ -427,6 +427,7 @@ my %tests = (
 		catch_all =>
 		  'ALTER ... OWNER commands (except LARGE OBJECTs and PUBLICATIONs)',
 		regexp => qr/^ALTER COLLATION test0 OWNER TO .*;/m,
+		collation => 1,
 		like   => {
 			binary_upgrade           => 1,
 			clean                    => 1,
@@ -1707,6 +1708,7 @@ my %tests = (
 		create_sql   => 'COMMENT ON COLLATION test0
 					   IS \'comment on test0 collation\';',
 		regexp => qr/^COMMENT ON COLLATION test0 IS 'comment on test0 collation';/m,
+		collation => 1,
 		like   => {
 			binary_upgrade           => 1,
 			clean                    => 1,
@@ -2423,6 +2425,7 @@ qr/^\QINSERT INTO test_fifth_table (col1, col2, col3, col4, col5) VALUES (NULL,
 		regexp =>
 		  qr/^
 		  \QCREATE COLLATION test0 (lc_collate = 'C', lc_ctype = 'C');\E/xm,
+	    collation => 1,
 		like => {
 			binary_upgrade           => 1,
 			clean                    => 1,
@@ -6090,6 +6093,17 @@ $node->start;
 
 my $port = $node->port;
 
+# We need to see if this system supports CREATE COLLATION or not
+# If it doesn't then we will skip all the COLLATION-related tests.
+my $collation_support = 0;
+my $collation_check_stderr;
+$node->psql('postgres',"CREATE COLLATION testing FROM \"C\"; DROP COLLATION testing;", on_error_stop => 0, stderr => \$collation_check_stderr);
+
+if ($collation_check_stderr !~ /ERROR: /)
+{
+	$collation_support = 1;
+}
+
 # Start with number of command_fails_like()*2 tests below (each
 # command_fails_like is actually 2 tests)
 my $num_tests = 12;
@@ -6115,6 +6129,11 @@ foreach my $run (sort keys %pgdump_runs)
 	# Then count all the tests run against each run
 	foreach my $test (sort keys %tests)
 	{
+		# Skip any collation-related commands if there is no collation support
+		if (!$collation_support && defined($tests{$test}->{collation})) {
+			next;
+		}
+
 		if ($tests{$test}->{like}->{$test_key})
 		{
 			$num_tests++;
@@ -6181,6 +6200,11 @@ foreach my $test (
 {
 	if ($tests{$test}->{create_sql})
 	{
+		# Skip any collation-related commands if there is no collation support
+		if (!$collation_support && defined($tests{$test}->{collation})) {
+			next;
+		}
+
 		$create_sql .= $tests{$test}->{create_sql};
 	}
 }
@@ -6258,6 +6282,11 @@ foreach my $run (sort keys %pgdump_runs)
 
 	foreach my $test (sort keys %tests)
 	{
+		# Skip any collation-related commands if there is no collation support
+		if (!$collation_support && defined($tests{$test}->{collation})) {
+			next;
+		}
+
 		if ($tests{$test}->{like}->{$test_key})
 		{
 			like($output_file, $tests{$test}->{regexp}, "$run: dumps $test");