pgsql: Clean up code to resolve the "root target relation" in nodeModif

From: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Clean up code to resolve the "root target relation" in nodeModif
Date: 2020-10-19 11:43:59
Message-ID: E1kUTa3-0000Oo-8r@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Clean up code to resolve the "root target relation" in nodeModifyTable.c

When executing DDL on a partitioned table or on a table with inheritance
children, statement-level triggers must be fired against the table given
in the original statement. The code to look that up was a bit messy and
duplicative. Commit 501ed02cf6 added a helper function,
getASTriggerResultRelInfo() (later renamed to getTargetResultRelInfo())
for it, but for some reason it was only used when firing AFTER STATEMENT
triggers and the code to fire BEFORE STATEMENT triggers duplicated the
logic.

Determine the target relation in ExecInitModifyTable(), and set it always
in ModifyTableState. Code that used to call getTargetResultRelInfo() can
now use ModifyTableState->rootResultRelInfo directly.

Discussion: https://www.postgresql.org/message-id/CA%2BHiwqFViT47Zbr_ASBejiK7iDG8%3DQ1swQ-tjM6caRPQ67pT%3Dw%40mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/f49b85d783f6781138f33bbe5f6e98da86907d84

Modified Files
--------------
src/backend/executor/nodeModifyTable.c | 62 +++++++++++++---------------------
src/include/nodes/execnodes.h | 9 +++--
2 files changed, 31 insertions(+), 40 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Magnus Hagander 2020-10-19 11:49:25 pgsql: Update link for pllua
Previous Message Magnus Hagander 2020-10-19 11:40:42 Re: pgsql: Change the docs for PARALLEL option of Vacuum.