Skip Menu |

This queue is for tickets about the DBD-Pg CPAN distribution.

Report information
The Basics
Id: 12968
Status: resolved
Priority: 0/
Queue: DBD-Pg

People
Owner: Nobody in particular
Requestors: szinger [...] lanl.gov
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.41
Fixed in: 1.43



Subject: get_info(18) returns all 0s.
Tested with DBD::Pg 1.41 and 1.42 against server versions 8.0.2 and 8.0.3. I've not tested against a 7.x server. I expect $dbh->get_info(18) to return a meaningful version string, e.g. '08.00.0300', but it returns '00.00.0000'. #!/usr/bin/perl use warnings; use strict; use DBI; my $dbh = DBI->connect( "dbi:Pg:dbname=template1") or die "Cannot connect"; print $dbh->{pg_server_version}, "\n"; # 80003 print $dbh->get_info(18), "\n"; # 00.00.0000
From: adamk [...] cpan.org
[guest - Thu May 26 15:49:27 2005]: Show quoted text
> Tested with DBD::Pg 1.41 and 1.42 against server versions 8.0.2 and > 8.0.3. I've not tested against a 7.x server. > > I expect $dbh->get_info(18) to return a meaningful version string, > e.g. '08.00.0300', but it returns '00.00.0000'. > > #!/usr/bin/perl > use warnings; > use strict; > > use DBI; > > my $dbh = DBI->connect( "dbi:Pg:dbname=template1") or die "Cannot > connect"; > > print $dbh->{pg_server_version}, "\n"; # 80003 > print $dbh->get_info(18), "\n"; # 00.00.0000
For some reason, Postgres is supplying DDDDD for 7.4+, but get_info(18) expects DD.DDD, and thus assumes it is pre-7.3 and returns null (00.00.0000).
this patch works for me.
diff -Naur DBD-Pg-1.42/Pg.pm new/Pg.pm --- DBD-Pg-1.42/Pg.pm Sun May 22 00:36:05 2005 +++ new/Pg.pm Mon May 30 21:38:59 2005 @@ -1269,8 +1269,13 @@ } elsif ($ans eq 'ODBCVERSION') { my $version = $dbh->{private_dbdpg}{version}; - my $dotted = $version =~ /(\d\d?)\.(\d\d)(\d\d)$/ ? "$1.$2.$4" : "0.0.0"; - return sprintf "%02d.%02d.%1d%1d%1d%1d", split (/\./, "$dotted.0.0.0.0.0.0"); + if ($version > 80000) { + my $dotted = $version =~ /(\d?\d)(\d\d)(\d\d)$/ ? "$1.$2.$3" : "0.0.0"; + return sprintf "%02d.%02d.%1d%1d%1d%1d", split (/\./, "$dotted.0.0.0.0.0.0"); + } else { + my $dotted = $version =~ /(\d\d?)\.(\d\d)(\d\d)$/ ? "$1.$2.$3" : "0.0.0"; + return sprintf "%02d.%02d.%1d%1d%1d%1d", split (/\./, "$dotted.0.0.0.0.0.0"); + } } elsif ($ans eq 'DBDVERSION') { my $simpleversion = $DBD::Pg::VERSION; diff -Naur DBD-Pg-1.42/t/03dbmethod.t new/t/03dbmethod.t --- DBD-Pg-1.42/t/03dbmethod.t Tue May 17 08:50:51 2005 +++ new/t/03dbmethod.t Mon May 30 21:47:24 2005 @@ -17,7 +17,7 @@ $|=1; if (defined $ENV{DBI_DSN}) { - plan tests => 137; + plan tests => 138; } else { plan skip_all => 'Cannot run test unless DBI_DSN is defined. See the README file'; } @@ -265,6 +265,9 @@ my $forth = $dbh->get_info($get_info{$_}); ok( defined $forth, qq{DB handle method "get_info" works with a value of "$get_info{$_}"}); is( $back, $forth, qq{DB handle method "get_info" returned matching values}); + if ($_ eq 'SQL_DBMS_VERSION') { + ok((split /\./, $forth)[0] > 0, "Version number detected\n"); + } } #
Fixed in cvs, will be part of 1.43