From: Pavan Deolasee Date: Mon, 21 Aug 2017 05:37:47 +0000 (+0530) Subject: Handle params correctly within Subplan nodes X-Git-Tag: XL_10_R1BETA1~172 X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=28147bfd19da345621f209cb5b5065422d8f5926;p=postgres-xl.git 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 (senhu@tencent.com) --- 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);