Commit 827eb439 authored by Tom Lane's avatar Tom Lane

Tweak new jsonb_plperl test cases to work with old Perl versions.

The previous coding here didn't actually produce Inf or NaN double
values in Perl versions 5.8.x.  Adopt a suggestion from stackoverflow.

Discussion: https://postgr.es/m/28585.1525131438@sss.pgh.pa.us
parent 23078689
...@@ -43,7 +43,7 @@ CREATE FUNCTION testInf() RETURNS jsonb ...@@ -43,7 +43,7 @@ CREATE FUNCTION testInf() RETURNS jsonb
LANGUAGE plperl LANGUAGE plperl
TRANSFORM FOR TYPE jsonb TRANSFORM FOR TYPE jsonb
AS $$ AS $$
$val = 0 + 'Inf'; $val = 9**9**9; # we assume this will overflow to +Inf
return $val; return $val;
$$; $$;
SELECT testInf(); SELECT testInf();
...@@ -53,7 +53,7 @@ CREATE FUNCTION testNaN() RETURNS jsonb ...@@ -53,7 +53,7 @@ CREATE FUNCTION testNaN() RETURNS jsonb
LANGUAGE plperl LANGUAGE plperl
TRANSFORM FOR TYPE jsonb TRANSFORM FOR TYPE jsonb
AS $$ AS $$
$val = 0 + 'NaN'; $val = sin(9**9**9); # we assume sin(inf) will yield NaN
return $val; return $val;
$$; $$;
SELECT testNaN(); SELECT testNaN();
......
...@@ -43,7 +43,7 @@ CREATE FUNCTION testInf() RETURNS jsonb ...@@ -43,7 +43,7 @@ CREATE FUNCTION testInf() RETURNS jsonb
LANGUAGE plperlu LANGUAGE plperlu
TRANSFORM FOR TYPE jsonb TRANSFORM FOR TYPE jsonb
AS $$ AS $$
$val = 0 + 'Inf'; $val = 9**9**9; # we assume this will overflow to +Inf
return $val; return $val;
$$; $$;
SELECT testInf(); SELECT testInf();
...@@ -53,7 +53,7 @@ CREATE FUNCTION testNaN() RETURNS jsonb ...@@ -53,7 +53,7 @@ CREATE FUNCTION testNaN() RETURNS jsonb
LANGUAGE plperlu LANGUAGE plperlu
TRANSFORM FOR TYPE jsonb TRANSFORM FOR TYPE jsonb
AS $$ AS $$
$val = 0 + 'NaN'; $val = sin(9**9**9); # we assume sin(inf) will yield NaN
return $val; return $val;
$$; $$;
SELECT testNaN(); SELECT testNaN();
......
...@@ -38,7 +38,7 @@ CREATE FUNCTION testInf() RETURNS jsonb ...@@ -38,7 +38,7 @@ CREATE FUNCTION testInf() RETURNS jsonb
LANGUAGE plperl LANGUAGE plperl
TRANSFORM FOR TYPE jsonb TRANSFORM FOR TYPE jsonb
AS $$ AS $$
$val = 0 + 'Inf'; $val = 9**9**9; # we assume this will overflow to +Inf
return $val; return $val;
$$; $$;
...@@ -49,7 +49,7 @@ CREATE FUNCTION testNaN() RETURNS jsonb ...@@ -49,7 +49,7 @@ CREATE FUNCTION testNaN() RETURNS jsonb
LANGUAGE plperl LANGUAGE plperl
TRANSFORM FOR TYPE jsonb TRANSFORM FOR TYPE jsonb
AS $$ AS $$
$val = 0 + 'NaN'; $val = sin(9**9**9); # we assume sin(inf) will yield NaN
return $val; return $val;
$$; $$;
......
...@@ -38,7 +38,7 @@ CREATE FUNCTION testInf() RETURNS jsonb ...@@ -38,7 +38,7 @@ CREATE FUNCTION testInf() RETURNS jsonb
LANGUAGE plperlu LANGUAGE plperlu
TRANSFORM FOR TYPE jsonb TRANSFORM FOR TYPE jsonb
AS $$ AS $$
$val = 0 + 'Inf'; $val = 9**9**9; # we assume this will overflow to +Inf
return $val; return $val;
$$; $$;
...@@ -49,7 +49,7 @@ CREATE FUNCTION testNaN() RETURNS jsonb ...@@ -49,7 +49,7 @@ CREATE FUNCTION testNaN() RETURNS jsonb
LANGUAGE plperlu LANGUAGE plperlu
TRANSFORM FOR TYPE jsonb TRANSFORM FOR TYPE jsonb
AS $$ AS $$
$val = 0 + 'NaN'; $val = sin(9**9**9); # we assume sin(inf) will yield NaN
return $val; return $val;
$$; $$;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment