1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-11 20:28:21 +03:00

Fix jsonb_plperl to convert Perl UV values correctly.

Values greater than IV_MAX were incorrectly converted to SQL,
for instance ~0 would become -1 rather than 18446744073709551615
(on a 64-bit machine).

Dagfinn Ilmari Mannsåker, adjusted a bit by me

Discussion: https://postgr.es/m/d8jtvskjzzs.fsf@dalvik.ping.uio.no
This commit is contained in:
Tom Lane
2018-06-18 17:39:57 -04:00
parent e3b7f7cc50
commit 93b6e03ab4
5 changed files with 72 additions and 3 deletions

View File

@ -34,6 +34,18 @@ $$;
SELECT testSVToJsonb();
CREATE FUNCTION testUVToJsonb() RETURNS jsonb
LANGUAGE plperl
TRANSFORM FOR TYPE jsonb
as $$
$val = ~0;
return $val;
$$;
-- this might produce either 18446744073709551615 or 4294967295
SELECT testUVToJsonb() IN ('18446744073709551615'::jsonb, '4294967295'::jsonb);
-- this revealed a bug in the original implementation
CREATE FUNCTION testRegexpResultToJsonb() RETURNS jsonb
LANGUAGE plperl