Re: Residual cleanups for tied objects in PL/Perl

From: Andrey Rachitskiy <pl0h0yp1(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: andrew(at)dunslane(dot)net, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Residual cleanups for tied objects in PL/Perl
Date: 2026-08-16 22:24:09
Message-ID: CAB8bMisM-qSPw2qVnyjTp862LVAKpfX33_y-H1MBGzjAfwAQcg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

пн, 17 авг. 2026 г. в 02:40, Andrey Rachitskiy <pl0h0yp1(at)gmail(dot)com>:

> If we want a tied hash or array to convert like an ordinary one, GETMAGIC
> is still needed before SvOK() / SvROK() in plperl_sv_to_datum() and
> jsonb_plperl's SV_to_JsonbValue(). plperl_build_tuple_result() still
> uses HeVAL() and will crash on a tied hash the same way hstore_plperl
> did. That loop also calls hek2cstr(), which uses FREETMPS, so
> hek2cstr() has to run before hv_iterval().
>
>
The first patch tries to close every Perl-to-SQL path that still
ignored FETCH on tied values.

The trigger path does not return a hash. After "MODIFY",
plperl_modify_tuple() walks $_TD->{new}. That hash is normally filled
by PL/Perl from the tuple, so it is not tied. The loop is still fixed,
so the HeVAL() bug is not left behind if a trigger replaces that hash
with a tied one.

The second patch is regress only. Separate files cover the cases the
code patch touches: SETOF text, scalar text, composite, integer[], a
BEFORE INSERT trigger that swaps in a tied $_TD->{new}, hstore, and
jsonb. The classes are small inline TIEHASH / TIEARRAY / TIESCALAR
helpers, not Tie::Hash or Tie::Array.

--
Regards,
Rachitskiy Andrey

Attachment Content-Type Size
0001-Honor-Perl-FETCH-for-tied-hashes-and-arrays.patch text/x-patch 3.7 KB
0002-Add-regress-tests-for-tied-Perl-hashes-and-arrays.patch text/x-patch 12.5 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bharath Rupireddy 2026-08-16 23:38:09 Re: Add a pg_wal_preallocate() SQL function to eagerly create future WAL segments
Previous Message Andrey Rachitskiy 2026-08-16 21:40:28 Re: Residual cleanups for tied objects in PL/Perl