pgsql: Fix excessive enreferencing in jsonb-to-plperl transform. - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Fix excessive enreferencing in jsonb-to-plperl transform.
Date
Msg-id E1fUywO-00054m-VP@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Fix excessive enreferencing in jsonb-to-plperl transform.

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/1731e3741cbbf8e0b4481665d7d523bc55117f63

Modified Files
--------------
contrib/jsonb_plperl/expected/jsonb_plperl.out  | 49 +++++++++-------
contrib/jsonb_plperl/expected/jsonb_plperlu.out | 78 ++++++++++++++++++-------
contrib/jsonb_plperl/jsonb_plperl.c             | 10 ++--
contrib/jsonb_plperl/sql/jsonb_plperl.sql       | 42 +++++++------
contrib/jsonb_plperl/sql/jsonb_plperlu.sql      | 45 ++++++++------
5 files changed, 141 insertions(+), 83 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Remove obsolete prohibition on function name matching a columnn
Next
From: Tom Lane
Date:
Subject: pgsql: Avoid platform-dependent output from Data::Dumper.