Make plperl's handling of Perl hashes more consistent. Make hek2cstr() available in plperl.h, so that it can be used in hstore_plperl and jsonb_plperl. Those modules were previously using different coding techniques that probably don't get conversion from Perl strings to the database encoding quite right. (I'd prefer to make hek2cstr() non-inline, but cross-extension calls are messy and plperl has avoided them up to now, so stick with the existing approach.)
Consistently use hv_iternext, hek2cstr, and HeVAL for hash iterations, with one exception in plperl_trusted_init: there, hv_iternextsv is fine since we don't actually care about the hash keys. (A later patch will remove the HeVAL calls again, but for now we just want consistency.) Remove unnecessary extra calls of hv_iterinit. Remove duplicative pstrdup's in plperl_to_hstore. The meat of this change is to use hek2cstr() in the contrib modules, which makes a user-visible change in encoding conversion behavior. While it's certainly a bug fix, we've had no field complaints about those modules, so I'm hesitant to make this change in the back branches. Hence, apply to master only. Author: Tom Lane <[email protected]> Reviewed-by: Andrey Rachitskiy <[email protected]> Discussion: https://postgr.es/m/[email protected] Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/5bf8fee543a19ca9ffa5aa99046adae34ba6a864 Modified Files -------------- contrib/hstore_plperl/hstore_plperl.c | 6 ++-- contrib/jsonb_plperl/jsonb_plperl.c | 13 ++++---- src/pl/plperl/plperl.c | 59 +---------------------------------- src/pl/plperl/plperl.h | 55 ++++++++++++++++++++++++++++++++ 4 files changed, 66 insertions(+), 67 deletions(-)
