From: Tom Lane Date: Fri, 19 Aug 2016 18:35:32 +0000 (-0400) Subject: Guard against parallel-restricted functions in VALUES expressions. X-Git-Tag: REL9_6_RC1~24 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c3813268a7eca8000b8963c079e521eccd960620;p=postgresql Guard against parallel-restricted functions in VALUES expressions. Obvious brain fade in set_rel_consider_parallel(). Noticed it while adjusting the adjacent RTE_FUNCTION case. In 9.6, also make the code look more like what I just did in HEAD by removing the unnecessary function_rte_parallel_ok subroutine (it does nothing that expression_tree_walker wouldn't do). --- diff --git a/src/backend/optimizer/path/allpaths.c b/src/backend/optimizer/path/allpaths.c index 88d833a2e8..cceb27ee76 100644 --- a/src/backend/optimizer/path/allpaths.c +++ b/src/backend/optimizer/path/allpaths.c @@ -78,7 +78,6 @@ static void set_plain_rel_size(PlannerInfo *root, RelOptInfo *rel, static void create_plain_partial_paths(PlannerInfo *root, RelOptInfo *rel); static void set_rel_consider_parallel(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte); -static bool function_rte_parallel_ok(RangeTblEntry *rte); static void set_plain_rel_pathlist(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte); static void set_tablesample_rel_size(PlannerInfo *root, RelOptInfo *rel, @@ -596,16 +595,14 @@ set_rel_consider_parallel(PlannerInfo *root, RelOptInfo *rel, case RTE_FUNCTION: /* Check for parallel-restricted functions. */ - if (!function_rte_parallel_ok(rte)) + if (has_parallel_hazard((Node *) rte->functions, false)) return; break; case RTE_VALUES: - - /* - * The data for a VALUES clause is stored in the plan tree itself, - * so scanning it in a worker is fine. - */ + /* Check for parallel-restricted functions. */ + if (has_parallel_hazard((Node *) rte->values_lists, false)) + return; break; case RTE_CTE: @@ -643,26 +640,6 @@ set_rel_consider_parallel(PlannerInfo *root, RelOptInfo *rel, rel->consider_parallel = true; } -/* - * Check whether a function RTE is scanning something parallel-restricted. - */ -static bool -function_rte_parallel_ok(RangeTblEntry *rte) -{ - ListCell *lc; - - foreach(lc, rte->functions) - { - RangeTblFunction *rtfunc = (RangeTblFunction *) lfirst(lc); - - Assert(IsA(rtfunc, RangeTblFunction)); - if (has_parallel_hazard(rtfunc->funcexpr, false)) - return false; - } - - return true; -} - /* * set_plain_rel_pathlist * Build access paths for a plain relation (no subquery, no inheritance)