summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Paquier2012-07-23 05:23:22 +0000
committerMichael Paquier2012-07-23 05:23:22 +0000
commit60262c8b95f692bfd8409a7818ab5699e81e6765 (patch)
tree0a90adc68c600f3e913f73812978aa003c9575cb
parent38b2b79f21859016e2b23d1c1203cd1d64ae833d (diff)
Set CommandId communication flag on Coordinator only for parent/child INSERT SELECT
In the particular case of an INSERT SELECT where INSERT is done on a child table based on the data scanned of the parent, it is necessary to communicate the command Id between Postgres-XC nodes. However in this case it was done for all the nodes and it is only necessary to set it on local Coordinator.
-rw-r--r--src/backend/parser/analyze.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/backend/parser/analyze.c b/src/backend/parser/analyze.c
index e496b2f6d3..5ab63decce 100644
--- a/src/backend/parser/analyze.c
+++ b/src/backend/parser/analyze.c
@@ -530,11 +530,19 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt)
makeAlias("*SELECT*", NIL),
false);
#ifdef PGXC
- target_rte = rt_fetch(qry->resultRelation, pstate->p_rtable);
- if (is_relation_child(target_rte, selectQuery->rtable))
+ /*
+ * For an INSERT SELECT involving INSERT on a child after scanning
+ * the parent, set flag to send command ID communication to remote
+ * nodes in order to maintain global data visibility.
+ */
+ if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
{
- qry->is_ins_child_sel_parent = true;
- SetSendCommandId(true);
+ target_rte = rt_fetch(qry->resultRelation, pstate->p_rtable);
+ if (is_relation_child(target_rte, selectQuery->rtable))
+ {
+ qry->is_ins_child_sel_parent = true;
+ SetSendCommandId(true);
+ }
}
#endif
rtr = makeNode(RangeTblRef);