mirror of
https://github.com/postgres/postgres.git
synced 2025-06-11 20:28:21 +03:00
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>
This commit is contained in:
@ -34,6 +34,28 @@ $$;
|
||||
SELECT testSVToJsonb();
|
||||
|
||||
|
||||
CREATE FUNCTION testInf() RETURNS jsonb
|
||||
LANGUAGE plperl
|
||||
TRANSFORM FOR TYPE jsonb
|
||||
AS $$
|
||||
$val = 0 + 'Inf';
|
||||
return $val;
|
||||
$$;
|
||||
|
||||
SELECT testInf();
|
||||
|
||||
|
||||
CREATE FUNCTION testNaN() RETURNS jsonb
|
||||
LANGUAGE plperl
|
||||
TRANSFORM FOR TYPE jsonb
|
||||
AS $$
|
||||
$val = 0 + 'NaN';
|
||||
return $val;
|
||||
$$;
|
||||
|
||||
SELECT testNaN();
|
||||
|
||||
|
||||
-- this revealed a bug in the original implementation
|
||||
CREATE FUNCTION testRegexpResultToJsonb() RETURNS jsonb
|
||||
LANGUAGE plperl
|
||||
|
Reference in New Issue
Block a user