Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf8135d8

Browse files
committed
Expand comments and add an assertion in nodeModifyTable.c.
Most comments concern RELKIND_VIEW. One addresses the ExecUpdate()"tupleid" parameter. A later commit will rely on these facts, but theyhold already. Back-patch to v12 (all supported versions), the plan forthat commit.Reviewed (in an earlier version) by Robert Haas.Discussion:https://postgr.es/m/20240512232923.aa.nmisch@google.com
1 parentdd8008e commitf8135d8

File tree

1 file changed

+32
-23
lines changed

1 file changed

+32
-23
lines changed

‎src/backend/executor/nodeModifyTable.c

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@
2424
*values plus row-locating info for UPDATE and MERGE cases, or just the
2525
*row-locating info for DELETE cases.
2626
*
27+
*The relation to modify can be an ordinary table, a view having an
28+
*INSTEAD OF trigger, or a foreign table. Earlier processing already
29+
*pointed ModifyTable to the underlying relations of any automatically
30+
*updatable view not using an INSTEAD OF trigger, so code here can
31+
*assume it won't have one as a modification target. This node does
32+
*process ri_WithCheckOptions, which may have expressions from those
33+
*automatically updatable views.
34+
*
2735
*MERGE runs a join between the source relation and the target
2836
*table; if any WHEN NOT MATCHED clauses are present, then the
2937
*join is an outer join. In this case, any unmatched tuples will
@@ -1401,18 +1409,18 @@ ExecDeleteEpilogue(ModifyTableContext *context, ResultRelInfo *resultRelInfo,
14011409
*DELETE is like UPDATE, except that we delete the tuple and no
14021410
*index modifications are needed.
14031411
*
1404-
*When deleting from a table, tupleid identifies the tuple to
1405-
*delete andoldtuple is NULL. When deletingfrom a view,
1406-
*oldtuple is passed to theINSTEAD OFtriggers and identifies
1407-
*what to delete, andtupleid is invalid. When deleting from a
1408-
*foreign table, tupleid isinvalid; the FDW has to figure out
1409-
*which row to delete using data from the planSlot. oldtuple is
1410-
*passed toforeign tabletriggers; it is NULL when the foreign
1411-
*table has no relevant triggers. We use tupleDeleted to indicate
1412-
*whether the tuple is actually deleted, callers can use it to
1413-
*decide whether to continue the operation. When this DELETE is a
1414-
*part of an UPDATE of partition-key, then the slot returned by
1415-
*EvalPlanQual() is passed back using output parameterepqreturnslot.
1412+
*When deleting from a table, tupleid identifies the tuple to delete and
1413+
*oldtuple is NULL. When deletingthrough a view INSTEAD OF trigger,
1414+
*oldtuple is passed to the triggers and identifies what to delete, and
1415+
*tupleid is invalid. When deleting from a foreign table, tupleid is
1416+
*invalid; the FDW has to figure out which row to delete using data from
1417+
*the planSlot. oldtuple is passed to foreign table triggers; it is
1418+
*NULL when theforeign tablehas no relevant triggers. We use
1419+
*tupleDeleted to indicate whether the tuple is actually deleted,
1420+
*callers can use it to decide whether to continue the operation. When
1421+
*this DELETE is a part of an UPDATE of partition-key, then the slot
1422+
*returned by EvalPlanQual() is passed back using output parameter
1423+
*epqreturnslot.
14161424
*
14171425
*Returns RETURNING result if any, otherwise NULL.
14181426
* ----------------------------------------------------------------
@@ -2244,21 +2252,22 @@ ExecCrossPartitionUpdateForeignKey(ModifyTableContext *context,
22442252
*is, we don't want to get stuck in an infinite loop
22452253
*which corrupts your database..
22462254
*
2247-
*When updating a table, tupleid identifies the tuple to
2248-
*update and oldtuple is NULL. When updating a view, oldtuple
2249-
*is passed to the INSTEAD OF triggers and identifies what to
2250-
*update, and tupleid is invalid. When updating a foreign table,
2251-
*tupleid is invalid; the FDW has to figure out which row to
2252-
*update using data from the planSlot. oldtuple is passed to
2253-
*foreign table triggers; it is NULL when the foreign table has
2254-
*no relevant triggers.
2255+
*When updating a table, tupleid identifies the tuple to update and
2256+
*oldtuple is NULL. When updating through a view INSTEAD OF trigger,
2257+
*oldtuple is passed to the triggers and identifies what to update, and
2258+
*tupleid is invalid. When updating a foreign table, tupleid is
2259+
*invalid; the FDW has to figure out which row to update using data from
2260+
*the planSlot. oldtuple is passed to foreign table triggers; it is
2261+
*NULL when the foreign table has no relevant triggers.
22552262
*
22562263
*slot contains the new tuple value to be stored.
22572264
*planSlot is the output of the ModifyTable's subplan; we use it
22582265
*to access values from other input tables (for RETURNING),
22592266
*row-ID junk columns, etc.
22602267
*
2261-
*Returns RETURNING result if any, otherwise NULL.
2268+
*Returns RETURNING result if any, otherwise NULL. On exit, if tupleid
2269+
*had identified the tuple to update, it will identify the tuple
2270+
*actually updated after EvalPlanQual.
22622271
* ----------------------------------------------------------------
22632272
*/
22642273
staticTupleTableSlot*
@@ -3800,8 +3809,8 @@ ExecModifyTable(PlanState *pstate)
38003809
* know enough here to set t_tableOid. Quite separately from
38013810
* this, the FDW may fetch its own junk attrs to identify the row.
38023811
*
3803-
* Other relevant relkinds, currently limited to views, always
3804-
* have a wholerow attribute.
3812+
* Other relevant relkinds, currently limited to views having
3813+
*INSTEAD OF triggers, alwayshave a wholerow attribute.
38053814
*/
38063815
elseif (AttributeNumberIsValid(resultRelInfo->ri_RowIdAttNo))
38073816
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp