|
28 | 28 | * rowtype, but we might still find that different plans are appropriate
|
29 | 29 | * for different child relations.
|
30 | 30 | *
|
| 31 | + * The relation to modify can be an ordinary table, a view having an |
| 32 | + * INSTEAD OF trigger, or a foreign table. Earlier processing already |
| 33 | + * pointed ModifyTable to the underlying relations of any automatically |
| 34 | + * updatable view not using an INSTEAD OF trigger, so code here can |
| 35 | + * assume it won't have one as a modification target. This node does |
| 36 | + * process ri_WithCheckOptions, which may have expressions from those |
| 37 | + * automatically updatable views. |
| 38 | + * |
31 | 39 | * If the query specifies RETURNING, then the ModifyTable returns a
|
32 | 40 | * RETURNING tuple after completing each row insert, update, or delete.
|
33 | 41 | * It must be called again to continue the operation. Without RETURNING,
|
@@ -812,8 +820,8 @@ ExecInsert(ModifyTableState *mtstate,
|
812 | 820 | * index modifications are needed.
|
813 | 821 | *
|
814 | 822 | * When deleting from a table, tupleid identifies the tuple to
|
815 |
| - * delete and oldtuple is NULL. When deleting from a view, |
816 |
| - * oldtuple is passed to the INSTEAD OF triggers and identifies |
| 823 | + * delete and oldtuple is NULL. When deleting through a view |
| 824 | + * INSTEAD OF trigger, oldtuple is passed to the triggers and identifies |
817 | 825 | * what to delete, and tupleid is invalid. When deleting from a
|
818 | 826 | * foreign table, tupleid is invalid; the FDW has to figure out
|
819 | 827 | * which row to delete using data from the planSlot. oldtuple is
|
@@ -1178,15 +1186,17 @@ ldelete:;
|
1178 | 1186 | * which corrupts your database..
|
1179 | 1187 | *
|
1180 | 1188 | * When updating a table, tupleid identifies the tuple to
|
1181 |
| - * update and oldtuple is NULL. When updating a view, oldtuple |
1182 |
| - * is passed to the INSTEAD OF triggers and identifies what to |
| 1189 | + * update and oldtuple is NULL. When updating through a view INSTEAD OF |
| 1190 | + * trigger, oldtuple is passed to the triggers and identifies what to |
1183 | 1191 | * update, and tupleid is invalid. When updating a foreign table,
|
1184 | 1192 | * tupleid is invalid; the FDW has to figure out which row to
|
1185 | 1193 | * update using data from the planSlot. oldtuple is passed to
|
1186 | 1194 | * foreign table triggers; it is NULL when the foreign table has
|
1187 | 1195 | * no relevant triggers.
|
1188 | 1196 | *
|
1189 |
| - * Returns RETURNING result if any, otherwise NULL. |
| 1197 | + * Returns RETURNING result if any, otherwise NULL. On exit, if tupleid |
| 1198 | + * had identified the tuple to update, it will identify the tuple |
| 1199 | + * actually updated after EvalPlanQual. |
1190 | 1200 | * ----------------------------------------------------------------
|
1191 | 1201 | */
|
1192 | 1202 | static TupleTableSlot *
|
@@ -2337,8 +2347,8 @@ ExecModifyTable(PlanState *pstate)
|
2337 | 2347 | * to set t_tableOid. Quite separately from this, the FDW may
|
2338 | 2348 | * fetch its own junk attrs to identify the row.
|
2339 | 2349 | *
|
2340 |
| - * Other relevant relkinds, currently limited to views, always |
2341 |
| - * have a wholerow attribute. |
| 2350 | + * Other relevant relkinds, currently limited to views having |
| 2351 | + * INSTEAD OF triggers, always have a wholerow attribute. |
2342 | 2352 | */
|
2343 | 2353 | else if (AttributeNumberIsValid(junkfilter->jf_junkAttNo))
|
2344 | 2354 | {
|
|
0 commit comments