From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix excessive enreferencing in jsonb-to-plperl transform.
Date: Mon, 18 Jun 2018 18:31:48 +0000
Message-ID: <E1fUywO-00054m-VP@gemulon.postgresql.org> (raw)
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(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: tgl@sss.pgh.pa.us
Subject: Re: pgsql: Fix excessive enreferencing in jsonb-to-plperl transform.
In-Reply-To: <E1fUywO-00054m-VP@gemulon.postgresql.org>
References: <E1fUywO-00054m-VP@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox