Re: Transform for pl/perl
Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
From: ilmari@ilmari.org (Dagfinn Ilmari Mannsåker )
To: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Cc: Alvaro Herrera <alvherre@2ndquadrant.com>, Tom Lane <tgl@sss.pgh.pa.us>,
Pavel Stehule <pavel.stehule@gmail.com>,
Nikita Glukhov <n.gluhov@postgrespro.ru>,
PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2018-06-07T13:54:10Z
Lists: pgsql-hackers
Attachments
Peter Eisentraut <peter.eisentraut@2ndquadrant.com> writes: > On 6/6/18 12:14, Alvaro Herrera wrote: >> On 2018-May-17, Peter Eisentraut wrote: >> >>> The items that are still open from the original email are: >>> >>> 2) jsonb scalar values are passed to the plperl function wrapped in not >>> one, but _two_ layers of references >>> >>> 3) jsonb numeric values are passed as perl's NV (floating point) type, >>> losing precision if they're integers that would fit in an IV or UV. >>> >>> #2 appears to be a quality of implementation issue without any >>> user-visible effects. >>> >>> #3 is an opportunity for future improvement, but works as intended right >>> now. >>> >>> I think patches for these issues could still be considered during beta, >>> but they are not release blockers IMO. >> >> It appears to me that item #2 definitely would need to be fixed before >> release, so that it doesn't become a backwards-incompatibility later on. > > The way I understand it, it's only how things are passed around > internally. Nothing is noticeable externally, and so there is no > backward compatibility issue. > > At least that's how I understand it. So far this is only a claim by one > person. I haven't seen anything conclusive about whether there is an > actual issue. It's not just how things are passed internally, but how they are passed to pl/perl functions with a jsonb transform: JSON scalar values at the top level (strings, numbers, booleans, null) get passed as a reference to a reference to the value, e.g. \\42 instead of 42. The reason the current tests don't pick this up is that they don't check the value inside the pl/perl functions, only that they roundtrip back to jsonb, and the plperl to jsonb transform recursively dereferences references. Another side effect of the recursive dereferencing is that returning undef from the perl function returns an SQL NULL while returning a reference to undef (\undef) returns a jsonb null. The attached patch fixes the excess enreferencing, but does not touch the dereferencing part. - ilmari -- "I use RMS as a guide in the same way that a boat captain would use a lighthouse. It's good to know where it is, but you generally don't want to find yourself in the same spot." - Tollef Fog Heen
Commits
-
Fix jsonb_plperl to convert Perl UV values correctly.
- 93b6e03ab479 11.0 landed
-
Fix contrib/hstore_plperl to look through scalar refs.
- e3b7f7cc5063 11.0 landed
- 7594b7a53366 10.5 landed
- 645929c545ef 9.5.14 landed
- 1bebfb9b6365 9.6.10 landed
-
Allow plperl_sv_to_datum to look through scalar refs.
- 3a382983d142 11.0 landed
-
Fix excessive enreferencing in jsonb-to-plperl transform.
- 1731e3741cbb 11.0 landed