Collect the global OR of hasRowSecurity flags for plancache
authorStephen Frost <sfrost@snowman.net>
Tue, 15 Dec 2015 01:05:43 +0000 (20:05 -0500)
committerStephen Frost <sfrost@snowman.net>
Tue, 15 Dec 2015 01:05:43 +0000 (20:05 -0500)
commite5e11c8cca7ae298895430102217fa6d77cfb2a3
tree4f6601826910ede524a063e482fa7768fec7d42a
parentdb81329eed6b1f54bbdd9049bcdba556f2b4737d
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.
src/backend/optimizer/plan/planner.c
src/backend/optimizer/plan/setrefs.c
src/test/regress/expected/rowsecurity.out
src/test/regress/sql/rowsecurity.sql