Subject: | Bad calls to ph_server_version |
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 )