File: 170_extensions.t

package info (click to toggle)
postgresql-common 282
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,528 kB
  • sloc: perl: 4,170; sh: 1,572; makefile: 327; sql: 13; ansic: 10
file content (84 lines) | stat: -rw-r--r-- 2,835 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# Check that all extensions install successfully.

use strict; 

use lib 't';
use TestLib;
use PgCommon;
use Test::More 0.87; # needs libtest-simple-perl backport on lenny

foreach my $v (@MAJORS) {
note "Running tests for $v";

if ($v < '9.1') {
    pass 'No extensions for version < 9.1';
    next;
}

# create cluster
is ((system "pg_createcluster $v main --start >/dev/null"), 0, "pg_createcluster $v main");

# plpgsql is installed by default
is_program_out 'postgres', "psql -Atc 'SELECT extname FROM pg_extension'", 0, "plpgsql\n";

my %depends = (
    bool_plperl       => [qw(plperl)],
    bool_plperlu      => [qw(plperlu)],
    earthdistance     => [qw(cube)],
    hstore_plperl     => [qw(hstore plperl)],
    hstore_plperlu    => [qw(hstore plperlu)],
    hstore_plpython3u => [qw(hstore plpython3u)],
    hstore_plpythonu  => [qw(hstore plpythonu)],
    jsonb_plperl      => [qw(plperl)],
    jsonb_plperlu     => [qw(plperlu)],
    jsonb_plpython3u  => [qw(plpython3u)],
    jsonb_plpythonu   => [qw(plpythonu)],
    ltree_plpython3u  => [qw(ltree plpython3u)],
    ltree_plpythonu   => [qw(ltree plpythonu)],
);

foreach (</usr/share/postgresql/$v/extension/*.control>) {
    my ($extname) = $_ =~ /^.*\/(.*)\.control$/;
    next if ($extname eq 'plpgsql');

    if ($depends{$extname}) {
        for my $dep (@{$depends{$extname}}) {
            is_program_out 'postgres', "psql -qc 'CREATE EXTENSION $dep'", 0, '',
                "$extname dependency $dep installs without error";
        }
    }

    if ($extname eq 'hstore' && $v eq '9.1') {
	# EXFAIL: hstore in 9.1 throws a warning about obsolete => operator
	like_program_out 'postgres', "psql -qc 'CREATE EXTENSION \"$extname\"'", 0,
	   qr/=>/, "extension $extname installs (with warning)";
    } elsif ($extname eq 'chkpass' && $v >= '9.5') {
        # chkpass is slightly broken, see
        # http://www.postgresql.org/message-id/20141117162116.GA3565@msg.df7cb.de
        like_program_out 'postgres', "psql -qc 'CREATE EXTENSION \"$extname\"'", 0,
            qr/WARNING:  type input function chkpass_in should not be volatile/,
            "extension $extname installs (with warning)";
    } else {
	is_program_out 'postgres', "psql -qc 'CREATE EXTENSION \"$extname\"'", 0, '',
	    "extension $extname installs without error";
    }

    is_program_out 'postgres', "psql -qc 'DROP EXTENSION \"$extname\"'", 0, '',
	"extension $extname removes without error";

    if ($depends{$extname}) {
        for my $dep (@{$depends{$extname}}) {
            is_program_out 'postgres', "psql -qc 'DROP EXTENSION $dep'", 0, '',
                "$extname dependency extension $dep removes without error";
        }
    }
}

# clean up
is ((system "pg_dropcluster $v main --stop"), 0, "pg_dropcluster $v main");
check_clean;
}

done_testing();

# vim: filetype=perl