Re[2]: jsonb_plperl bug

From: Ivan Panchenko <wao(at)mail(dot)ru>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re[2]: jsonb_plperl bug
Date: 2019-08-03 07:03:32
Message-ID: 1564815812.697452305@f521.i.mail.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
>
>=?UTF-8?B?SXZhbiBQYW5jaGVua28=?= < wao(at)mail(dot)ru > writes:
>> I have found a bug in jsonb_plperl extension. A possible fix is proposed below.
>> ...
>> + /* SVt_PV without POK flag is also NULL */
>> + if(SvTYPE(in) == SVt_PV)
>
>Ugh. Doesn't Perl provide some saner way to determine the type of a SV?
>
>The core code seems to think that SvOK() is a sufficient test for an
>undef. Should we be doing that before the switch, perhaps?
Thank you, Tom. Yes, there is a solution with SvOK(), please see the attached patch.

SvOK() check before the switch seems too early, because in such case we would  loose hashes and arrays which are not SvOK. So I put it inside the switch. May be, it's better to remove the switch at all, and rewrite the code with ifs?

>
>(My underlying concern here is mostly about whether we have other
>similar bugs. There are a lot of places checking SvTYPE.)
I looked through plperl.c, but found no similar cases of checking SvTYPE.

>regards, tom lane
Regards, Ivan

>

Attachment Content-Type Size
jsonb_plperl_null_bug.patch application/x-patch 3.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Fabien COELHO 2019-08-03 09:30:30 Re: pgbench - implement strict TPC-B benchmark
Previous Message Konstantin Knizhnik 2019-08-03 05:37:55 Re: pglz performance