|
24 | 24 | * values plus row-locating info for UPDATE and MERGE cases, or just the
|
25 | 25 | * row-locating info for DELETE cases.
|
26 | 26 | *
|
| 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 | + * |
27 | 35 | * MERGE runs a join between the source relation and the target
|
28 | 36 | * table; if any WHEN NOT MATCHED clauses are present, then the
|
29 | 37 | * join is an outer join. In this case, any unmatched tuples will
|
@@ -1380,18 +1388,18 @@ ExecDeleteEpilogue(ModifyTableContext *context, ResultRelInfo *resultRelInfo,
|
1380 | 1388 | * DELETE is like UPDATE, except that we delete the tuple and no
|
1381 | 1389 | * index modifications are needed.
|
1382 | 1390 | *
|
1383 |
| - * When deleting from a table, tupleid identifies the tuple to |
1384 |
| - * delete and oldtuple is NULL. When deleting from a view, |
1385 |
| - * oldtuple is passed to the INSTEAD OF triggers and identifies |
1386 |
| - * what to delete, and tupleid is invalid. When deleting from a |
1387 |
| - * foreign table, tupleid is invalid; the FDW has to figure out |
1388 |
| - * which row to delete using data from the planSlot. oldtuple is |
1389 |
| - * passed to foreign table triggers; it is NULL when the foreign |
1390 |
| - * table has no relevant triggers. We use tupleDeleted to indicate |
1391 |
| - * whether the tuple is actually deleted, callers can use it to |
1392 |
| - * decide whether to continue the operation. When this DELETE is a |
1393 |
| - * part of an UPDATE of partition-key, then the slot returned by |
1394 |
| - * EvalPlanQual() is passed back using output parameter epqreturnslot. |
| 1391 | + * When deleting from a table, tupleid identifies the tuple to delete and |
| 1392 | + * oldtuple is NULL. When deleting through a view INSTEAD OF trigger, |
| 1393 | + * oldtuple is passed to the triggers and identifies what to delete, and |
| 1394 | + * tupleid is invalid. When deleting from a foreign table, tupleid is |
| 1395 | + * invalid; the FDW has to figure out which row to delete using data from |
| 1396 | + * the planSlot. oldtuple is passed to foreign table triggers; it is |
| 1397 | + * NULL when the foreign table has no relevant triggers. We use |
| 1398 | + * tupleDeleted to indicate whether the tuple is actually deleted, |
| 1399 | + * callers can use it to decide whether to continue the operation. When |
| 1400 | + * this DELETE is a part of an UPDATE of partition-key, then the slot |
| 1401 | + * returned by EvalPlanQual() is passed back using output parameter |
| 1402 | + * epqreturnslot. |
1395 | 1403 | *
|
1396 | 1404 | * Returns RETURNING result if any, otherwise NULL.
|
1397 | 1405 | * ----------------------------------------------------------------
|
@@ -2225,21 +2233,22 @@ ExecCrossPartitionUpdateForeignKey(ModifyTableContext *context,
|
2225 | 2233 | * is, we don't want to get stuck in an infinite loop
|
2226 | 2234 | * which corrupts your database..
|
2227 | 2235 | *
|
2228 |
| - * When updating a table, tupleid identifies the tuple to |
2229 |
| - * update and oldtuple is NULL. When updating a view, oldtuple |
2230 |
| - * is passed to the INSTEAD OF triggers and identifies what to |
2231 |
| - * update, and tupleid is invalid. When updating a foreign table, |
2232 |
| - * tupleid is invalid; the FDW has to figure out which row to |
2233 |
| - * update using data from the planSlot. oldtuple is passed to |
2234 |
| - * foreign table triggers; it is NULL when the foreign table has |
2235 |
| - * no relevant triggers. |
| 2236 | + * When updating a table, tupleid identifies the tuple to update and |
| 2237 | + * oldtuple is NULL. When updating through a view INSTEAD OF trigger, |
| 2238 | + * oldtuple is passed to the triggers and identifies what to update, and |
| 2239 | + * tupleid is invalid. When updating a foreign table, tupleid is |
| 2240 | + * invalid; the FDW has to figure out which row to update using data from |
| 2241 | + * the planSlot. oldtuple is passed to foreign table triggers; it is |
| 2242 | + * NULL when the foreign table has no relevant triggers. |
2236 | 2243 | *
|
2237 | 2244 | * slot contains the new tuple value to be stored.
|
2238 | 2245 | * planSlot is the output of the ModifyTable's subplan; we use it
|
2239 | 2246 | * to access values from other input tables (for RETURNING),
|
2240 | 2247 | * row-ID junk columns, etc.
|
2241 | 2248 | *
|
2242 |
| - * Returns RETURNING result if any, otherwise NULL. |
| 2249 | + * Returns RETURNING result if any, otherwise NULL. On exit, if tupleid |
| 2250 | + * had identified the tuple to update, it will identify the tuple |
| 2251 | + * actually updated after EvalPlanQual. |
2243 | 2252 | * ----------------------------------------------------------------
|
2244 | 2253 | */
|
2245 | 2254 | static TupleTableSlot *
|
@@ -3781,8 +3790,8 @@ ExecModifyTable(PlanState *pstate)
|
3781 | 3790 | * know enough here to set t_tableOid. Quite separately from
|
3782 | 3791 | * this, the FDW may fetch its own junk attrs to identify the row.
|
3783 | 3792 | *
|
3784 |
| - * Other relevant relkinds, currently limited to views, always |
3785 |
| - * have a wholerow attribute. |
| 3793 | + * Other relevant relkinds, currently limited to views having |
| 3794 | + * INSTEAD OF triggers, always have a wholerow attribute. |
3786 | 3795 | */
|
3787 | 3796 | else if (AttributeNumberIsValid(resultRelInfo->ri_RowIdAttNo))
|
3788 | 3797 | {
|
|
0 commit comments