Enforce ALL/SELECT policies in RETURNING for RLS

Stephen Frost <sfrost@snowman.net>

Commit: 68b5201128c2d0c8a3a0051ff7c2534b037e1eab
Author: Stephen Frost <sfrost@snowman.net>
Date: 2015-09-15T19:49:40Z
Releases: 9.5.0
Enforce ALL/SELECT policies in RETURNING for RLS

For the UPDATE/DELETE RETURNING case, filter the records which are not
visible to the user through ALL or SELECT policies from those considered
for the UPDATE or DELETE.  This is similar to how the GRANT system
works, which prevents RETURNING unless the caller has SELECT rights on
the relation.

Per discussion with Robert, Dean, Tom, and Kevin.

Back-patch to 9.5 where RLS was introduced.

Files

PathChange+/−
src/backend/rewrite/rowsecurity.c modified +47 −0
src/test/regress/expected/rowsecurity.out modified +27 −23