Re: pgsql: Prevent infinity and NaN in jsonb/plperl transform

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Dunstan <andrew(dot)dunstan(at)2ndquadrant(dot)com>
Cc: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: Re: pgsql: Prevent infinity and NaN in jsonb/plperl transform
Date: 2018-04-30 23:37:18
Message-ID: 28585.1525131438@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Andrew Dunstan <andrew(dot)dunstan(at)2ndquadrant(dot)com> writes:
> Fingers crossed we'll be OK. Looking at the perl headers on a Windows
> machine I'm doing some other stuff on, the #define is protected by an
> #ifndef. I'm always happy when my hacks can be removed :-)

Well, the early returns on that are promising, but we have another
problem: prairiedog, jacana, and probably other old BF members are
failing the new regression test cases. It appears that what the test
script assumes will produce a NaN or Inf float doesn't work in 5.8.x
perl:

$ perl -e "print 0 + 'NaN'"
0
$ perl -e "print 0 + 'Inf'"
0

I googled a bit and found these recommendations on stackoverflow:

my $inf = 9**9**9;
my $neginf = -9**9**9;
my $nan = -sin(9**9**9);

These do seem to produce the desired results, at least on the
couple of Perl versions I checked, including 5.8.3.

regards, tom lane

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2018-05-01 00:09:37 pgsql: Does it help to wait before reattaching?
Previous Message Tom Lane 2018-04-30 21:07:19 pgsql: Map and unmap the shared memory block before risking VirtualFree