| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Pg::CLI::Role::Connects; |
|
2
|
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
3398
|
use strict; |
|
|
5
|
|
|
|
|
14
|
|
|
|
5
|
|
|
|
|
162
|
|
|
4
|
5
|
|
|
5
|
|
28
|
use warnings; |
|
|
5
|
|
|
|
|
10
|
|
|
|
5
|
|
|
|
|
149
|
|
|
5
|
5
|
|
|
5
|
|
27
|
use namespace::autoclean; |
|
|
5
|
|
|
|
|
27
|
|
|
|
5
|
|
|
|
|
33
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.14'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
5
|
|
|
5
|
|
2972
|
use IPC::Run3 qw( run3 ); |
|
|
5
|
|
|
|
|
135528
|
|
|
|
5
|
|
|
|
|
336
|
|
|
10
|
5
|
|
|
5
|
|
1938
|
use MooseX::Params::Validate qw( validated_hash validated_list ); |
|
|
5
|
|
|
|
|
349584
|
|
|
|
5
|
|
|
|
|
46
|
|
|
11
|
5
|
|
|
5
|
|
3535
|
use MooseX::Types::Moose qw( ArrayRef Bool Defined Str ); |
|
|
5
|
|
|
|
|
222044
|
|
|
|
5
|
|
|
|
|
50
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
5
|
|
|
5
|
|
27768
|
use Moose::Role; |
|
|
5
|
|
|
|
|
14
|
|
|
|
5
|
|
|
|
|
45
|
|
|
14
|
5
|
|
|
5
|
|
27477
|
use MooseX::SemiAffordanceAccessor; |
|
|
5
|
|
|
|
|
13
|
|
|
|
5
|
|
|
|
|
35
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
with 'Pg::CLI::Role::HasVersion'; |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
for my $attr (qw( username password host port )) { |
|
19
|
|
|
|
|
|
|
has $attr => ( |
|
20
|
|
|
|
|
|
|
is => 'rw', |
|
21
|
|
|
|
|
|
|
isa => Str, |
|
22
|
|
|
|
|
|
|
predicate => '_has_' . $attr, |
|
23
|
|
|
|
|
|
|
); |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
has require_ssl => ( |
|
27
|
|
|
|
|
|
|
is => 'ro', |
|
28
|
|
|
|
|
|
|
isa => 'Bool', |
|
29
|
|
|
|
|
|
|
default => 0, |
|
30
|
|
|
|
|
|
|
); |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub run { |
|
33
|
21
|
|
|
21
|
0
|
5767
|
my $self = shift; |
|
34
|
21
|
|
|
|
|
89
|
my ( $database, $options, $stdin, $stdout, $stderr ) = validated_list( |
|
35
|
|
|
|
|
|
|
\@_, |
|
36
|
|
|
|
|
|
|
database => { isa => Str, optional => 1 }, |
|
37
|
|
|
|
|
|
|
options => { |
|
38
|
|
|
|
|
|
|
isa => ArrayRef [Str], default => [], |
|
39
|
|
|
|
|
|
|
}, |
|
40
|
|
|
|
|
|
|
stdin => { isa => Defined, optional => 1 }, |
|
41
|
|
|
|
|
|
|
stdout => { isa => Defined, optional => 1 }, |
|
42
|
|
|
|
|
|
|
stderr => { isa => Defined, optional => 1 }, |
|
43
|
|
|
|
|
|
|
); |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
$self->_execute_command( |
|
46
|
|
|
|
|
|
|
[ |
|
47
|
|
|
|
|
|
|
$self->executable(), |
|
48
|
|
|
|
|
|
|
$self->_connect_options(), |
|
49
|
|
|
|
|
|
|
$self->_run_options($database), |
|
50
|
21
|
100
|
100
|
|
|
212385
|
@{$options}, |
|
|
21
|
|
|
|
|
98
|
|
|
51
|
|
|
|
|
|
|
( $database && $self->_database_at_end() ? $database : () ), |
|
52
|
|
|
|
|
|
|
], |
|
53
|
|
|
|
|
|
|
$stdin, |
|
54
|
|
|
|
|
|
|
$stdout, |
|
55
|
|
|
|
|
|
|
$stderr, |
|
56
|
|
|
|
|
|
|
); |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub _database_at_end { |
|
60
|
16
|
|
|
16
|
|
96
|
return 1; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub _run_options { |
|
64
|
11
|
|
|
11
|
|
33
|
return; |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub _execute_command { |
|
68
|
21
|
|
|
21
|
|
37
|
my $self = shift; |
|
69
|
|
|
|
|
|
|
|
|
70
|
21
|
100
|
|
|
|
1087
|
local $ENV{PGPASSWORD} = $self->password() |
|
71
|
|
|
|
|
|
|
if $self->_has_password(); |
|
72
|
|
|
|
|
|
|
|
|
73
|
21
|
100
|
|
|
|
553
|
local $ENV{PGSSLMODE} = 'require' |
|
74
|
|
|
|
|
|
|
if $self->require_ssl(); |
|
75
|
|
|
|
|
|
|
|
|
76
|
21
|
|
|
|
|
81
|
$self->_call_run3(@_); |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# This is a separate sub to provide something we can override in testing |
|
80
|
|
|
|
|
|
|
sub _call_run3 { |
|
81
|
0
|
|
|
0
|
|
0
|
shift; |
|
82
|
0
|
|
|
|
|
0
|
my $cmd = shift; |
|
83
|
0
|
|
0
|
|
|
0
|
my $stdin = shift || \undef; |
|
84
|
0
|
|
0
|
|
|
0
|
my $stdout = shift || \undef; |
|
85
|
0
|
|
0
|
|
|
0
|
my $stderr = shift || \undef; |
|
86
|
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
0
|
run3( |
|
88
|
|
|
|
|
|
|
$cmd, |
|
89
|
|
|
|
|
|
|
$stdin, |
|
90
|
|
|
|
|
|
|
$stdout, |
|
91
|
|
|
|
|
|
|
$stderr, |
|
92
|
|
|
|
|
|
|
); |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub _connect_options { |
|
96
|
21
|
|
|
21
|
|
44
|
my $self = shift; |
|
97
|
|
|
|
|
|
|
|
|
98
|
21
|
|
|
|
|
50
|
my @options; |
|
99
|
|
|
|
|
|
|
|
|
100
|
21
|
100
|
|
|
|
645
|
push @options, '-U', $self->username() |
|
101
|
|
|
|
|
|
|
if $self->_has_username(); |
|
102
|
|
|
|
|
|
|
|
|
103
|
21
|
100
|
|
|
|
583
|
push @options, '-h', $self->host() |
|
104
|
|
|
|
|
|
|
if $self->_has_host(); |
|
105
|
|
|
|
|
|
|
|
|
106
|
21
|
100
|
|
|
|
674
|
push @options, '-p', $self->port() |
|
107
|
|
|
|
|
|
|
if $self->_has_port(); |
|
108
|
|
|
|
|
|
|
|
|
109
|
21
|
100
|
|
|
|
557
|
push @options, '-w' |
|
110
|
|
|
|
|
|
|
if $self->two_part_version >= 8.4; |
|
111
|
|
|
|
|
|
|
|
|
112
|
21
|
|
|
|
|
104
|
return @options; |
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
1; |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=for Pod::Coverage run |