bucardo / dbdpg

Perl Postgres driver DBD::Pg aka dbdpg
48 stars 35 forks source link

DBD::Pg 3.9.x fails tests on 32-bit PowerPC #56

Closed awilfox closed 5 years ago

awilfox commented 5 years ago

The first bad commit is 5298facba2439139f70e1d7ac39116a669b701ce:

t/04misc.t ............. 1/101 DBD::Pg::st execute failed: ERROR:  invalid input syntax for integer: "-9.22337203685478e+18" at t/04misc.t line 80.
Issuing rollback() due to DESTROY without explicit disconnect() of DBD::Pg::db handle dbname=postgres;port=5440;host=/usr/src/packages/user/perl-dbd-pg/src/DBD-Pg-3.9.1/dbdpg_test_database/data/socket at t/04misc.t line 80.
# Looks like your test exited with 255 just after 14.
t/04misc.t ............. Dubious, test returned 255 (wstat 65280, 0xff00)

After 112ddc37994c09e8b7cf9496c6ff8b05b6a9bba5, the error changes to:

t/04misc.t ............. 1/101 
#   Failed test 'Constant PG_MIN_BIGINT returns correct value'
#   at t/04misc.t line 81.
#          got: '-9223372036854775808'
#     expected: '-9.22337203685478e+18'
DBD::Pg::st execute failed: ERROR:  invalid input syntax for integer: "-9.22337203685478e+18" at t/04misc.t line 87.
Issuing rollback() due to DESTROY without explicit disconnect() of DBD::Pg::db handle dbname=postgres;port=5440;host=/usr/src/packages/user/perl-dbd-pg/src/DBD-Pg-3.9.1/dbdpg_test_database/data/socket at t/04misc.t line 87.
# Looks like your test exited with 255 just after 16.
t/04misc.t ............. Dubious, test returned 255 (wstat 65280, 0xff00)

Changing it to use bignums, the error changes to test failures:

t/04misc.t ............. 1/101 
#   Failed test 'Constant PG_MIN_BIGINT returns correct value'
#   at t/04misc.t line 81.
#          got: '-9223372036854775808'
#     expected: '-9.22337203685478e+18'

#   Failed test 'Constant PG_MIN_BIGINT returns correct value'
#   at t/04misc.t line 88.
#          got: '-9223372036854775807'
#     expected: '-9.22337203685478e+18'

#   Failed test 'Constant PG_MAX_BIGINT returns correct value'
#   at t/04misc.t line 92.
#          got: '9223372036854775807'
#     expected: '9.22337203685478e+18'

#   Failed test 'Constant PG_MAX_BIGINT returns correct value'
#   at t/04misc.t line 99.
#          got: '9223372036854775806'
#     expected: '9.22337203685478e+18'
t/04misc.t ............. 99/101 # Looks like you failed 4 tests of 101.
t/04misc.t ............. Dubious, test returned 4 (wstat 1024, 0x400)
pali commented 5 years ago

Try following patch:

diff --git a/t/04misc.t b/t/04misc.t
index 929ba0c..314778e 100644
--- a/t/04misc.t
+++ b/t/04misc.t
@@ -78,25 +78,25 @@ is ( $sth->fetch->[0], 2147483646, $t);
 $t = 'Constant PG_MIN_BIGINT returns correct value';
 $sth = $dbh->prepare('SELECT ?::bigint');
 $sth->execute(PG_MIN_BIGINT);
-is ( $sth->fetch->[0], -9223372036854775808, $t);
+is ( $sth->fetch->[0], '-9223372036854775808', $t);

 eval { $sth->execute(PG_MIN_BIGINT-1) };
 $dbh->rollback();
 like ($@, qr/ERROR/, $t);

 $sth->execute(PG_MIN_BIGINT+1);
-is ( $sth->fetch->[0], -9223372036854775807, $t);
+is ( $sth->fetch->[0], '-9223372036854775807', $t);

 $t = 'Constant PG_MAX_BIGINT returns correct value';
 $sth->execute(PG_MAX_BIGINT);
-is ( $sth->fetch->[0], 9223372036854775807, $t);
+is ( $sth->fetch->[0], '9223372036854775807', $t);

 eval { $sth->execute(PG_MAX_BIGINT+1) };
 $dbh->rollback();
 like ($@, qr/ERROR/, $t);

 $sth->execute(PG_MAX_BIGINT-1);
-is ( $sth->fetch->[0], 9223372036854775806, $t);
+is ( $sth->fetch->[0], '9223372036854775806', $t);

 $t = 'Constant PG_MIN_SMALLSERIAL returns correct value';
 is (PG_MIN_SMALLSERIAL, 1, $t);
turnstep commented 5 years ago

Applied in 17f545267297341434caad56c47bf952f62ed2e0