| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Amon2::DBI; |
|
2
|
7
|
|
|
7
|
|
133587
|
use strict; |
|
|
7
|
|
|
|
|
15
|
|
|
|
7
|
|
|
|
|
272
|
|
|
3
|
7
|
|
|
7
|
|
37
|
use warnings; |
|
|
7
|
|
|
|
|
15
|
|
|
|
7
|
|
|
|
|
244
|
|
|
4
|
7
|
|
|
7
|
|
160
|
use 5.008001; |
|
|
7
|
|
|
|
|
28
|
|
|
|
7
|
|
|
|
|
429
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.32'; |
|
6
|
|
|
|
|
|
|
|
|
7
|
7
|
|
|
7
|
|
5655
|
use parent qw/DBI/; |
|
|
7
|
|
|
|
|
1897
|
|
|
|
7
|
|
|
|
|
36
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub connect { |
|
10
|
5
|
|
|
5
|
1
|
1705
|
my ($class, $dsn, $user, $pass, $attr) = @_; |
|
11
|
5
|
|
|
|
|
16
|
$attr->{RaiseError} = 1; |
|
12
|
5
|
|
|
|
|
9
|
$attr->{PrintError} = 0; |
|
13
|
5
|
|
|
|
|
12
|
$attr->{ShowErrorStatement} = 1; |
|
14
|
5
|
50
|
|
|
|
22
|
if ($DBI::VERSION >= 1.614) { |
|
15
|
5
|
50
|
|
|
|
23
|
$attr->{AutoInactiveDestroy} = 1 unless exists $attr->{AutoInactiveDestroy}; |
|
16
|
|
|
|
|
|
|
} |
|
17
|
5
|
100
|
|
|
|
35
|
if ($dsn =~ /^dbi:SQLite:/i) { |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
18
|
4
|
50
|
|
|
|
46
|
$attr->{sqlite_unicode} = 1 unless exists $attr->{sqlite_unicode}; |
|
19
|
|
|
|
|
|
|
} |
|
20
|
|
|
|
|
|
|
elsif ($dsn =~ /^dbi:mysql:/i) { |
|
21
|
0
|
0
|
|
|
|
0
|
$attr->{mysql_enable_utf8} = 1 unless exists $attr->{mysql_enable_utf8}; |
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
elsif ($dsn =~ /^dbi:Pg:/i) { |
|
24
|
0
|
|
|
|
|
0
|
my $dbd_pg_version = eval { require DBD::Pg; (DBD::Pg->VERSION =~ /^([.0-9]+)\./)[0] }; |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
25
|
0
|
0
|
0
|
|
|
0
|
if ( !$@ and $dbd_pg_version < 2.99 ) { # less than DBD::Pg 2.99, pg_enable_utf8 must be set for utf8. |
|
26
|
0
|
0
|
|
|
|
0
|
$attr->{pg_enable_utf8} = 1 unless exists $attr->{pg_enable_utf8}; |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
} |
|
29
|
5
|
50
|
|
|
|
45
|
my $self = $class->SUPER::connect($dsn, $user, $pass, $attr) or die "Cannot connect to server: $DBI::errstr"; |
|
30
|
4
|
|
|
|
|
695
|
return $self; |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
package Amon2::DBI::dr; |
|
34
|
|
|
|
|
|
|
our @ISA = qw(DBI::dr); |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
package Amon2::DBI::db; # database handler |
|
37
|
|
|
|
|
|
|
our @ISA = qw(DBI::db); |
|
38
|
|
|
|
|
|
|
|
|
39
|
7
|
|
|
7
|
|
443757
|
use DBIx::TransactionManager; |
|
|
7
|
|
|
|
|
26814
|
|
|
|
7
|
|
|
|
|
226
|
|
|
40
|
7
|
|
|
7
|
|
8954
|
use SQL::Interp (); |
|
|
7
|
|
|
|
|
149713
|
|
|
|
7
|
|
|
|
|
233
|
|
|
41
|
7
|
|
|
7
|
|
72
|
use Carp (); |
|
|
7
|
|
|
|
|
13
|
|
|
|
7
|
|
|
|
|
116
|
|
|
42
|
7
|
|
|
7
|
|
38
|
use Scalar::Util (); |
|
|
7
|
|
|
|
|
11
|
|
|
|
7
|
|
|
|
|
2306
|
|
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub connected { |
|
45
|
4
|
|
|
4
|
|
6888
|
my $dbh = shift; |
|
46
|
4
|
|
|
|
|
33
|
$dbh->{private_connect_info} = [@_]; |
|
47
|
4
|
|
|
|
|
43
|
$dbh->SUPER::connected(@_); |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
1
|
|
|
1
|
|
1080
|
sub connect_info { $_[0]->{private_connect_info} } |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub _txn_manager { |
|
53
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
|
54
|
0
|
0
|
|
|
|
0
|
if (not defined $self->{private_txn_manager}) { |
|
55
|
0
|
|
|
|
|
0
|
$self->{private_txn_manager} = DBIx::TransactionManager->new($self); |
|
56
|
0
|
|
|
|
|
0
|
Scalar::Util::weaken($self->{private_txn_manager}->{dbh}); |
|
57
|
|
|
|
|
|
|
} |
|
58
|
0
|
|
|
|
|
0
|
return $self->{private_txn_manager}; |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
0
|
|
|
0
|
|
0
|
sub txn_scope { $_[0]->_txn_manager->txn_scope(caller => [caller(0)]) } |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub do_i { |
|
64
|
6
|
|
|
6
|
|
1049
|
my $self = shift; |
|
65
|
6
|
|
|
|
|
29
|
my ($sql, @bind) = SQL::Interp::sql_interp(@_); |
|
66
|
6
|
|
|
|
|
677
|
$self->do($sql, {}, @bind); |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub insert { |
|
70
|
4
|
|
|
4
|
|
4693
|
my ($self, $table, $vars) = @_; |
|
71
|
4
|
|
|
|
|
18
|
$self->do_i("INSERT INTO $table", $vars); |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
package Amon2::DBI::st; # statement handler |
|
75
|
|
|
|
|
|
|
our @ISA = qw(DBI::st); |
|
76
|
|
|
|
|
|
|
|
|
77
|
0
|
|
|
0
|
|
|
sub sql { $_[0]->{private_sql} } |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |
|
80
|
|
|
|
|
|
|
__END__ |