line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
13
|
|
|
13
|
|
71035
|
use strict; use warnings; |
|
13
|
|
|
13
|
|
31
|
|
|
13
|
|
|
|
|
418
|
|
|
13
|
|
|
|
|
71
|
|
|
13
|
|
|
|
|
25
|
|
|
13
|
|
|
|
|
7497
|
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package DBIx::Connector::Driver; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.59'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
DRIVERS: { |
8
|
|
|
|
|
|
|
my %DRIVERS; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
32
|
|
|
32
|
1
|
5075
|
my ($class, $driver) = @_; |
12
|
32
|
|
66
|
|
|
185
|
return $DRIVERS{$driver} ||= do { |
13
|
12
|
|
|
|
|
71
|
my $subclass = __PACKAGE__ . "::$driver"; |
14
|
12
|
|
|
|
|
950
|
eval "require $subclass"; |
15
|
12
|
100
|
|
|
|
102
|
$class = $subclass unless $@; |
16
|
12
|
|
|
|
|
192
|
bless { driver => $driver } => $class; |
17
|
|
|
|
|
|
|
}; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub _connect { |
22
|
60
|
|
|
60
|
|
220
|
my ($self, $dbh, $dsn, $username, $password, $attrs) = @_; |
23
|
60
|
|
|
|
|
396
|
$dbh; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub ping { |
27
|
60
|
|
|
60
|
1
|
128
|
my ($self, $dbh) = @_; |
28
|
60
|
|
|
|
|
176
|
$dbh->ping; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub begin_work { |
32
|
62
|
|
|
62
|
1
|
128
|
my ($self, $dbh) = @_; |
33
|
62
|
|
|
|
|
238
|
$dbh->begin_work; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub commit { |
37
|
45
|
|
|
45
|
1
|
103
|
my ($self, $dbh) = @_; |
38
|
45
|
|
|
|
|
347
|
$dbh->commit; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub rollback { |
42
|
3
|
|
|
3
|
1
|
1211
|
my ($self, $dbh) = @_; |
43
|
3
|
|
|
|
|
27
|
$dbh->rollback; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub _rollback { |
47
|
11
|
|
|
11
|
|
30
|
my ($self, $dbh, $err) = @_; |
48
|
11
|
|
|
|
|
20
|
local $@; |
49
|
11
|
|
|
|
|
20
|
eval { $dbh->rollback }; |
|
11
|
|
|
|
|
52
|
|
50
|
11
|
100
|
|
|
|
169
|
return $@ ? DBIx::Connector::TxnRollbackError->new( |
51
|
|
|
|
|
|
|
error => $err, |
52
|
|
|
|
|
|
|
rollback_error => $@, |
53
|
|
|
|
|
|
|
) : $err; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub _rollback_and_release { |
57
|
4
|
|
|
4
|
|
10
|
my ($self, $dbh, $name, $err) = @_; |
58
|
4
|
|
|
|
|
6
|
local $@; |
59
|
4
|
|
|
|
|
7
|
eval { |
60
|
4
|
|
|
|
|
12
|
$self->rollback_to($dbh, $name); |
61
|
0
|
|
|
|
|
0
|
$self->release($dbh, $name); |
62
|
|
|
|
|
|
|
}; |
63
|
4
|
50
|
|
|
|
37
|
return $@ ? DBIx::Connector::SvpRollbackError->new( |
64
|
|
|
|
|
|
|
error => $err, |
65
|
|
|
|
|
|
|
rollback_error => $@, |
66
|
|
|
|
|
|
|
) : $err; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub savepoint { |
70
|
0
|
|
|
0
|
1
|
0
|
my ($self, $dbh, $name) = @_; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub release { |
74
|
0
|
|
|
0
|
1
|
0
|
my ($self, $dbh, $name) = @_; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub rollback_to { |
78
|
0
|
|
|
0
|
1
|
0
|
my ($self, $dbh, $name) = @_; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
ROLLBACKERR: { |
82
|
|
|
|
|
|
|
package DBIx::Connector::RollbackError; |
83
|
|
|
|
|
|
|
our $VERSION = '0.58'; |
84
|
|
|
|
|
|
|
# an exception is always true |
85
|
13
|
|
|
13
|
|
15394
|
use overload bool => sub {1}, '""' => 'as_string', fallback => 1; |
|
13
|
|
|
13
|
|
12633
|
|
|
13
|
|
|
|
|
126
|
|
|
13
|
|
|
|
|
1091
|
|
86
|
|
|
|
|
|
|
|
87
|
11
|
|
|
11
|
|
26
|
sub new { my $c = shift; bless {@_} => $c; } |
|
11
|
|
|
|
|
50
|
|
88
|
27
|
|
|
27
|
|
194
|
sub error { shift->{error} } |
89
|
24
|
|
|
24
|
|
4150
|
sub rollback_error { shift->{rollback_error} } |
90
|
|
|
|
|
|
|
sub as_string { |
91
|
15
|
|
|
15
|
|
7030
|
my $self = shift; |
92
|
15
|
|
|
|
|
66
|
my $label = $self->_label; |
93
|
15
|
|
|
|
|
71
|
return "$label aborted: " . $self->error |
94
|
|
|
|
|
|
|
. "$label rollback failed: " . $self->rollback_error; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
package DBIx::Connector::TxnRollbackError; |
98
|
|
|
|
|
|
|
our $VERSION = '0.58'; |
99
|
|
|
|
|
|
|
our @ISA = qw( DBIx::Connector::RollbackError ); |
100
|
9
|
|
|
9
|
|
23
|
sub _label { 'Transaction' } |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
package DBIx::Connector::SvpRollbackError; |
103
|
|
|
|
|
|
|
our $VERSION = '0.58'; |
104
|
|
|
|
|
|
|
our @ISA = qw( DBIx::Connector::RollbackError ); |
105
|
6
|
|
|
6
|
|
11
|
sub _label { 'Savepoint' } |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
1; |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
__END__ |