line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
27361
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
2
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
46
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package DBD::PassThrough; |
5
|
1
|
|
|
1
|
|
21
|
use 5.008005; |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
224
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
{ |
9
|
|
|
|
|
|
|
package DBD::PassThrough; |
10
|
|
|
|
|
|
|
require DBI; |
11
|
|
|
|
|
|
|
DBI->require_version(1.0201); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $drh = undef; # holds driver handle(s) once initialized |
14
|
|
|
|
|
|
|
our $imp_data_size = 0; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub driver($;$) { |
17
|
0
|
|
|
0
|
0
|
|
my ($class, $attr) = @_; |
18
|
0
|
0
|
|
|
|
|
$drh->{$class} and return $drh->{$class}; # Is this line needed? |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
0
|
|
|
|
$attr ||= +{}; |
21
|
0
|
|
0
|
|
|
|
$attr->{Attribution} ||= __PACKAGE__ . ' by tokuhirom'; |
22
|
0
|
|
0
|
|
|
|
$attr->{Version} ||= $VERSION; |
23
|
0
|
|
0
|
|
|
|
$attr->{Name} ||= 'PassThrough'; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# Make delegater methods |
26
|
|
|
|
|
|
|
# This is needed like '$dbh->func("last_insert_rowid")' |
27
|
|
|
|
|
|
|
{ |
28
|
0
|
|
|
|
|
|
my %drivers = DBI->installed_drivers; |
|
0
|
|
|
|
|
|
|
29
|
1
|
|
|
1
|
|
4
|
no strict 'refs'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
649
|
|
30
|
0
|
|
|
|
|
|
for my $db_class (keys %drivers) { |
31
|
0
|
|
|
|
|
|
my @meth = grep !/^[_A-Z]/, keys %{"DBD::${db_class}::db::"}; |
|
0
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
for my $meth (sort @meth) { |
33
|
0
|
0
|
|
|
|
|
next if DBD::PassThrough::db->can($meth); |
34
|
0
|
|
|
|
|
|
*{"DBD::PassThrough::db::${meth}"} = sub { |
35
|
0
|
|
|
0
|
|
|
my $dbh = shift; |
36
|
0
|
|
|
|
|
|
return $dbh->{pass_through_source}->func($meth => @_); |
37
|
0
|
|
|
|
|
|
}; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
$drh->{$class} = DBI::_new_drh( $class . "::dr", $attr ); |
43
|
0
|
|
|
|
|
|
return $drh->{$class}; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
{ |
48
|
|
|
|
|
|
|
package DBD::PassThrough::dr; |
49
|
|
|
|
|
|
|
our $imp_data_size = 0; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
{ |
53
|
|
|
|
|
|
|
package DBD::PassThrough::db; |
54
|
|
|
|
|
|
|
our $imp_data_size = 0; |
55
|
|
|
|
|
|
|
sub STORE { |
56
|
0
|
|
|
0
|
|
|
my ($dbh, $attrib, $value) = @_; |
57
|
0
|
0
|
|
|
|
|
if ($dbh->{pass_through_source}) { |
58
|
0
|
|
|
|
|
|
return $dbh->{pass_through_source}->STORE($attrib, $value); |
59
|
|
|
|
|
|
|
} |
60
|
0
|
0
|
|
|
|
|
if ($attrib eq 'pass_through_source') { |
61
|
0
|
|
|
|
|
|
$dbh->{pass_through_source} = $value; |
62
|
0
|
|
|
|
|
|
return; |
63
|
|
|
|
|
|
|
} |
64
|
0
|
|
|
|
|
|
return $dbh->set_err($DBI::stderr, "Can't alter \$dbh->{$attrib} after handle created with DBD::PassThrough"); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
sub FETCH { |
67
|
0
|
|
|
0
|
|
|
my ($dbh, $attrib) = @_; |
68
|
0
|
0
|
|
|
|
|
if ($attrib eq 'pass_through_source') { |
69
|
0
|
|
|
|
|
|
return $dbh->{pass_through_source}; |
70
|
|
|
|
|
|
|
} |
71
|
0
|
0
|
|
|
|
|
if ($dbh->{pass_through_source}) { |
72
|
0
|
|
|
|
|
|
return $dbh->{pass_through_source}->FETCH($attrib); |
73
|
|
|
|
|
|
|
} |
74
|
0
|
0
|
|
|
|
|
if ($attrib eq 'Active') { |
75
|
0
|
|
|
|
|
|
return 0; # pass_through_source is not set yet. |
76
|
|
|
|
|
|
|
} |
77
|
0
|
|
|
|
|
|
return $dbh->set_err($DBI::stderr, "Can't fetch \$dbh->{$attrib} before connect with DBD::PassThrough"); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
# do not disconnect parent handle. |
81
|
|
|
|
|
|
|
sub disconnect { |
82
|
0
|
|
|
0
|
|
|
my $dbh = shift; |
83
|
0
|
|
|
|
|
|
delete $dbh->{pass_through_source}; |
84
|
0
|
|
|
|
|
|
return 1; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
# Generate methods |
88
|
|
|
|
|
|
|
for my $meth (qw(prepare table_info get_info type_info_all type_info column_info primary_key_info primary_key foreign_key_info tables quote quote_identifier)) { |
89
|
1
|
|
|
1
|
|
5
|
no strict 'refs'; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
91
|
|
90
|
|
|
|
|
|
|
*{"DBD::PassThrough::db::${meth}"} = sub { |
91
|
0
|
|
|
0
|
|
|
my $dbh = shift; |
92
|
0
|
|
|
|
|
|
return $dbh->{pass_through_source}->$meth(@_); |
93
|
|
|
|
|
|
|
}; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
1; |
98
|
|
|
|
|
|
|
__END__ |