diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2019-08-04 14:05:35 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2019-08-04 14:05:35 -0400 |
commit | df521ab79547b82471126e54e9dc7fead4a5a4fb (patch) | |
tree | 4bb232ee28872dcec9d3f1a2728046b6c0d65092 /contrib/jsonb_plperl/expected/jsonb_plperl.out | |
parent | 4844c6303296d4fa2c9cc800685e4f404dfa5396 (diff) | |
download | postgresql-df521ab79547b82471126e54e9dc7fead4a5a4fb.tar.gz postgresql-df521ab79547b82471126e54e9dc7fead4a5a4fb.zip |
Fix handling of "undef" in contrib/jsonb_plperl.
Perl has multiple internal representations of "undef", and just
testing for SvTYPE(x) == SVt_NULL doesn't recognize all of them,
leading to "cannot transform this Perl type to jsonb" errors.
Use the approved test SvOK() instead.
Report and patch by Ivan Panchenko. Back-patch to v11 where
this module was added.
Discussion: https://postgr.es/m/1564783533.324795401@f193.i.mail.ru
Diffstat (limited to 'contrib/jsonb_plperl/expected/jsonb_plperl.out')
-rw-r--r-- | contrib/jsonb_plperl/expected/jsonb_plperl.out | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/contrib/jsonb_plperl/expected/jsonb_plperl.out b/contrib/jsonb_plperl/expected/jsonb_plperl.out index 6dc090a87f7..5a73485ac06 100644 --- a/contrib/jsonb_plperl/expected/jsonb_plperl.out +++ b/contrib/jsonb_plperl/expected/jsonb_plperl.out @@ -66,6 +66,26 @@ SELECT testRegexpResultToJsonb(); 0 (1 row) +-- this revealed a different bug +CREATE FUNCTION testTextToJsonbObject(text) RETURNS jsonb +LANGUAGE plperl +TRANSFORM FOR TYPE jsonb +AS $$ +my $x = shift; +return {a => $x}; +$$; +SELECT testTextToJsonbObject('abc'); + testtexttojsonbobject +----------------------- + {"a": "abc"} +(1 row) + +SELECT testTextToJsonbObject(NULL); + testtexttojsonbobject +----------------------- + {"a": null} +(1 row) + CREATE FUNCTION roundtrip(val jsonb, ref text = '') RETURNS jsonb LANGUAGE plperl TRANSFORM FOR TYPE jsonb @@ -230,4 +250,4 @@ SELECT roundtrip('{"1": {"2": [3, 4, 5]}, "2": 3}', 'HASH'); \set VERBOSITY terse \\ -- suppress cascade details DROP EXTENSION plperl CASCADE; -NOTICE: drop cascades to 7 other objects +NOTICE: drop cascades to 8 other objects |