pgsql: Remove rewriteTargetListIU's expansion of view targetlists in UP

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Remove rewriteTargetListIU's expansion of view targetlists in UP
Date: 2021-04-26 17:58:41
Message-ID: E1lb5VJ-0006rO-9q@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Remove rewriteTargetListIU's expansion of view targetlists in UPDATE.

Commit 2ec993a7c, which added triggers on views, modified the rewriter
to add dummy entries like "SET x = x" for all columns that weren't
actually being updated by the user in any UPDATE directed at a view.
That was needed at the time to produce a complete "NEW" row to pass
to the trigger. Later it was found to cause problems for ordinary
updatable views, so commit cab5dc5da restricted it to happen only for
trigger-updatable views. But in the wake of commit 86dc90056, we
really don't need it at all. nodeModifyTable.c populates the trigger
"OLD" row from the whole-row variable that is generated for the view,
and then it computes the "NEW" row using that old row and the UPDATE
targetlist. So there is no need for the UPDATE tlist to have dummy
entries, any more than it needs them for regular tables or other
types of views.

(The comments for rewriteTargetListIU suggest that we must do this
for correct expansion of NEW references in rules, but I now think
that that was just lazy comment editing in 2ec993a7c. If we didn't
need it for rules on views before there were triggers, we don't need
it after that.)

This essentially propagates 86dc90056's decision that we don't need
dummy column updates into the view case. Aside from making the
different cases more uniform and hence possibly forestalling future
bugs, it ought to save a little bit of rewriter/planner effort.

Discussion: https://postgr.es/m/2181213.1619397634@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/04942bffd0aa9bd0d143d99b473342eb9ecee88b

Modified Files
--------------
src/backend/rewrite/rewriteHandler.c | 42 ++++--------------------------------
1 file changed, 4 insertions(+), 38 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Alvaro Herrera 2021-04-26 20:22:20 pgsql: psql: tab-complete ALTER ... DETACH CONCURRENTLY / FINALIZE
Previous Message Tom Lane 2021-04-26 15:50:59 pgsql: Doc: document EXTRACT(JULIAN ...), improve Julian Date explanati