From 7633676bd346452a5106dec9f6df0c2feefad385 Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Mon, 12 Mar 2018 13:52:01 -0400 Subject: [PATCH 2/5] Adjust use_physical_tlist to work on upper rels. Instead of testing for the inheritance case by checking specifically for RELOPT_BASEREL, use IS_OTHER_REL(). This requires a small adjustment later in the function: upper rels won't have attr_neeeded set, so just skip that test if the information is not present. Patch by me. --- src/backend/optimizer/plan/createplan.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c index a2bf3b77fe..73a06f32d3 100644 --- a/src/backend/optimizer/plan/createplan.c +++ b/src/backend/optimizer/plan/createplan.c @@ -805,7 +805,7 @@ use_physical_tlist(PlannerInfo *root, Path *path, int flags) * doesn't project; this test may be unnecessary now that * create_append_plan instructs its children to return an exact tlist). */ - if (rel->reloptkind != RELOPT_BASEREL) + if (IS_OTHER_REL(rel)) return false; /* @@ -831,10 +831,13 @@ use_physical_tlist(PlannerInfo *root, Path *path, int flags) * (This could possibly be fixed but would take some fragile assumptions * in setrefs.c, I think.) */ - for (i = rel->min_attr; i <= 0; i++) + if (rel->attr_needed) { - if (!bms_is_empty(rel->attr_needed[i - rel->min_attr])) - return false; + for (i = rel->min_attr; i <= 0; i++) + { + if (!bms_is_empty(rel->attr_needed[i - rel->min_attr])) + return false; + } } /* -- 2.14.3 (Apple Git-98)