From 71d60e2aa05157efec28393b15c0b0b9fc1b210c Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Mon, 9 Mar 2020 09:22:22 +0100 Subject: Add tg_updatedcols to TriggerData This allows a trigger function to determine for an UPDATE trigger which columns were actually updated. This allows some optimizations in generic trigger functions such as lo_manage and tsvector_update_trigger. Reviewed-by: Daniel Gustafsson Discussion: https://www.postgresql.org/message-id/flat/11c5f156-67a9-0fb5-8200-2a8018eb2e0c@2ndquadrant.com --- doc/src/sgml/trigger.sgml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'doc/src') diff --git a/doc/src/sgml/trigger.sgml b/doc/src/sgml/trigger.sgml index 6f323a903b5..7d9ad4763aa 100644 --- a/doc/src/sgml/trigger.sgml +++ b/doc/src/sgml/trigger.sgml @@ -517,6 +517,7 @@ typedef struct TriggerData TupleTableSlot *tg_newslot; Tuplestorestate *tg_oldtable; Tuplestorestate *tg_newtable; + const Bitmapset *tg_updatedcols; } TriggerData; @@ -759,6 +760,30 @@ typedef struct Trigger + + tg_updatedcols + + + For UPDATE triggers, a bitmap set indicating the + columns that were updated by the triggering command. Generic trigger + functions can use this to optimize actions by not having to deal with + columns that were not changed. + + + + As an example, to determine whether a column with attribute number + attnum (1-based) is a member of this bitmap set, + call bms_is_member(attnum - + FirstLowInvalidHeapAttributeNumber, + trigdata->tg_updatedcols)). + + + + For triggers other than UPDATE triggers, this will + be NULL. + + + -- cgit v1.2.3