From f1557c773f38b611f64c4abf69f0b9d0572812e1 Mon Sep 17 00:00:00 2001 From: Tomas Vondra Date: Sat, 18 Mar 2017 20:47:32 +0100 Subject: [PATCH] Iterate over the whole simple_rel_array in WITH RECURSIVE check The loop over in subquery_planner() looked about like this: for (i = 1; i < root->simple_rel_array_size - 1; i++) which fails to check the last element in the array, due to a trivial off-by-one error. Instead, the loop should be: for (i = 1; i < root->simple_rel_array_size; i++) --- src/backend/optimizer/plan/planner.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c index 6bd699310b..7cc28acd24 100644 --- a/src/backend/optimizer/plan/planner.c +++ b/src/backend/optimizer/plan/planner.c @@ -866,7 +866,7 @@ subquery_planner(PlannerGlobal *glob, Query *parse, recursiveOk = true; /* seems to start at 1... */ - for (idx = 1; idx < root->simple_rel_array_size - 1 && recursiveOk; idx++) + for (idx = 1; idx < root->simple_rel_array_size && recursiveOk; idx++) { RangeTblEntry *rte; -- 2.39.5