summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Paquier2012-06-18 06:17:57 +0000
committerMichael Paquier2012-06-18 06:17:57 +0000
commita593cbdbbb437636d44ceb86c81c82c831ba612a (patch)
treeb696f374dafce464d3a001e99186c36dd852602a /src
parent2f9eabd983cfed51a4fcf4cbbc2fae1167912cd4 (diff)
Fix for bug 3535915: INSERT SELECT for partially replicated tables
Remote DML planning was not taking into account the node list to be used on a relation when modifying data on it. This has been enlighten by a test case with INSERT SELECT on tables replicated defined on a sub-cluster. For example, in the case of a cluster with 2 Datanodes dn1 and dn2: CREATE TABLE aa1 (a int) DISTRIBUTE BY REPLICATION TO NODE dn1; CREATE TABLE aa2 (a int) DISTRIBUTE BY HASH(a); INSERT INTO aa2 VALUES (1),(2),(3),(4); INSERT INTO aa1 SELECT * FROM aa2; The last INSERT SELECT was inserting data on all the nodes instead of doing it only on Datanode dn1.
Diffstat (limited to 'src')
-rw-r--r--src/backend/optimizer/plan/createplan.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c
index 0099d9d886..6972cd3e53 100644
--- a/src/backend/optimizer/plan/createplan.c
+++ b/src/backend/optimizer/plan/createplan.c
@@ -5624,7 +5624,7 @@ create_remoteinsert_plan(PlannerInfo *root, Plan *topplan)
fstep->exec_nodes = makeNode(ExecNodes);
fstep->exec_nodes->baselocatortype = rel_loc_info->locatorType;
fstep->exec_nodes->primarynodelist = NULL;
- fstep->exec_nodes->nodeList = NULL;
+ fstep->exec_nodes->nodeList = rel_loc_info->nodeList;
fstep->exec_nodes->en_relid = ttab->relid;
fstep->exec_nodes->accesstype = RELATION_ACCESS_INSERT;
fstep->exec_nodes->en_expr = pgxc_set_en_expr(ttab->relid, resultRelationIndex);
@@ -5872,6 +5872,7 @@ create_remoteupdate_plan(PlannerInfo *root, Plan *topplan)
fstep->exec_nodes = GetRelationNodes(rel_loc_info, 0, true, UNKNOWNOID, RELATION_ACCESS_UPDATE);
fstep->exec_nodes->baselocatortype = rel_loc_info->locatorType;
fstep->exec_nodes->en_relid = ttab->relid;
+ fstep->exec_nodes->nodeList = rel_loc_info->nodeList;
fstep->exec_nodes->accesstype = RELATION_ACCESS_UPDATE;
fstep->exec_nodes->en_expr = pgxc_set_en_expr(ttab->relid, resultRelationIndex);
SetRemoteStatementName((Plan *) fstep, NULL, tot_prepparams, param_types, 0);
@@ -6019,6 +6020,7 @@ create_remotedelete_plan(PlannerInfo *root, Plan *topplan)
RELATION_ACCESS_UPDATE);
fstep->exec_nodes->baselocatortype = rel_loc_info->locatorType;
fstep->exec_nodes->en_relid = ttab->relid;
+ fstep->exec_nodes->nodeList = rel_loc_info->nodeList;
fstep->exec_nodes->accesstype = RELATION_ACCESS_UPDATE;
SetRemoteStatementName((Plan *) fstep, NULL, tot_prepparams, param_types, 0);
pfree(buf->data);