Grokbase Groups Perl dbi-dev May 2003
FAQ
It's nice to see the new version of DBD::Pg caches the server version
calls, but
there's a couple of very obvious bugs you've missed.

Line 911 in sub table_attributes... you don't fully reference the sub
name correctly.

my $version = pg_server_version( $dbh );

should be

my $version = DBD::Pg::pg_server_version( $dbh );



Secondly, you should probably cache a failure to get the version,
to avoid repeatedly attempting.

## Used by both the dr and db packages
sub pg_server_version {
my $dbh = shift;
return $dbh->{pg_server_version} if defined
$dbh->{pg_server_version};

my ($version) = $dbh->selectrow_array("SELECT version();");
return 0 unless $version =~ /^PostgreSQL ([\d\.]+)/;
$dbh{pg_server_version} = $1;
return $dbh{pg_server_version};
}

should become

sub pg_server_version {
my $dbh = shift;
return $dbh->{pg_server_version} if defined
$dbh->{pg_server_version};

my ($version) = $dbh->selectrow_array("SELECT version();");
$dbh{pg_server_version} = $version =~ /^PostgreSQL ([\d\.]+)/ ? $1
: 0;
return $dbh{pg_server_version};
}

And thirdly, while I haven't tested it, I have doubts about whether

my $version = $dbh->pg_server_version;

would work as well... ( in foreign_key_info )

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupdbi-dev @
categoriesperl
postedMay 6, '03 at 7:08p
activeMay 6, '03 at 7:08p
posts1
users1
websitedbi.perl.org

1 user in discussion

David Wheeler: 1 post

People

Translate

site design / logo © 2019 Grokbase