aboutsummaryrefslogtreecommitdiff
path: root/contrib/jsonb_plperl/sql/jsonb_plperl.sql
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2018-06-18 17:39:57 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2018-06-18 17:39:57 -0400
commit93b6e03ab4794272986a11a427c6c391eafa5dea (patch)
treed47064e64f9edbe30fdaacee3ba56c81d6b74147 /contrib/jsonb_plperl/sql/jsonb_plperl.sql
parente3b7f7cc50630dac958a48b533cce04e4222892b (diff)
downloadpostgresql-93b6e03ab4794272986a11a427c6c391eafa5dea.tar.gz
postgresql-93b6e03ab4794272986a11a427c6c391eafa5dea.zip
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
Diffstat (limited to 'contrib/jsonb_plperl/sql/jsonb_plperl.sql')
-rw-r--r--contrib/jsonb_plperl/sql/jsonb_plperl.sql12
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