Re: pgsql: Transforms for jsonb to PL/Perl - Mailing list pgsql-committers

From Anthony Bykov
Subject Re: pgsql: Transforms for jsonb to PL/Perl
Date
Msg-id 20180404111051.28c7912d@anthony-24-g082ur
Whole thread Raw
In response to Re: pgsql: Transforms for jsonb to PL/Perl  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-committers
On Tue, 03 Apr 2018 17:37:04 -0400
Tom Lane <tgl@sss.pgh.pa.us> wrote:

> I wrote:
> > Hm, it fails on my own machine too (RHEL6, perl 5.10.1), with the
> > same "cannot transform this Perl type to jsonb" symptoms.  A bit
> > of tracing shows that SvTYPE(in) is returning SVt_PVIV in some
> > of the failing cases, and SVt_PVNV in others.  
> 
> I tried to fix this by reducing the amount of knowledge that function
> embeds about the possible SvTYPEs.  After the special cases for AV,
> HV, and NULL, the attached just tests SvIOK, SvNOK, and SvPOK, and
> does the right thing for each case.
> 
> This results in one change in the module's test results: the example
> that thinks it's returning a regexp match result no longer fails,
> but just returns the scalar result (0).  I'm inclined to think that
> this is correct/desirable and the existing behavior is an accidental
> artifact of not coping with Perl's various augmented representations
> of scalar values.
> 
> Thoughts?
> 
>             regards, tom lane
> 

Hello,
I don't think that user expect having 0 in jsonb when they have regexp:
it should have a possibility to convert resulting jsonb back to perl
with exact same type and data.


--
Anthony Bykov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company


pgsql-committers by date:

Previous
From: Alvaro Herrera
Date:
Subject: pgsql: Don't clone internal triggers to partitions
Next
From: Heikki Linnakangas
Date:
Subject: pgsql: Fix incorrect description of USE_SLICING_BY_8_CRC32C.