aboutsummaryrefslogtreecommitdiff
path: root/contrib/jsonb_plperl/expected
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2018-04-30 12:28:45 -0400
committerPeter Eisentraut <peter_e@gmx.net>2018-04-30 13:22:57 -0400
commite348e7ae5727a6da8678036d748e5c5af7deb6c9 (patch)
treead29dc9987af244f9a240f05f9c1c44611ecd96e /contrib/jsonb_plperl/expected
parentf7df8043f08a9d00811fb4aa054ed3221f5f9b5e (diff)
downloadpostgresql-e348e7ae5727a6da8678036d748e5c5af7deb6c9.tar.gz
postgresql-e348e7ae5727a6da8678036d748e5c5af7deb6c9.zip
Prevent infinity and NaN in jsonb/plperl transform
jsonb uses numeric internally, and numeric can store NaN, but that is not allowed by jsonb on input, so we shouldn't store it. Also prevent infinity to get a consistent error message. (numeric input would reject infinity anyway.) Reported-by: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org> Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Diffstat (limited to 'contrib/jsonb_plperl/expected')
-rw-r--r--contrib/jsonb_plperl/expected/jsonb_plperl.out24
-rw-r--r--contrib/jsonb_plperl/expected/jsonb_plperlu.out24
2 files changed, 44 insertions, 4 deletions
diff --git a/contrib/jsonb_plperl/expected/jsonb_plperl.out b/contrib/jsonb_plperl/expected/jsonb_plperl.out
index 99a2e8e135d..d6c3becf631 100644
--- a/contrib/jsonb_plperl/expected/jsonb_plperl.out
+++ b/contrib/jsonb_plperl/expected/jsonb_plperl.out
@@ -39,6 +39,26 @@ SELECT testSVToJsonb();
1
(1 row)
+CREATE FUNCTION testInf() RETURNS jsonb
+LANGUAGE plperl
+TRANSFORM FOR TYPE jsonb
+AS $$
+$val = 0 + 'Inf';
+return $val;
+$$;
+SELECT testInf();
+ERROR: cannot convert infinity to jsonb
+CONTEXT: PL/Perl function "testinf"
+CREATE FUNCTION testNaN() RETURNS jsonb
+LANGUAGE plperl
+TRANSFORM FOR TYPE jsonb
+AS $$
+$val = 0 + 'NaN';
+return $val;
+$$;
+SELECT testNaN();
+ERROR: cannot convert NaN to jsonb
+CONTEXT: PL/Perl function "testnan"
-- this revealed a bug in the original implementation
CREATE FUNCTION testRegexpResultToJsonb() RETURNS jsonb
LANGUAGE plperl
@@ -71,7 +91,7 @@ SELECT roundtrip('1');
(1 row)
SELECT roundtrip('1E+131071');
-ERROR: cannot convert infinite value to jsonb
+ERROR: cannot convert infinity to jsonb
CONTEXT: PL/Perl function "roundtrip"
SELECT roundtrip('-1');
roundtrip
@@ -207,4 +227,4 @@ SELECT roundtrip('{"1": {"2": [3, 4, 5]}, "2": 3}');
\set VERBOSITY terse \\ -- suppress cascade details
DROP EXTENSION plperl CASCADE;
-NOTICE: drop cascades to 6 other objects
+NOTICE: drop cascades to 8 other objects
diff --git a/contrib/jsonb_plperl/expected/jsonb_plperlu.out b/contrib/jsonb_plperl/expected/jsonb_plperlu.out
index 8053cf6aa80..65ed21f3b2d 100644
--- a/contrib/jsonb_plperl/expected/jsonb_plperlu.out
+++ b/contrib/jsonb_plperl/expected/jsonb_plperlu.out
@@ -39,6 +39,26 @@ SELECT testSVToJsonb();
1
(1 row)
+CREATE FUNCTION testInf() RETURNS jsonb
+LANGUAGE plperlu
+TRANSFORM FOR TYPE jsonb
+AS $$
+$val = 0 + 'Inf';
+return $val;
+$$;
+SELECT testInf();
+ERROR: cannot convert infinity to jsonb
+CONTEXT: PL/Perl function "testinf"
+CREATE FUNCTION testNaN() RETURNS jsonb
+LANGUAGE plperlu
+TRANSFORM FOR TYPE jsonb
+AS $$
+$val = 0 + 'NaN';
+return $val;
+$$;
+SELECT testNaN();
+ERROR: cannot convert NaN to jsonb
+CONTEXT: PL/Perl function "testnan"
-- this revealed a bug in the original implementation
CREATE FUNCTION testRegexpResultToJsonb() RETURNS jsonb
LANGUAGE plperlu
@@ -71,7 +91,7 @@ SELECT roundtrip('1');
(1 row)
SELECT roundtrip('1E+131071');
-ERROR: cannot convert infinite value to jsonb
+ERROR: cannot convert infinity to jsonb
CONTEXT: PL/Perl function "roundtrip"
SELECT roundtrip('-1');
roundtrip
@@ -207,4 +227,4 @@ SELECT roundtrip('{"1": {"2": [3, 4, 5]}, "2": 3}');
\set VERBOSITY terse \\ -- suppress cascade details
DROP EXTENSION plperlu CASCADE;
-NOTICE: drop cascades to 6 other objects
+NOTICE: drop cascades to 8 other objects