aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2019-03-31 13:47:41 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2019-03-31 13:47:41 -0400
commit9fd4de119c609b4110eea74f00f7b9002e14aa38 (patch)
tree3ad357e59afd2136ba5c8c242c869c34076a72e5 /src
parent2aa6e331ead7f3ad080561495ad4bd3bc7cd8913 (diff)
downloadpostgresql-9fd4de119c609b4110eea74f00f7b9002e14aa38.tar.gz
postgresql-9fd4de119c609b4110eea74f00f7b9002e14aa38.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/backend/optimizer/plan/planner.c10
-rw-r--r--src/backend/optimizer/util/relnode.c11
2 files changed, 10 insertions, 11 deletions
diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c
index f08f1cdf7e7..3a1b846217b 100644
--- a/src/backend/optimizer/plan/planner.c
+++ b/src/backend/optimizer/plan/planner.c
@@ -731,6 +731,16 @@ subquery_planner(PlannerGlobal *glob, Query *parse,
if (rte->lateral)
root->hasLateralRTEs = true;
+
+ /*
+ * We can also determine the maximum security level required for any
+ * securityQuals now. Addition of inheritance-child RTEs won't affect
+ * this, because child tables don't have their own securityQuals; see
+ * expand_single_inheritance_child().
+ */
+ if (rte->securityQuals)
+ root->qual_security_level = Max(root->qual_security_level,
+ list_length(rte->securityQuals));
}
/*
diff --git a/src/backend/optimizer/util/relnode.c b/src/backend/optimizer/util/relnode.c
index f86f39c197f..272e2eb10af 100644
--- a/src/backend/optimizer/util/relnode.c
+++ b/src/backend/optimizer/util/relnode.c
@@ -325,17 +325,6 @@ build_simple_rel(PlannerInfo *root, int relid, RelOptInfo *parent)
}
/*
- * This is a convenient spot at which to note whether rels participating
- * in the query have any securityQuals attached. If so, increase
- * root->qual_security_level to ensure it's larger than the maximum
- * security level needed for securityQuals. (Must do this before we call
- * apply_child_basequals, else we'll hit an Assert therein.)
- */
- if (rte->securityQuals)
- root->qual_security_level = Max(root->qual_security_level,
- list_length(rte->securityQuals));
-
- /*
* Copy the parent's quals to the child, with appropriate substitution of
* variables. If any constant false or NULL clauses turn up, we can mark
* the child as dummy right away. (We must do this immediately so that