aboutsummaryrefslogtreecommitdiff
path: root/contrib/jsonb_plperl/jsonb_plperl.c
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/jsonb_plperl.c
parent45d6789e78dc2997292a528e2538fa496485b85f (diff)
downloadpostgresql-e8b639357f0a9d9543578ac9331a8b33dcc4f25f.tar.gz
postgresql-e8b639357f0a9d9543578ac9331a8b33dcc4f25f.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/jsonb_plperl.c')
-rw-r--r--contrib/jsonb_plperl/jsonb_plperl.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/contrib/jsonb_plperl/jsonb_plperl.c b/contrib/jsonb_plperl/jsonb_plperl.c
index e847ae53699..b16c824c794 100644
--- a/contrib/jsonb_plperl/jsonb_plperl.c
+++ b/contrib/jsonb_plperl/jsonb_plperl.c
@@ -193,12 +193,12 @@ SV_to_JsonbValue(SV *in, JsonbParseState **jsonb_state, bool is_elem)
case SVt_PVHV:
return HV_to_JsonbValue((HV *) in, jsonb_state);
- case SVt_NULL:
- out.type = jbvNull;
- break;
-
default:
- if (SvUOK(in))
+ if (!SvOK(in))
+ {
+ out.type = jbvNull;
+ }
+ else if (SvUOK(in))
{
/*
* If UV is >=64 bits, we have no better way to make this