summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Martsinchyk2015-01-07 00:22:45 +0000
committerPavan Deolasee2015-04-15 05:46:44 +0000
commitc514680f5693f2fb905237dc34146a0295270cbe (patch)
treeb64ed40f4a1d1df36d9bfa3a194ad762171d6d40 /src
parenteb726bef9c6bd69fbc93111ff706ea47dbbf04bb (diff)
Executor ignored the distributionRestrict list, that could cause
incorrect result of some queries. If RemoteSubplan is running on a Datanode and it is not expected to receive any results from remote datanodes (because distributionRestrict is defined and current node is not in the list) it should not even acquire connections and send down subplan. In this case RemoteSubplan won't produce any results on that node.
Diffstat (limited to 'src')
-rw-r--r--src/backend/pgxc/pool/execRemote.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/backend/pgxc/pool/execRemote.c b/src/backend/pgxc/pool/execRemote.c
index 54405b397e..601e0bbf47 100644
--- a/src/backend/pgxc/pool/execRemote.c
+++ b/src/backend/pgxc/pool/execRemote.c
@@ -8439,6 +8439,14 @@ ExecFinishInitRemoteSubplan(RemoteSubplanState *node)
if (node->subplanstr == NULL)
return;
+ /*
+ * Check if any results are planned to be received here.
+ * Otherwise it does not make sense to send out the subplan.
+ */
+ if (IS_PGXC_DATANODE && plan->distributionRestrict &&
+ !list_member_int(plan->distributionRestrict, PGXCNodeId - 1))
+ return;
+
/*
* Acquire connections and send down subplan where it will be stored
* as a prepared statement.
@@ -8647,6 +8655,18 @@ ExecRemoteSubplan(RemoteSubplanState *node)
EState *estate = combiner->ss.ps.state;
TupleTableSlot *resultslot = combiner->ss.ps.ps_ResultTupleSlot;
+ /*
+ * We allow combiner->conn_count == 0 after node initialization
+ * if we figured out that current node won't receive any result
+ * because of distributionRestrict is set by planner.
+ * But we should distinguish this case from others where result is
+ * received not through a connection. These cases are: local execution
+ * and buffered rows.
+ */
+ if (!node->local_exec && combiner->conn_count == 0 &&
+ list_length(combiner->rowBuffer) == 0)
+ return NULL;
+
primary_mode_phase_two:
if (!node->bound)
{