mirror of
https://github.com/postgres/postgres.git
synced 2025-09-09 13:09:39 +03:00
Support data-modifying commands (INSERT/UPDATE/DELETE) in WITH.
This patch implements data-modifying WITH queries according to the semantics that the updates all happen with the same command counter value, and in an unspecified order. Therefore one WITH clause can't see the effects of another, nor can the outer query see the effects other than through the RETURNING values. And attempts to do conflicting updates will have unpredictable results. We'll need to document all that. This commit just fixes the code; documentation updates are waiting on author. Marko Tiikkaja and Hitoshi Harada
This commit is contained in:
@@ -346,7 +346,7 @@ typedef struct EState
|
||||
/* If query can insert/delete tuples, the command ID to mark them with */
|
||||
CommandId es_output_cid;
|
||||
|
||||
/* Info about target table for insert/update/delete queries: */
|
||||
/* Info about target table(s) for insert/update/delete queries: */
|
||||
ResultRelInfo *es_result_relations; /* array of ResultRelInfos */
|
||||
int es_num_result_relations; /* length of array */
|
||||
ResultRelInfo *es_result_relation_info; /* currently active array elt */
|
||||
@@ -378,6 +378,8 @@ typedef struct EState
|
||||
|
||||
List *es_subplanstates; /* List of PlanState for SubPlans */
|
||||
|
||||
List *es_auxmodifytables; /* List of secondary ModifyTableStates */
|
||||
|
||||
/*
|
||||
* this ExprContext is for per-output-tuple operations, such as constraint
|
||||
* checks and index-value computations. It will be reset for each output
|
||||
@@ -1041,10 +1043,13 @@ typedef struct ResultState
|
||||
typedef struct ModifyTableState
|
||||
{
|
||||
PlanState ps; /* its first field is NodeTag */
|
||||
CmdType operation;
|
||||
CmdType operation; /* INSERT, UPDATE, or DELETE */
|
||||
bool canSetTag; /* do we set the command tag/es_processed? */
|
||||
bool mt_done; /* are we done? */
|
||||
PlanState **mt_plans; /* subplans (one per target rel) */
|
||||
int mt_nplans; /* number of plans in the array */
|
||||
int mt_whichplan; /* which one is being executed (0..n-1) */
|
||||
ResultRelInfo *resultRelInfo; /* per-subplan target relations */
|
||||
List **mt_arowmarks; /* per-subplan ExecAuxRowMark lists */
|
||||
EPQState mt_epqstate; /* for evaluating EvalPlanQual rechecks */
|
||||
bool fireBSTriggers; /* do we need to fire stmt triggers? */
|
||||
|
Reference in New Issue
Block a user