Skip Menu |
 

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

Report information
The Basics
Id: 128993
Status: open
Priority: 0/
Queue: DBD-Pg

People
Owner: Nobody in particular
Requestors: ubhofmann [...] googlemail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in:
  • 3.7.0
  • 3.7.1
  • 3.7.3
  • 3.7.4
  • 3.6.0
  • 3.6.1
  • 3.6.2
Fixed in: (no value)



Subject: DBD::Pg 3.7.0 Wrong floating point numbers
Download (untitled) / with headers
text/plain 419b
Output of floating point numbers has changed between DBD::Pg 3.5.3 and 3.7.0. Issues: 1) -0 is returned as +0 2) DBD::Pg lost the ability to return large numbers in scientific notation. Consider a select to a real field containing the number 1.23456789e+12::real. Psql and DBD::Pg 3.5.3 return this number as 1.23457e+12, which is fine. DBD::Pg 3.7.0 returns this number as 1234567950000, which is wrong!
Download (untitled) / with headers
text/plain 670b
How to repeat: 1) Create test data create table float_test ( f real ); -- hack: insert -0 insert into float_test ( f ) values ( 0 ); update float_test set f = -1.0 * f; -- more test data insert into float_test ( f ) values ( 0 ), ( 16777212 ), ( 1.23456789e+12 ), ( 3.14159265358979323 ); 2) Read data using psql Show quoted text
> select * from float_test;
f ------------- -0 0 1.67772e+07 1.23457e+12 3.14159 Show quoted text
> set extra_float_digits=3;
Show quoted text
> select * from float_test;
f ---------------- -0 0 16777212 1.23456795e+12 3.14159274 ===> All values as expected
Download (untitled) / with headers
text/plain 632b
3) Read data in Perl using DBD::Pg 3.5.3 (test program: see attachment) Data with extra_float_digits = <default> -0 0 1.67772e+07 1.23457e+12 3.14159 Data with extra_float_digits = 3 -0 0 16777212 1.23456795e+12 3.14159274 ===> All values as expected 4) Read data in Perl using DBD::Pg 3.7.0 (test program: see attachment) Data with extra_float_digits = <default> 0 <== Wrong, should be -0 0 16777200 <== Wrong 1234570000000 <== Wrong 3.14159 Data with extra_float_digits = 3 0 <== Wrong, should be -0 0 16777212 1234567950000 <== Wrong 3.14159274
Subject: test_floating_point_numbers.pl
#!/usr/bin/perl use 5.20.1; use utf8; use strict; use warnings; use DBI; my $dbh = DBI->connect( "dbi:Pg:dbname=<dbname>;host=127.0.0.1;port=5432", "<username>", "<password>" ); # ------------------------------------------------------- printf( "Data with extra_float_digits = <default>\n" ); my $th = $dbh->prepare( 'SELECT f from float_test' ); my $retval = $th->execute( @_ ); while ( 1 ) { my @row = $th->fetchrow_array(); last if ( $#row < 0 ); printf( "%s\n", $row[0] ); } $th->finish(); # ------------------------------------------------------- printf( "Data with extra_float_digits = 3\n" ); $dbh->do( 'set extra_float_digits=3' ); $th = $dbh->prepare( 'SELECT f from float_test' ); $retval = $th->execute( @_ ); while ( 1 ) { my @row = $th->fetchrow_array(); last if ( $#row < 0 ); printf( "%s\n", $row[0] ); } $th->finish(); # ------------------------------------------------------- $dbh->disconnect(); __END__
Download (untitled) / with headers
text/plain 158b
3.5.3 is the last version without the problem 3.6.0 is the first version with the problem Tested on Linux with PostgreSQL 9.6 and 11, Perl 5.24 and 5.26.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.