Re[2]: jsonb_plperl bug - Mailing list pgsql-hackers

From Ivan Panchenko
Subject Re[2]: jsonb_plperl bug
Date
Msg-id 1564815812.697452305@f521.i.mail.ru
Whole thread Raw
In response to Re: jsonb_plperl bug  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Re[2]: jsonb_plperl bug  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers


 Tom Lane <tgl@sss.pgh.pa.us>:

Ivan Panchenko <wao@mail.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

pgsql-hackers by date:

Previous
From: Konstantin Knizhnik
Date:
Subject: Re: pglz performance
Next
From: Fabien COELHO
Date:
Subject: Re: pgbench - implement strict TPC-B benchmark