Add TG_* vars for FOR PORTION OF

From: Paul A Jungwirth <pj(at)illuminatedcomputing(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Cc: Peter Eisentraut <peter(at)eisentraut(dot)org>
Subject: Add TG_* vars for FOR PORTION OF
Date: 2026-08-31 21:28:08
Message-ID: CA+renyU3XXv+7cB7xrbG4BM5p4o2X8yao5gw2vNvm3UeZ0HKQg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Dear Hackers,

Here are patches adding new TG_* vars to PL/pgSQL, PL/Python, PL/Perl,
and PL/Tcl, holding FOR PORTION OF details. These let triggers respond
appropriately when FOR PORTION OF is used in the original query. That
is useful for replication, auditing, and general functionality. We
ourselves need this information for temporal foreign key actions (but
in C, not in a PL)[0]. This also came up a few times in the v19 beta
feedback to FOR PORTION OF. In particular, it would help to include
FOR PORTION OF information even for INSERT triggers fired because of
the temporal leftovers.

Patch 1 is the same as patch 2 from [0], but I'm repeating it here so
that the main patches compile.

The PL/pgSQL patch is fairly mature: I've been including it in
valid-time submissions for at least a few years now. The other PL/*
patches are new. They don't have to all be committed together, but I
think we should make the behavior as consistent as possible across
languages, so one commitfest entry seems best.

For Tcl, it's hard for me to judge if I'm presenting the information
in an idiomatic way. Any feedback would be appreciated!

[0] https://www.postgresql.org/message-id/CA%2BrenyUts-ksRKL3V%2B9kTnRCAJdb8Xc3T1L%2ByCVscNZQKT4Yvw%40mail.gmail.com

Yours,

--
Paul ~{:-)
pj(at)illuminatedcomputing(dot)com

Attachment Content-Type Size
v1-0005-Expose-FOR-PORTION-OF-to-pltcl-triggers.patch text/x-patch 14.6 KB
v1-0004-Expose-FOR-PORTION-OF-to-plpython-triggers.patch text/x-patch 9.3 KB
v1-0003-Expose-FOR-PORTION-OF-to-plperl-triggers.patch text/x-patch 8.4 KB
v1-0002-Expose-FOR-PORTION-OF-to-plpgsql-triggers.patch text/x-patch 26.8 KB
v1-0001-Add-tg_temporal-to-TriggerData.patch text/x-patch 15.5 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Bharath Rupireddy 2026-08-31 21:29:25 Re: REPACK (CONCURRENTLY) fails with wrong error for materialized views
Previous Message Jeff Davis 2026-08-31 20:59:23 Re: Commit Sequence Numbers and Visibility