]> granicus.if.org Git - postgresql/commit
Perform RLS WITH CHECK before constraints, etc
authorStephen Frost <sfrost@snowman.net>
Sat, 25 Apr 2015 00:34:26 +0000 (20:34 -0400)
committerStephen Frost <sfrost@snowman.net>
Sat, 25 Apr 2015 00:34:26 +0000 (20:34 -0400)
commite89bd02f58ac07e44e0388a32b7ee1b42f1fd7c6
treee6f42eb3a1d58bf7ff874bc72ae29467cb0bc14f
parentc8aa893862275614d54a0657d1fb336020c98f60
Perform RLS WITH CHECK before constraints, etc

The RLS capability is built on top of the WITH CHECK OPTION
system which was added for auto-updatable views, however, unlike
WCOs on views (which are mandated by the SQL spec to not fire until
after all other constraints and checks are done), it makes much more
sense for RLS checks to happen earlier than constraint and uniqueness
checks.

This patch reworks the structure which holds the WCOs a bit to be
explicitly either VIEW or RLS checks and the RLS-related checks are
done prior to the constraint and uniqueness checks.  This also allows
better error reporting as we are now reporting when a violation is due
to a WITH CHECK OPTION and when it's due to an RLS policy violation,
which was independently noted by Craig Ringer as being confusing.

The documentation is also updated to include a paragraph about when RLS
WITH CHECK handling is performed, as there have been a number of
questions regarding that and the documentation was previously silent on
the matter.

Author: Dean Rasheed, with some kabitzing and comment changes by me.
15 files changed:
doc/src/sgml/ref/create_policy.sgml
src/backend/executor/execMain.c
src/backend/executor/nodeModifyTable.c
src/backend/nodes/copyfuncs.c
src/backend/nodes/equalfuncs.c
src/backend/nodes/outfuncs.c
src/backend/nodes/readfuncs.c
src/backend/rewrite/rewriteHandler.c
src/backend/rewrite/rowsecurity.c
src/include/executor/executor.h
src/include/nodes/execnodes.h
src/include/nodes/parsenodes.h
src/test/modules/test_rls_hooks/expected/test_rls_hooks.out
src/test/regress/expected/rowsecurity.out
src/test/regress/sql/rowsecurity.sql