summaryrefslogtreecommitdiff
path: root/contrib/jsonb_plperl/expected/jsonb_plperlu.out
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2019-08-04 14:05:35 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2019-08-04 14:05:35 -0400
commite8b639357f0a9d9543578ac9331a8b33dcc4f25f (patch)
treeccd513694e544b52f92ebf5b8bcbd8a79a046f94 /contrib/jsonb_plperl/expected/jsonb_plperlu.out
parent45d6789e78dc2997292a528e2538fa496485b85f (diff)
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_plperlu.out')
-rw-r--r--contrib/jsonb_plperl/expected/jsonb_plperlu.out22
1 files changed, 21 insertions, 1 deletions
diff --git a/contrib/jsonb_plperl/expected/jsonb_plperlu.out b/contrib/jsonb_plperl/expected/jsonb_plperlu.out
index 434327bea02..dff316cf984 100644
--- a/contrib/jsonb_plperl/expected/jsonb_plperlu.out
+++ b/contrib/jsonb_plperl/expected/jsonb_plperlu.out
@@ -66,6 +66,26 @@ SELECT testRegexpResultToJsonb();
0
(1 row)
+-- this revealed a different bug
+CREATE FUNCTION testTextToJsonbObject(text) RETURNS jsonb
+LANGUAGE plperlu
+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 plperlu
TRANSFORM FOR TYPE jsonb
@@ -257,4 +277,4 @@ INFO: $VAR1 = {'1' => {'2' => ['3','4','5']},'2' => '3'};
\set VERBOSITY terse \\ -- suppress cascade details
DROP EXTENSION plperlu CASCADE;
-NOTICE: drop cascades to 7 other objects
+NOTICE: drop cascades to 8 other objects