More support for older versions of Postgres, other cleanups.
authorGreg Sabino Mullane <[email protected]>
Thu, 30 Apr 2009 13:09:52 +0000 (09:09 -0400)
committerGreg Sabino Mullane <[email protected]>
Thu, 30 Apr 2009 13:09:52 +0000 (09:09 -0400)
13 files changed:
check_postgres.pl
t/02_autovac_freeze.t
t/02_backends.t
t/02_last_analyze.t
t/02_last_vacuum.t
t/02_logfile.t
t/02_query_time.t
t/02_txn_idle.t
t/02_txn_wraparound.t
t/02_version.t
t/02_wal_files.t
t/99_perlcritic.t
t/CP_Testing.pm

index 8bd874cb37d84a6f4a682e45a194bc439a95973c..978cea73ccb37a7ed51792107132eab8a33178a5 100755 (executable)
@@ -1760,7 +1760,7 @@ sub verify_version {
                        ndie msg('die-nosetting', $setting);
                }
                my $val = $info2->{db}[0]{slurp};
-               if ($val !~ /^on\b/) {
+               if ($val !~ /^\s*on\b/) {
                        ndie msg('die-noset', $action, $setting);
                }
        }
index a24be524ab6676dfadaa4bc60e170f8e4f269091..a442628cc023e8a1545cdec70ab74cfe5d2fb4de 100644 (file)
@@ -18,10 +18,16 @@ $dbh = $cp->test_database_handle();
 $dbh->{AutoCommit} = 1;
 $dbname = $cp->get_dbname;
 $host = $cp->get_host();
+my $ver = $dbh->{pg_server_version};
+
 my $label = 'POSTGRES_AUTOVAC_FREEZE';
 
 my $S = q{Action 'autovac_freeze'};
 
+SKIP:
+{
+       $ver < 80200 and skip 'Cannot test autovac_freeze on old Postgres versions', 8;
+
 $t = qq{$S self-identifies correctly};
 $result = $cp->run(q{-w 0%});
 like ($result, qr{^$label}, $t);
@@ -46,3 +52,7 @@ like ($cp->run('-w 99%'), qr{$label OK:.*ardala=\d+%.*?beedeebeedee=\d+%.*?postg
 
 $t=qq{$S produces MRTG output};
 like ($cp->run('--output=mrtg -w 99%'), qr{0\n\d+\n\nardala \| beedeebeedee \| postgres \| template1\n}, $t);
+
+}
+
+exit;
index 73933c87c219ba523f2d9da05da8981542a57651..609d8ab557235ad8148d79006f9fa13e8cfb7e9a 100644 (file)
@@ -16,13 +16,16 @@ my $cp = CP_Testing->new( {default_action => 'backends'} );
 
 $dbh = $cp->test_database_handle();
 
+my $ver = $dbh->{pg_server_version};
+my $goodver = $ver >= 80200 ? 1 : 0;
+
 ## Check current number of connections: should be 1 (for recent versions of PG)
 $SQL = 'SELECT count(*) FROM pg_stat_activity';
 $count = $dbh->selectall_arrayref($SQL)->[0][0];
 
 $t=q{Current number of backends is one (ourselves)};
-is ($count, 1, $t);
-1==$count or BAIL_OUT "Cannot continue unless we start from a sane connection count\n";
+$count <= 1 or BAIL_OUT "Cannot continue unless we start from a sane connection count\n";
+pass $t;
 
 $host = $cp->get_host();
 
@@ -37,13 +40,17 @@ $t=qq{$S returned correct host name};
 like ($result, qr{^POSTGRES_BACKENDS OK: \(host:$host\)}, $t);
 
 $t=qq{$S returned correct connection count};
-like ($result, qr{^POSTGRES_BACKENDS OK: \(host:$host\) 2 of 10 connections}, $t);
+SKIP: {
+       skip 'Cannot test backends completely with older version of Postgres', 3;
+
+       like ($result, qr{^POSTGRES_BACKENDS OK: \(host:$host\) 2 of 10 connections}, $t);
 
-$t=qq{$S returned correct percentage};
-like ($result, qr{^POSTGRES_BACKENDS OK: \(host:$host\) 2 of 10 connections \(20%\)}, $t);
+       $t=qq{$S returned correct percentage};
+       like ($result, qr{^POSTGRES_BACKENDS OK: \(host:$host\) 2 of 10 connections \(20%\)}, $t);
 
-$t=qq{$S returned correct performance data};
-like ($result, qr{ \| time=(\d\.\d\d)  ardala=0 beedeebeedee=0 postgres=2 template0=0 template1=0\s$}, $t);
+       $t=qq{$S returned correct performance data};
+       like ($result, qr{ \| time=(\d\.\d\d)  ardala=0 beedeebeedee=0 postgres=2 template0=0 template1=0\s$}, $t);
+}
 
 $t=qq{$S fails when called with an invalid option};
 like ($cp->run('foobar=12'), qr{^\s*Usage:}, $t);
@@ -72,12 +79,15 @@ $t=qq{$S fails when the critical option is a negative percent};
 like ($cp->run('-c -10%'), qr{^ERROR: Cannot specify a negative percent}, $t);
 
 $t=qq{$S with the 'noidle' option returns expected result};
-like ($cp->run('-noidle'), qr{^POSTGRES_BACKENDS OK:.+ 2 of 10 connections}, $t);
+my $num = $goodver ? 2 : 1;
+like ($cp->run('-noidle'), qr{^POSTGRES_BACKENDS OK:.+ $num of 10 connections}, $t);
 $dbh2 = $cp->get_fresh_dbh();
 $dbh2->do('SELECT 123');
-like ($cp->run('-noidle'), qr{^POSTGRES_BACKENDS OK:.+ 3 of 10 connections}, $t);
+$num++ if $goodver;
+like ($cp->run('-noidle'), qr{^POSTGRES_BACKENDS OK:.+ $num of 10 connections}, $t);
 $dbh2->commit();
-like ($cp->run('-noidle'), qr{^POSTGRES_BACKENDS OK:.+ 2 of 10 connections}, $t);
+$num = $goodver ? 2 : '(?:1|2)';
+like ($cp->run('-noidle'), qr{^POSTGRES_BACKENDS OK:.+ $num of 10 connections}, $t);
 
 $t=qq{$S has critical option trump the warning option};
 like ($cp->run('-w 1 -c 1'), qr{^POSTGRES_BACKENDS CRITICAL}, $t);
@@ -85,74 +95,78 @@ like ($cp->run('--critical=1 --warning=0'), qr{^POSTGRES_BACKENDS CRITICAL}, $t)
 
 $t=qq{$S works with warning option as an absolute number};
 like ($cp->run('-w 2'), qr{^POSTGRES_BACKENDS WARNING}, $t);
-like ($cp->run('-w 3'), qr{^POSTGRES_BACKENDS WARNING}, $t);
+$num = $goodver ? 3 : 2;
+like ($cp->run("-w $num"), qr{^POSTGRES_BACKENDS WARNING}, $t);
 like ($cp->run('-w 4'), qr{^POSTGRES_BACKENDS OK}, $t);
 
 $t=qq{$S works with warning option as an percentage};
 like ($cp->run('-w 20%'), qr{^POSTGRES_BACKENDS WARNING}, $t);
-like ($cp->run('-w 30%'), qr{^POSTGRES_BACKENDS WARNING}, $t);
+like ($cp->run("-w ${num}0%"), qr{^POSTGRES_BACKENDS WARNING}, $t);
 like ($cp->run('-w 40%'), qr{^POSTGRES_BACKENDS OK}, $t);
 
 $t=qq{$S works with warning option as a negative number};
 like ($cp->run('-w -6'), qr{^POSTGRES_BACKENDS WARNING}, $t);
 like ($cp->run('-w -7'), qr{^POSTGRES_BACKENDS WARNING}, $t);
-like ($cp->run('-w -8'), qr{^POSTGRES_BACKENDS OK}, $t);
+$num = $goodver ? 8 : 9;
+like ($cp->run("-w -$num"), qr{^POSTGRES_BACKENDS OK}, $t);
 
 $t=qq{$S works with critical option as an absolute number};
 like ($cp->run('-c 2'), qr{^POSTGRES_BACKENDS CRITICAL}, $t);
-like ($cp->run('-c 3'), qr{^POSTGRES_BACKENDS CRITICAL}, $t);
+$num = $goodver ? 3 : 2;
+like ($cp->run("-c $num"), qr{^POSTGRES_BACKENDS CRITICAL}, $t);
 like ($cp->run('-c 4'), qr{^POSTGRES_BACKENDS OK}, $t);
 
 $t=qq{$S works with critical option as an percentage};
 like ($cp->run('-c 20%'), qr{^POSTGRES_BACKENDS CRITICAL}, $t);
-like ($cp->run('-c 30%'), qr{^POSTGRES_BACKENDS CRITICAL}, $t);
+like ($cp->run("-c ${num}0%"), qr{^POSTGRES_BACKENDS CRITICAL}, $t);
 like ($cp->run('-c 40%'), qr{^POSTGRES_BACKENDS OK}, $t);
 
 $t=qq{$S works with critical option as a negative number};
 like ($cp->run('-c -6'), qr{^POSTGRES_BACKENDS CRITICAL}, $t);
 like ($cp->run('-c -7'), qr{^POSTGRES_BACKENDS CRITICAL}, $t);
-like ($cp->run('-c -8'), qr{^POSTGRES_BACKENDS OK}, $t);
+$num = $goodver ? 8 : 9;
+like ($cp->run("-c -$num"), qr{^POSTGRES_BACKENDS OK}, $t);
 
 $t=qq{$S works when no items caught by pg_stat_activity};
 
-$cp->drop_schema_if_exists($fakeschema);
+$cp->drop_schema_if_exists();
 $cp->create_fake_pg_table('pg_stat_activity');
 like ($cp->run(), qr{^POSTGRES_BACKENDS OK: .+No connections}, $t);
 
 $t=qq{$S returns correct MRTG output when no rows};
 is ($cp->run('--output=MRTG'), qq{0\n0\n\nDB=postgres Max connections=10\n}, $t);
 
-$cp->remove_fake_pg_table('pg_stat_activity');
-
 $t=qq{$S fails as expected when max_connections cannot be determined};
 $cp->create_fake_pg_table('pg_settings');
 like ($cp->run(), qr{^POSTGRES_BACKENDS UNKNOWN: .+max_connections}, $t);
-$cp->remove_fake_pg_table('pg_settings');
+$cp->drop_schema_if_exists();
 
 $t=qq{$S returns correct MRTG output when rows found};
-is ($cp->run('--output=MRTG'), qq{3\n0\n\nDB=postgres Max connections=10\n}, $t);
+$num = $goodver ? 3 : 2;
+is ($cp->run('--output=MRTG'), qq{$num\n0\n\nDB=postgres Max connections=10\n}, $t);
 
 $t=qq{$S works when include forces no matches};
 like ($cp->run('--include=foobar'), qr{POSTGRES_BACKENDS OK: .+No connections}, $t);
 
 $t=qq{$S works when include has valid database};
-like ($cp->run('--include=postgres'), qr{POSTGRES_BACKENDS OK: .+3 of 10}, $t);
+$num = $goodver ? 3 : 2;
+like ($cp->run('--include=postgres'), qr{POSTGRES_BACKENDS OK: .+$num of 10}, $t);
 
 $t=qq{$S works when exclude forces no matches};
 like ($cp->run('--exclude=postgres'), qr{POSTGRES_BACKENDS OK: .+No connections}, $t);
 
 $t=qq{$S works when exclude excludes nothing};
-like ($cp->run('--exclude=foobar'), qr{POSTGRES_BACKENDS OK: .+3 of 10}, $t);
+like ($cp->run('--exclude=foobar'), qr{POSTGRES_BACKENDS OK: .+$num of 10}, $t);
 
 $t=qq{$S works when include and exclude make a match};
-like ($cp->run('--exclude=postgres --include=postgres'), qr{POSTGRES_BACKENDS OK: .+3 of 10}, $t);
+like ($cp->run('--exclude=postgres --include=postgres'), qr{POSTGRES_BACKENDS OK: .+$num of 10}, $t);
 
 $t=qq{$S works when include and exclude make a match};
-like ($cp->run('--include=postgres --exclude=postgres'), qr{POSTGRES_BACKENDS OK: .+3 of 10}, $t);
+like ($cp->run('--include=postgres --exclude=postgres'), qr{POSTGRES_BACKENDS OK: .+$num of 10}, $t);
 
 $t=qq{$S returned correct performance data with include};
-like ($cp->run('--include=postgres'), qr{ \| time=(\d\.\d\d)  ardala=0 beedeebeedee=0 postgres=3}, $t);
+like ($cp->run('--include=postgres'), qr{ \| time=(\d\.\d\d)  ardala=0 beedeebeedee=0 postgres=$num}, $t);
 
-$cp->drop_schema_if_exists($fakeschema);
+$cp->drop_schema_if_exists();
 
 exit;
index efa9461d89b82363216051d179e1f985d33e7f3d..a3d08c1098f7376f5e1fbe421d1c62888775b6c6 100644 (file)
@@ -19,10 +19,16 @@ my $cp = CP_Testing->new( {default_action => 'last_analyze'} );
 $dbh = $cp->test_database_handle();
 $dbname = $cp->get_dbname;
 $host = $cp->get_host();
+my $ver = $dbh->{pg_server_version};
+
 my $label = 'POSTGRES_LAST_ANALYZE';
 
 my $S = q{Action 'last_analyze'};
 
+SKIP:
+{
+       $ver < 80200 and skip 'Cannot test autovac_freeze on old Postgres versions', 14;
+
 $t = qq{$S self-identifies correctly};
 $result = $cp->run(q{-w 0});
 like ($result, qr{^$label}, $t);
@@ -76,4 +82,6 @@ $t = qq{$S returns correct MRTG information (fail case)};
 like($cp->run(q{--output=mrtg -w 0 --exclude=~.* --include=no_such_table}),
   qr{0\n0\n\nDB: $dbname TABLE: \?\n}, $t);
 
+}
+
 exit;
index 53cd8e7a1a65a4c936da6713849a61d0846e60de..e8d1bce5709351043a593aa51ebd2f15aa9f277e 100644 (file)
@@ -19,10 +19,16 @@ my $cp = CP_Testing->new( {default_action => 'last_vacuum'} );
 $dbh = $cp->test_database_handle();
 $dbname = $cp->get_dbname;
 $host = $cp->get_host();
+my $ver = $dbh->{pg_server_version};
+
 my $label = 'POSTGRES_LAST_VACUUM';
 
 my $S = q{Action 'last_vacuum'};
 
+SKIP:
+{
+       $ver < 80200 and skip 'Cannot test autovac_freeze on old Postgres versions', 14;
+
 $t = qq{$S self-identifies correctly};
 $result = $cp->run(q{-w 0});
 like ($result, qr{^$label}, $t);
@@ -77,4 +83,6 @@ $t = qq{$S returns correct MRTG information (fail case)};
 like ($cp->run('--output=mrtg -w 0 --exclude=~.* --include=no_such_table'),
          qr{0\n0\n\nDB: $dbname TABLE: \?\n}, $t);
 
+}
+
 exit;
index ffd37781e2a41c3c4d23d8cb908e6ab1d9c8f231..239cbb1e4945f33daf0f643cedf1863447304469 100644 (file)
@@ -34,7 +34,7 @@ like ($result, qr{^$label}, $t);
 $t = qq{$S identifies host};
 like ($result, qr{host:$host}, $t);
 
-$t = qq{$S correctly identified logfile};
+$t = qq{$S correctly identifies logfile};
 like ($result, qr{logs to: $logfile}, $t);
 
 $t = qq{$S correcly identifies host};
index 8366d6e0caf055bbe97edc77e6dea253fcc7e659..a851106204bfbbeb1d4e632bd32c02d1a6cf9a50 100644 (file)
@@ -51,14 +51,18 @@ for ('-1 second',
 my $child = fork();
 if ($child == 0) {
     my $kiddbh = $cp->test_database_handle();
-    $kiddbh->do(q{SELECT pg_sleep(3)});
+       $cp->database_sleep($kiddbh, 3);
+       $kiddbh->rollback();
     $kiddbh->disconnect;
     exit;
 }
 
 sleep 1;
+$dbh->disconnect();
 $dbh = $cp->test_database_handle();
 $t = qq{$S detects running query};
 like ($cp->run(q{-w 1}), qr{$label WARNING:}, $t);
+$dbh->rollback();
+$dbh->disconnect();
 
 exit;
index 75e1f8d9aa59f9140119986afc922a39fbd56d10..16001d5ca4694c61fb519c8dea4612ef33c453c6 100644 (file)
@@ -30,19 +30,21 @@ $t = qq{$S identifies host};
 like ($result, qr{host:$host}, $t);
 
 $t = qq{$S accepts valid -w input};
-for my $name ('1 second',
+for my $arg (
+     '1 second',
      '1 minute',
      '1 hour',
      '1 day'
     ) {
-   like ($cp->run(qq{-w "$_"}), qr/^$label/, "$t ($name)");
+   like ($cp->run(qq{-w "$arg"}), qr{^$label}, "$t ($arg)");
 }
 
 $t = qq{$S rejects invalid -w input};
-for ('-1 second',
+for my $arg (
+     '-1 second',
      'abc'
     ) {
-   like ($cp->run(qq{-w "$_"}), qr/^ERROR:.*?must be a valid time/, $t . " ($_)");
+   like ($cp->run(qq{-w "$arg"}), qr{^ERROR:.*?must be a valid time}, "$t ($arg)");
 }
 
 $t = qq{$S flags no-match-user};
index c44af2a123a3b6dc8f025bc42a51c3257fc6b1d7..b0774387a94bd1787b91351080da5431aa18c811 100644 (file)
@@ -46,10 +46,10 @@ for my $arg (-1, 0, 'a') {
 }
 
 $t = qq{$S rejects warning values 2 billion or higher};
-like ($cp->run(qq{-w 2000000000}), qr{ERROR:.+less than 2 billion}, $t);
+like ($cp->run(q{-w 2000000000}), qr{ERROR:.+less than 2 billion}, $t);
 
 $t = qq{$S rejects critical values 2 billion or higher};
-like ($cp->run(qq{-c 2200000000}), qr{ERROR:.+less than 2 billion}, $t);
+like ($cp->run(q{-c 2200000000}), qr{ERROR:.+less than 2 billion}, $t);
 
 $t = qq{$S accepts valid -c input};
 like ($cp->run(q{-c 1400000000}), qr{$label OK}, $t);
index 1ff66d0b779ccd90e7d84c1b4570d33890eb9dd2..e9e7e085afacb0c02f43960af75b1df576e4852c 100644 (file)
@@ -107,7 +107,7 @@ is ($cp->run('--output=MRTG --mrtg=7.8'), qq{1\n0\n\n7.8.12\n}, $t);
 $t=qq{$S gives correct output for MRTG output};
 is ($cp->run('--output=MRTG --mrtg=7.8.12'), qq{1\n0\n\n7.8.12\n}, $t);
 
-$cp->drop_schema_if_exists($fakeschema);
+$cp->drop_schema_if_exists();
 $cp->reset_path();
 
 exit;
index 53c61fcaaefef64cfc9a5c6bc6b1f3560e04ac99..9320fa4f29850c1d105f6cae40981e8916f67bfb 100644 (file)
@@ -33,7 +33,7 @@ $t=qq{$S works as expected for criticals};
 like ($cp->run('--critical=30'), qr{POSTGRES_WAL_FILES OK}, $t);
 like ($cp->run('--critical=0'), qr{POSTGRES_WAL_FILES CRITICAL}, $t);
 
-$cp->drop_schema_if_exists($fakeschema);
+$cp->drop_schema_if_exists();
 $cp->create_fake_pg_table('pg_ls_dir', 'text');
 
 like ($cp->run('--critical=1'), qr{POSTGRES_WAL_FILES OK}, $t);
@@ -50,6 +50,6 @@ is ($cp->run('--critical=1 --output=mrtg'), "99\n0\n\n\n", $t);
 $t=qq{$S returns correct MRTG information};
 is ($cp->run('--critical=101 --output=mrtg'), "99\n0\n\n\n", $t);
 
-$cp->drop_schema_if_exists($fakeschema);
+$cp->drop_schema_if_exists();
 
 exit;
index 2d1c830f804f7d89ddd4e79eec28f51b1d55f3a4..288d80a9a8f75b94896045218a1fff77d2dffa98 100644 (file)
@@ -25,14 +25,14 @@ else {
        opendir my $dir, 't' or die qq{Could not open directory 't': $!\n};
        @testfiles = map { "t/$_" } grep { /^.+\.(t|pl)$/ } readdir $dir;
        closedir $dir;
-       plan tests => 3+@testfiles;
+       plan tests => 4+@testfiles;
 }
 ok(@testfiles, 'Found files in test directory');
 
 ## Check some non-test files
 my $critic = Perl::Critic->new(-severity => 1, '-profile-strictness' => 'quiet');
 
-for my $filename (qw{check_postgres.pl }) {
+for my $filename (qw{check_postgres.pl t/CP_Testing.pm}) {
 
        if ($ENV{TEST_CRITIC_SKIPNONTEST}) {
                pass qq{Skipping non-test file "$filename"};
index c7fac75253a3686581127dfdba0b33fbcb137b13..c23e9b0ff6e6f69936f291e2e31e87fb1889fd63 100644 (file)
@@ -2,6 +2,7 @@ package CP_Testing;
 
 ## Common methods used by the other tests for check_postgres.pl
 
+use 5.006;
 use strict;
 use warnings;
 use Data::Dumper;
@@ -88,6 +89,7 @@ sub test_database_handle {
                print $cfh qq{max_connections = 10\n};
                print $cfh qq{max_prepared_transactions = 5\n};
                print $cfh qq{autovacuum = off\n};
+               print $cfh qq{stats_command_string = on\n};
                print $cfh "\n";
                close $cfh or die qq{Could not close "$cfile": $!\n};
 
@@ -141,7 +143,7 @@ sub test_database_handle {
          SCAN: {
                        seek $logfh, 0, 0;
                        while (<$logfh>) {
-                               if (/ready to accept connections/) {
+                               if (/ready to accept connections/ or /database system is ready/) {
                                        last SCAN;
                                }
                        }
@@ -181,17 +183,18 @@ sub test_database_handle {
        $dbh->{AutoCommit} = 1;
        $dbh->{RaiseError} = 0;
        $dbh->do("CREATE USER $dbuser SUPERUSER");
-       $dbh->do("CREATE USER sixpack NOSUPERUSER CREATEDB");
-       $dbh->do("CREATE USER readonly NOSUPERUSER NOCREATEDB");
-       $dbh->do("ALTER USER readonly SET default_transaction_read_only = 1");
-       $dbh->do("CREATE DATABASE beedeebeedee");
-       $dbh->do("CREATE DATABASE ardala");
-    $dbh->do("CREATE LANGUAGE plpgsql");
+       $dbh->do('CREATE USER sixpack NOSUPERUSER CREATEDB');
+       $dbh->do('CREATE USER readonly NOSUPERUSER NOCREATEDB');
+       $dbh->do('ALTER USER readonly SET default_transaction_read_only = 1');
+       $dbh->do('CREATE DATABASE beedeebeedee');
+       $dbh->do('CREATE DATABASE ardala');
+    $dbh->do('CREATE LANGUAGE plpgsql');
+    $dbh->do('CREATE LANGUAGE plperlu');
        $dbh->{AutoCommit} = 0;
        $dbh->{RaiseError} = 1;
 
        if (! exists $self->{keep_old_schema}) {
-               my $SQL = "SELECT count(*) FROM pg_namespace WHERE nspname = " . $dbh->quote($fakeschema);
+               my $SQL = 'SELECT count(*) FROM pg_namespace WHERE nspname = ' . $dbh->quote($fakeschema);
                my $count = $dbh->selectall_arrayref($SQL)->[0][0];
                if ($count) {
                        local $dbh->{Warn} = 0;
@@ -206,7 +209,7 @@ sub test_database_handle {
                eval { $tmp_dbh = DBI->connect($tmp_dsn, @superdsn[1..$#superdsn]) };
                if ($@) {
                        local($dbh->{AutoCommit}) = 1;
-                       $dbh->do("CREATE DATABASE " . $arg->{dbname});
+                       $dbh->do('CREATE DATABASE ' . $arg->{dbname});
                        eval { $tmp_dbh = DBI->connect($tmp_dsn, @superdsn[1..$#superdsn]) };
                        die $@ if $@;
                }
@@ -221,8 +224,8 @@ sub test_database_handle {
 
        ## Sanity check
        $dbh->do("ALTER USER $dbuser SET search_path = public");
-       $dbh->do("SET search_path = public");
-       $dbh->do("COMMIT");
+       $dbh->do('SET search_path = public');
+       $dbh->do('COMMIT');
 
        return $dbh;
 
@@ -246,9 +249,9 @@ sub run {
 
        my $double = $action =~ s/DB2// ? 1 : 0;
 
-       my $dbhost = $self->{dbhost}   || die "No dbhost?";
-       my $dbuser = $self->{testuser} || die "No testuser?";
-       my $dbname = $self->{dbname}   || die "No dbname?";
+       my $dbhost = $self->{dbhost}   || die 'No dbhost?';
+       my $dbuser = $self->{testuser} || die 'No testuser?';
+       my $dbname = $self->{dbname}   || die 'No dbname?';
        my $com = qq{perl check_postgres.pl --action=$action --dbhost="$dbhost" --dbuser=$dbuser};
     if ($extra =~ s/--nodbname//) {
     }
@@ -345,6 +348,7 @@ sub create_fake_pg_table {
 
        $dbh->do("ALTER USER $dbuser SET search_path = $fakeschema, public, pg_catalog");
        $dbh->commit();
+       return;
 
 } ## end of create_fake_pg_table
 
@@ -365,6 +369,7 @@ sub set_fake_schema {
 
        $dbh->do("ALTER USER $dbuser SET search_path = $fakeschema, public, pg_catalog");
        $dbh->commit();
+       return;
 
 } ## end of set_fake_schema
 
@@ -399,9 +404,10 @@ sub drop_schema_if_exists {
 
        my ($self,$name) = @_;
        my $dbh = $self->{dbh} || die;
+       $name ||= $fakeschema;
 
        if (! exists $self->{keep_old_schema}) {
-               my $SQL = "SELECT count(*) FROM pg_namespace WHERE nspname = " . $dbh->quote($name);
+               my $SQL = 'SELECT count(*) FROM pg_namespace WHERE nspname = ' . $dbh->quote($name);
                my $count = $dbh->selectall_arrayref($SQL)->[0][0];
                if ($count) {
                        local $dbh->{Warn};
@@ -427,7 +433,7 @@ sub drop_table_if_exists {
 
        my $safetable = $dbh->quote($name);
        my $safeschema = $dbh->quote($schema);
-       my $SQL = $schema 
+       my $SQL = $schema
                ? q{SELECT count(*) FROM pg_class c JOIN pg_namespace n ON (n.oid = c.relnamespace) }.
                  qq{WHERE relkind = 'r' AND nspname = $safeschema AND relname = $safetable}
         : qq{SELECT count(*) FROM pg_class WHERE relkind='r' AND relname = $safetable};
@@ -470,6 +476,7 @@ sub drop_sequence_if_exists {
                $dbh->do("DROP SEQUENCE $name");
                $dbh->commit();
        }
+       return;
 
 } ## end of drop_sequence_if_exists
 
@@ -531,6 +538,7 @@ sub fake_self_version {
        print $fh $slurp;
        truncate $fh, tell($fh);
        close $fh or die qq{Could not close "$file": $!\n};
+       return;
 
 } ## end of fake_self_version
 
@@ -547,6 +555,7 @@ sub restore_self_version {
        print $fh $slurp;
        truncate $fh, tell($fh);
        close $fh or die qq{Could not close "$file": $!\n};
+       return;
 
 } ## end of restore_self_version
 
@@ -570,7 +579,25 @@ sub drop_all_tables {
                $dbh->do("DROP TABLE $tab CASCADE");
        }
        $dbh->commit();
+       return;
 
 } ## end of drop_all_tables
 
+sub database_sleep {
+
+       my ($self,$dbh,$time) = @_;
+
+       my $ver = $dbh->{pg_server_version};
+
+       if ($ver < 80200) {
+               my $SQL = q{CREATE OR REPLACE FUNCTION pg_sleep(float) RETURNS VOID LANGUAGE plperlu AS 'select(undef,undef,undef,shift)'};
+               $dbh->do($SQL);
+               $dbh->commit();
+       }
+       $dbh->do(qq{SELECT pg_sleep($time)});
+       return;
+
+
+} ## end of database_sleep
+
 1;