diff options
author | Stephen Frost <sfrost@snowman.net> | 2015-04-24 20:34:26 -0400 |
---|---|---|
committer | Stephen Frost <sfrost@snowman.net> | 2015-04-24 20:34:26 -0400 |
commit | e89bd02f58ac07e44e0388a32b7ee1b42f1fd7c6 (patch) | |
tree | e6f42eb3a1d58bf7ff874bc72ae29467cb0bc14f /src/include/nodes/parsenodes.h | |
parent | c8aa893862275614d54a0657d1fb336020c98f60 (diff) | |
download | postgresql-e89bd02f58ac07e44e0388a32b7ee1b42f1fd7c6.tar.gz postgresql-e89bd02f58ac07e44e0388a32b7ee1b42f1fd7c6.zip |
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.
Diffstat (limited to 'src/include/nodes/parsenodes.h')
-rw-r--r-- | src/include/nodes/parsenodes.h | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h index 0e257ac46ce..36e36d56316 100644 --- a/src/include/nodes/parsenodes.h +++ b/src/include/nodes/parsenodes.h @@ -872,14 +872,23 @@ typedef struct RangeTblFunction /* * WithCheckOption - * representation of WITH CHECK OPTION checks to be applied to new tuples - * when inserting/updating an auto-updatable view. + * when inserting/updating an auto-updatable view, or RLS WITH CHECK + * policies to be applied when inserting/updating a relation with RLS. */ +typedef enum WCOKind +{ + WCO_VIEW_CHECK, /* WCO on an auto-updatable view */ + WCO_RLS_INSERT_CHECK, /* RLS INSERT WITH CHECK policy */ + WCO_RLS_UPDATE_CHECK /* RLS UPDATE WITH CHECK policy */ +} WCOKind; + typedef struct WithCheckOption { NodeTag type; - char *viewname; /* name of view that specified the WCO */ + WCOKind kind; /* kind of WCO */ + char *relname; /* name of relation that specified the WCO */ Node *qual; /* constraint qual to check */ - bool cascaded; /* true = WITH CASCADED CHECK OPTION */ + bool cascaded; /* true for a cascaded WCO on a view */ } WithCheckOption; /* |