0002-Adjust-use_physical_tlist-to-work-on-upper-rels.patch
application/octet-stream
Filename: 0002-Adjust-use_physical_tlist-to-work-on-upper-rels.patch
Type: application/octet-stream
Part: 5
Patch
Format: format-patch
Series: patch 0002
Subject: Adjust use_physical_tlist to work on upper rels.
| File | + | − |
|---|---|---|
| src/backend/optimizer/plan/createplan.c | 7 | 4 |
From 6329bf690a327e003a8de6e21aef3ffa019c561d Mon Sep 17 00:00:00 2001
From: Robert Haas <rhaas@postgresql.org>
Date: Mon, 12 Mar 2018 13:52:01 -0400
Subject: [PATCH 2/7] 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, reviewed by Amit Kapila.
---
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 997d032939..b5107988d6 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)