diff options
author | Michael Paquier | 2012-07-23 05:23:22 +0000 |
---|---|---|
committer | Michael Paquier | 2012-07-23 05:23:22 +0000 |
commit | 60262c8b95f692bfd8409a7818ab5699e81e6765 (patch) | |
tree | 0a90adc68c600f3e913f73812978aa003c9575cb | |
parent | 38b2b79f21859016e2b23d1c1203cd1d64ae833d (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.c | 16 |
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); |