• Tom Lane's avatar
    Fix excessive enreferencing in jsonb-to-plperl transform. · 1731e374
    Tom Lane authored
    We want, say, 2 to be transformed as 2, not \\2 which is what the
    original coding produced.  Perl's standard seems to be to add an RV
    wrapper only for hash and array SVs, so do it like that.
    
    This was missed originally because the test cases only checked what came
    out of a round trip back to SQL, and the strip-all-dereferences loop at
    the top of SV_to_JsonbValue hides the extra refs from view.  As a better
    test, print the Perl value with Data::Dumper, like the hstore_plperlu
    tests do.  While we can't do that in the plperl test, only plperlu,
    that should be good enough because this code is the same for both PLs.
    But also add a simplistic test for extra REFs, which we can do in both.
    
    That strip-all-dereferences behavior is now a bit dubious; it's unlike
    what happens for other Perl-to-SQL conversions.  However, the best
    thing to do seems to be to leave it alone and make the other conversions
    act similarly.  That will be done separately.
    
    Dagfinn Ilmari Mannsåker, adjusted a bit by me
    
    Discussion: https://postgr.es/m/d8jlgbq66t9.fsf@dalvik.ping.uio.no
    1731e374
jsonb_plperl.c 5.97 KB