diff options
author | Stephen Frost <sfrost@snowman.net> | 2015-12-14 20:05:43 -0500 |
---|---|---|
committer | Stephen Frost <sfrost@snowman.net> | 2015-12-14 20:05:43 -0500 |
commit | e5e11c8cca7ae298895430102217fa6d77cfb2a3 (patch) | |
tree | 4f6601826910ede524a063e482fa7768fec7d42a /src/backend | |
parent | db81329eed6b1f54bbdd9049bcdba556f2b4737d (diff) | |
download | postgresql-e5e11c8cca7ae298895430102217fa6d77cfb2a3.tar.gz postgresql-e5e11c8cca7ae298895430102217fa6d77cfb2a3.zip |
Collect the global OR of hasRowSecurity flags for plancache
We carry around information about if a given query has row security or
not to allow the plancache to use that information to invalidate a
planned query in the event that the environment changes.
Previously, the flag of one of the subqueries was simply being copied
into place to indicate if the query overall included RLS components.
That's wrong as we need the global OR of all subqueries. Fix by
changing the code to match how fireRIRules works, which is results
in OR'ing all of the flags.
Noted by Tom.
Back-patch to 9.5 where RLS was introduced.
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/optimizer/plan/planner.c | 3 | ||||
-rw-r--r-- | src/backend/optimizer/plan/setrefs.c | 3 |
2 files changed, 4 insertions, 2 deletions
diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c index 797df31c883..2c04f5c994d 100644 --- a/src/backend/optimizer/plan/planner.c +++ b/src/backend/optimizer/plan/planner.c @@ -1529,7 +1529,8 @@ grouping_planner(PlannerInfo *root, double tuple_fraction) * This may add new security barrier subquery RTEs to the rangetable. */ expand_security_quals(root, tlist); - root->glob->hasRowSecurity = parse->hasRowSecurity; + if (parse->hasRowSecurity) + root->glob->hasRowSecurity = true; /* * Locate any window functions in the tlist. (We don't need to look diff --git a/src/backend/optimizer/plan/setrefs.c b/src/backend/optimizer/plan/setrefs.c index d2232c227bc..12e929068a7 100644 --- a/src/backend/optimizer/plan/setrefs.c +++ b/src/backend/optimizer/plan/setrefs.c @@ -2401,7 +2401,8 @@ extract_query_dependencies_walker(Node *node, PlannerInfo *context) ListCell *lc; /* Collect row security information */ - context->glob->hasRowSecurity = query->hasRowSecurity; + if (query->hasRowSecurity) + context->glob->hasRowSecurity = true; if (query->commandType == CMD_UTILITY) { |