diff options
author | Pavan Deolasee | 2017-08-21 05:37:47 +0000 |
---|---|---|
committer | Pavan Deolasee | 2017-08-21 05:41:16 +0000 |
commit | 28147bfd19da345621f209cb5b5065422d8f5926 (patch) | |
tree | e4858cee7d5f5e04523d8bc82f2503fc8b0d4173 | |
parent | 72fdde3af5005f5a88e3f216dcd830537acdc53f (diff) |
Handle params correctly within Subplan nodes
We were not dealing with the params in Subplan correctly, thus those params
were not sent to the remote nodes correctly during RemoteSubplan exectution.
This patch fixes that by traversing the Subplan node correctly. The regression
failure in the 'join' test case is addressed too.
Patch by senhu ([email protected])
-rw-r--r-- | src/backend/pgxc/pool/execRemote.c | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/src/backend/pgxc/pool/execRemote.c b/src/backend/pgxc/pool/execRemote.c index d1a4e4d4b3..7ce5549521 100644 --- a/src/backend/pgxc/pool/execRemote.c +++ b/src/backend/pgxc/pool/execRemote.c @@ -77,6 +77,13 @@ typedef struct void *fparams; } abort_callback_type; +struct find_params_context +{ + RemoteParam *rparams; + Bitmapset *defineParams; + List *subplans; +}; + /* * Buffer size does not affect performance significantly, just do not allow * connection buffer grows infinitely @@ -115,6 +122,8 @@ static void pgxc_connections_cleanup(ResponseCombiner *combiner); static void pgxc_node_report_error(ResponseCombiner *combiner); +static bool determine_param_types(Plan *plan, struct find_params_context *context); + #define REMOVE_CURR_CONN(combiner) \ if ((combiner)->current_conn < --((combiner)->conn_count)) \ { \ @@ -4952,12 +4961,6 @@ RemoteSubplanMakeUnique(Node *plan, int unique) } } -struct find_params_context -{ - RemoteParam *rparams; - Bitmapset *defineParams; -}; - static bool determine_param_types_walker(Node *node, struct find_params_context *context) { @@ -4981,6 +4984,17 @@ determine_param_types_walker(Node *node, struct find_params_context *context) return bms_is_empty(context->defineParams); } } + + if (IsA(node, SubPlan) && context->subplans) + { + Plan *plan; + SubPlan *subplan = (SubPlan *) node; + + plan = (Plan *) list_nth(context->subplans, subplan->plan_id - 1); + if (determine_param_types(plan, context)) + return true; + } + return expression_tree_walker(node, determine_param_types_walker, (void *) context); @@ -5219,6 +5233,18 @@ determine_param_types(Plan *plan, struct find_params_context *context) (int) nodeTag(plan)); } + /* check initplan if exists */ + if (plan->initPlan) + { + ListCell *l; + + foreach(l, plan->initPlan) + { + SubPlan *subplan = (SubPlan *) lfirst(l); + if (determine_param_types_walker((Node *) subplan, context)) + return true; + } + } /* recurse into subplans */ return determine_param_types(plan->lefttree, context) || @@ -5496,6 +5522,7 @@ ExecInitRemoteSubplan(RemoteSubplan *node, EState *estate, int eflags) context.rparams = rstmt.remoteparams; context.defineParams = defineParams; + context.subplans = estate->es_plannedstmt->subplans; all_found = determine_param_types(node->scan.plan.lefttree, &context); |