aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/nodeModifyTable.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/executor/nodeModifyTable.c')
-rw-r--r--src/backend/executor/nodeModifyTable.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index eac9291149e..ab6d4c2d295 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -1277,6 +1277,15 @@ ExecUpdate(ModifyTableState *mtstate,
bool update_indexes;
/*
+ * If we generate a new candidate tuple after EvalPlanQual testing, we
+ * must loop back here to try again. (We don't need to redo triggers,
+ * however. If there are any BEFORE triggers then trigger.c will have
+ * done table_tuple_lock to lock the correct tuple, so there's no need
+ * to do them again.)
+ */
+lreplace:
+
+ /*
* Constraints and GENERATED expressions might reference the tableoid
* column, so (re-)initialize tts_tableOid before evaluating them.
*/
@@ -1289,17 +1298,6 @@ ExecUpdate(ModifyTableState *mtstate,
resultRelationDesc->rd_att->constr->has_generated_stored)
ExecComputeStoredGenerated(estate, slot, CMD_UPDATE);
- /*
- * Check any RLS UPDATE WITH CHECK policies
- *
- * If we generate a new candidate tuple after EvalPlanQual testing, we
- * must loop back here and recheck any RLS policies and constraints.
- * (We don't need to redo triggers, however. If there are any BEFORE
- * triggers then trigger.c will have done table_tuple_lock to lock the
- * correct tuple, so there's no need to do them again.)
- */
-lreplace:;
-
/* ensure slot is independent, consider e.g. EPQ */
ExecMaterializeSlot(slot);
@@ -1314,6 +1312,7 @@ lreplace:;
resultRelInfo->ri_PartitionCheck &&
!ExecPartitionCheck(resultRelInfo, slot, estate, false);
+ /* Check any RLS UPDATE WITH CHECK policies */
if (!partition_constraint_failed &&
resultRelInfo->ri_WithCheckOptions != NIL)
{
@@ -2549,11 +2548,12 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
/*
* For INSERT and UPDATE, prepare to evaluate any generated columns.
- * We must do this now, even if we never insert or update any rows,
- * because we have to fill resultRelInfo->ri_extraUpdatedCols for
- * possible use by the trigger machinery.
+ * (This is probably not necessary any longer, but we'll refrain from
+ * changing it in back branches, in case extension code expects it.)
+ * During EPQ eval, it might have been done already in an earlier EPQ.
*/
- if (operation == CMD_INSERT || operation == CMD_UPDATE)
+ if ((operation == CMD_INSERT || operation == CMD_UPDATE) &&
+ resultRelInfo->ri_GeneratedExprs == NULL)
ExecInitStoredGenerated(resultRelInfo, estate, operation);
resultRelInfo++;