diff options
author | Tom Lane | 2018-06-18 21:39:57 +0000 |
---|---|---|
committer | Tom Lane | 2018-06-18 21:39:57 +0000 |
commit | 93b6e03ab4794272986a11a427c6c391eafa5dea (patch) | |
tree | d47064e64f9edbe30fdaacee3ba56c81d6b74147 /contrib/jsonb_plperl/sql/jsonb_plperl.sql | |
parent | e3b7f7cc50630dac958a48b533cce04e4222892b (diff) |
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/[email protected]
Diffstat (limited to 'contrib/jsonb_plperl/sql/jsonb_plperl.sql')
-rw-r--r-- | contrib/jsonb_plperl/sql/jsonb_plperl.sql | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/contrib/jsonb_plperl/sql/jsonb_plperl.sql b/contrib/jsonb_plperl/sql/jsonb_plperl.sql index 642a71deb76..8b062dfc6bb 100644 --- a/contrib/jsonb_plperl/sql/jsonb_plperl.sql +++ b/contrib/jsonb_plperl/sql/jsonb_plperl.sql @@ -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 |