From 844e7a3b4931773324be06d6172c572187483375 Mon Sep 17 00:00:00 2001 From: Alvaro Herrera Date: Tue, 29 Nov 2022 09:56:02 +0100 Subject: [PATCH v28 5/8] setrefs: split out addition of PermInfo to flat list With the old structure, the outer comment was wrong, because it failed to point out the new action that the block was taking. But instead of fixing the comment, we can just make a new one that's conditional on perminfoindex alone and doesn't consider rtekind at all. --- src/backend/optimizer/plan/setrefs.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/backend/optimizer/plan/setrefs.c b/src/backend/optimizer/plan/setrefs.c index 534090a614..1023223a45 100644 --- a/src/backend/optimizer/plan/setrefs.c +++ b/src/backend/optimizer/plan/setrefs.c @@ -547,22 +547,20 @@ add_rte_to_flat_rtable(PlannerGlobal *glob, List *rtepermlist, * but it would probably cost more cycles than it would save. */ if (newrte->rtekind == RTE_RELATION) + glob->relationOids = lappend_oid(glob->relationOids, newrte->relid); + + /* + * Add the RTEPermissionInfo, if any, corresponding to this RTE to the + * flattened global list. Also update the perminfoindex in newrte to + * reflect the RTEPermissionInfo's position in this other list. + */ + if (rte->perminfoindex > 0) { RTEPermissionInfo *perminfo; - glob->relationOids = lappend_oid(glob->relationOids, newrte->relid); - - /* - * Add the RTEPermissionInfo, if any, corresponding to this RTE to the - * flattened global list. Also update the perminfoindex to reflect - * the RTEPermissionInfo's new position. - */ - if (rte->perminfoindex > 0) - { - perminfo = GetRTEPermissionInfo(rtepermlist, newrte); - glob->finalrtepermlist = lappend(glob->finalrtepermlist, perminfo); - newrte->perminfoindex = list_length(glob->finalrtepermlist); - } + perminfo = GetRTEPermissionInfo(rtepermlist, newrte); + glob->finalrtepermlist = lappend(glob->finalrtepermlist, perminfo); + newrte->perminfoindex = list_length(glob->finalrtepermlist); } } -- 2.30.2