line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# internal utility subroutines used by multiple classes |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package DBIx::DBSchema::_util; |
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
12
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
57
|
|
6
|
2
|
|
|
2
|
|
9
|
use vars qw(@ISA @EXPORT_OK); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
79
|
|
7
|
2
|
|
|
2
|
|
9
|
use Exporter; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
52
|
|
8
|
2
|
|
|
2
|
|
10
|
use Carp qw(confess); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
90
|
|
9
|
2
|
|
|
2
|
|
2658
|
use DBI; |
|
2
|
|
|
|
|
31486
|
|
|
2
|
|
|
|
|
618
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
12
|
|
|
|
|
|
|
@EXPORT_OK = qw( _load_driver _dbh _parse_opt ); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub _load_driver { |
15
|
2
|
|
|
2
|
|
4
|
my($dbh) = @_; |
16
|
2
|
|
|
|
|
3
|
my $driver; |
17
|
2
|
50
|
|
|
|
4
|
if ( ref($dbh) ) { |
18
|
0
|
|
|
|
|
0
|
$driver = $dbh->{Driver}->{Name}; |
19
|
|
|
|
|
|
|
} else { |
20
|
2
|
50
|
|
|
|
16
|
$dbh =~ s/^dbi:(\w*?)(?:\((.*?)\))?://i #nicked from DBI->connect |
21
|
|
|
|
|
|
|
or '' =~ /()/; # ensure $1 etc are empty if match fails |
22
|
2
|
50
|
|
|
|
6
|
$driver = $1 or confess "can't parse data source: $dbh"; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
#require "DBIx/DBSchema/DBD/$driver.pm"; |
26
|
|
|
|
|
|
|
#$driver; |
27
|
2
|
50
|
33
|
|
|
107
|
eval 'require "DBIx/DBSchema/DBD/$driver.pm"' and $driver or die $@; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
#sub _dbh_or_dbi_connect_args { |
31
|
|
|
|
|
|
|
sub _dbh { |
32
|
1
|
|
|
1
|
|
2
|
my($dbh) = shift; |
33
|
1
|
|
|
|
|
2
|
my $created_dbh = 0; |
34
|
1
|
50
|
33
|
|
|
5
|
unless ( ref($dbh) || ! @_ ) { |
35
|
0
|
0
|
|
|
|
0
|
$dbh = DBI->connect( $dbh, @_ ) or die $DBI::errstr; |
36
|
0
|
|
|
|
|
0
|
$created_dbh = 1; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
1
|
|
|
|
|
4
|
( $dbh, $created_dbh ); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub _parse_opt { |
43
|
0
|
|
|
0
|
|
|
my $optref = shift; |
44
|
0
|
0
|
|
|
|
|
if ( ref( $optref->[0] ) eq 'HASH' ) { |
45
|
0
|
|
|
|
|
|
shift @$optref; |
46
|
|
|
|
|
|
|
} else { |
47
|
0
|
|
|
|
|
|
{}; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
|