diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/optimizer/plan/planagg.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/backend/optimizer/plan/planagg.c b/src/backend/optimizer/plan/planagg.c index 805aae7ee7a..4216fc4a6ea 100644 --- a/src/backend/optimizer/plan/planagg.c +++ b/src/backend/optimizer/plan/planagg.c @@ -104,6 +104,14 @@ preprocess_minmax_aggregates(PlannerInfo *root, List *tlist) return; /* + * Reject if query contains any CTEs; there's no way to build an indexscan + * on one so we couldn't succeed here. (If the CTEs are unreferenced, + * that's not true, but it doesn't seem worth expending cycles to check.) + */ + if (parse->cteList) + return; + + /* * We also restrict the query to reference exactly one table, since join * conditions can't be handled reasonably. (We could perhaps handle a * query containing cartesian-product joins, but it hardly seems worth the @@ -360,7 +368,6 @@ build_minmax_path(PlannerInfo *root, MinMaxAggInfo *mminfo, subroot->plan_params = NIL; subroot->outer_params = NULL; subroot->init_plans = NIL; - subroot->cte_plan_ids = NIL; subroot->parse = parse = (Query *) copyObject(root->parse); IncrementVarSublevelsUp((Node *) parse, 1, 1); |