line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Class::DBI::Loader::Pg; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
21
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
90
|
|
4
|
2
|
|
|
2
|
|
11
|
use base 'Class::DBI::Loader::Generic'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
7443
|
|
5
|
2
|
|
|
2
|
|
68516
|
use vars '$VERSION'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
170
|
|
6
|
2
|
|
|
2
|
|
5309
|
use DBI; |
|
2
|
|
|
|
|
46973
|
|
|
2
|
|
|
|
|
164
|
|
7
|
2
|
|
|
2
|
|
22
|
use Carp; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
133
|
|
8
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
939
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
require Class::DBI::Pg; |
11
|
|
|
|
|
|
|
require Class::DBI::Loader::Generic; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
$VERSION = '0.30'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 NAME |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Class::DBI::Loader::Pg - Class::DBI::Loader Postgres Implementation. |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 SYNOPSIS |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
use Class::DBI::Loader; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# $loader is a Class::DBI::Loader::Pg |
24
|
|
|
|
|
|
|
my $loader = Class::DBI::Loader->new( |
25
|
|
|
|
|
|
|
dsn => "dbi:Pg:dbname=dbname", |
26
|
|
|
|
|
|
|
user => "postgres", |
27
|
|
|
|
|
|
|
password => "", |
28
|
|
|
|
|
|
|
namespace => "Data", |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
my $class = $loader->find_class('film'); # $class => Data::Film |
31
|
|
|
|
|
|
|
my $obj = $class->retrieve(1); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 DESCRIPTION |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
See L, L. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=cut |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
0
|
|
|
sub _db_class { return 'Class::DBI::Pg' } |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub _tables { |
42
|
0
|
|
|
0
|
|
|
my $self = shift; |
43
|
0
|
0
|
|
|
|
|
my $dbh = DBI->connect( @{ $self->{_datasource} } ) or croak($DBI::errstr); |
|
0
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# we do this check here because we don't really want to include this as |
46
|
|
|
|
|
|
|
# a pre-requisite in the Makefile.PL for all those non-Pg users |
47
|
0
|
|
|
|
|
|
my $sth = $dbh->prepare("SELECT version()"); |
48
|
0
|
|
|
|
|
|
$sth->execute(); |
49
|
0
|
|
|
|
|
|
my($vstr) = $sth->fetchrow_array(); |
50
|
0
|
|
|
|
|
|
$sth->finish; |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
my($pg_version) = $vstr =~ /^PostgreSQL ([\d\.]{3})/; |
53
|
0
|
0
|
0
|
|
|
|
if ($pg_version >= 8 && $Class::DBI::Pg::VERSION < 0.07) { |
54
|
0
|
|
|
|
|
|
die "Class::DBI::Pg $Class::DBI::Pg::VERSION does not support PostgreSQL > 8.x"; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
0
|
|
|
|
$self->{_namespace} ||= 'public'; |
58
|
0
|
0
|
|
|
|
|
my @tables = ( $DBD::Pg::VERSION >= 1.31 ) ? |
59
|
|
|
|
|
|
|
$dbh->tables( undef, $self->{_namespace}, "", "table", |
60
|
|
|
|
|
|
|
{ noprefix => 1, pg_noprefix => 1 } ) : |
61
|
|
|
|
|
|
|
$dbh->tables; |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
@tables = map {s/^public:://;$_} @tables; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
$dbh->disconnect; |
65
|
0
|
|
|
|
|
|
return @tables; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 AUTHOR |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Daisuke Maki C |
71
|
|
|
|
|
|
|
( except for lines 62, 58, and 56 ) |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 SEE ALSO |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
L, L |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=cut |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
1; |