Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 9fd4de1

Browse files
committed
Compute root->qual_security_level in a less random place.
We can set this up once and for all in subquery_planner's initial survey of the flattened rangetable, rather than incrementally adjusting it in build_simple_rel. The previous approach made it rather hard to reason about exactly when the value would be available, and we were definitely using it in some places before the final value was computed. Noted while fooling around with Amit Langote's patch to delay creation of inheritance child rels. That didn't break this code, but it made it even more fragile, IMO.
1 parent 2aa6e33 commit 9fd4de1

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

src/backend/optimizer/plan/planner.c

+10
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,16 @@ subquery_planner(PlannerGlobal *glob, Query *parse,
731731

732732
if (rte->lateral)
733733
root->hasLateralRTEs = true;
734+
735+
/*
736+
* We can also determine the maximum security level required for any
737+
* securityQuals now. Addition of inheritance-child RTEs won't affect
738+
* this, because child tables don't have their own securityQuals; see
739+
* expand_single_inheritance_child().
740+
*/
741+
if (rte->securityQuals)
742+
root->qual_security_level = Max(root->qual_security_level,
743+
list_length(rte->securityQuals));
734744
}
735745

736746
/*

src/backend/optimizer/util/relnode.c

-11
Original file line numberDiff line numberDiff line change
@@ -324,17 +324,6 @@ build_simple_rel(PlannerInfo *root, int relid, RelOptInfo *parent)
324324
break;
325325
}
326326

327-
/*
328-
* This is a convenient spot at which to note whether rels participating
329-
* in the query have any securityQuals attached. If so, increase
330-
* root->qual_security_level to ensure it's larger than the maximum
331-
* security level needed for securityQuals. (Must do this before we call
332-
* apply_child_basequals, else we'll hit an Assert therein.)
333-
*/
334-
if (rte->securityQuals)
335-
root->qual_security_level = Max(root->qual_security_level,
336-
list_length(rte->securityQuals));
337-
338327
/*
339328
* Copy the parent's quals to the child, with appropriate substitution of
340329
* variables. If any constant false or NULL clauses turn up, we can mark

0 commit comments

Comments
 (0)