From 15f8dc9208176a953c3810293c3e24a3d2c61dbc Mon Sep 17 00:00:00 2001 From: amitlan Date: Sun, 11 Dec 2022 18:12:05 +0900 Subject: [PATCH v2 1/2] Remove some dead code in selfuncs.c RelOptInfo.userid is the same for all relations in a given inheritance tree, so the code in examine_variable() and example_simple_variable() that wants to repeat the ACL checks on the root parent rel instead of a given leaf child relations need not recompute userid too. --- src/backend/utils/adt/selfuncs.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c index 48858a871a..36dac7f0ea 100644 --- a/src/backend/utils/adt/selfuncs.c +++ b/src/backend/utils/adt/selfuncs.c @@ -5211,9 +5211,11 @@ examine_variable(PlannerInfo *root, Node *node, int varRelid, rte = planner_rt_fetch(varno, root); Assert(rte->rtekind == RTE_RELATION); - userid = OidIsValid(onerel->userid) ? - onerel->userid : GetUserId(); - + /* + * Fine to use the same userid as it's + * the same in all relations of a + * given inheritance tree. + */ vardata->acl_ok = rte->securityQuals == NIL && (pg_class_aclcheck(rte->relid, @@ -5344,9 +5346,10 @@ examine_variable(PlannerInfo *root, Node *node, int varRelid, rte = planner_rt_fetch(varno, root); Assert(rte->rtekind == RTE_RELATION); - userid = OidIsValid(onerel->userid) ? - onerel->userid : GetUserId(); - + /* + * Fine to use the same userid as it's the same in + * all relations of a given inheritance tree. + */ vardata->acl_ok = rte->securityQuals == NIL && (pg_class_aclcheck(rte->relid, @@ -5485,9 +5488,10 @@ examine_simple_variable(PlannerInfo *root, Var *var, rte = planner_rt_fetch(varno, root); Assert(rte->rtekind == RTE_RELATION); - userid = OidIsValid(onerel->userid) ? - onerel->userid : GetUserId(); - + /* + * Fine to use the same userid as it's the same in all + * relations of a given inheritance tree. + */ vardata->acl_ok = rte->securityQuals == NIL && ((pg_class_aclcheck(rte->relid, userid, -- 2.35.3