diff options
Diffstat (limited to 'src/backend/utils/misc/rls.c')
-rw-r--r-- | src/backend/utils/misc/rls.c | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/src/backend/utils/misc/rls.c b/src/backend/utils/misc/rls.c index 066ac21a58c..44cb3743034 100644 --- a/src/backend/utils/misc/rls.c +++ b/src/backend/utils/misc/rls.c @@ -1,14 +1,14 @@ /*------------------------------------------------------------------------- * * rls.c - * RLS-related utility functions. + * RLS-related utility functions. * * Portions Copyright (c) 1996-2015, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * * IDENTIFICATION - * src/backend/utils/misc/rls.c + * src/backend/utils/misc/rls.c * *------------------------------------------------------------------------- */ @@ -24,7 +24,7 @@ #include "utils/syscache.h" -extern int check_enable_rls(Oid relid, Oid checkAsUser, bool noError); +extern int check_enable_rls(Oid relid, Oid checkAsUser, bool noError); /* * check_enable_rls @@ -48,10 +48,10 @@ extern int check_enable_rls(Oid relid, Oid checkAsUser, bool noError); int check_enable_rls(Oid relid, Oid checkAsUser, bool noError) { - HeapTuple tuple; - Form_pg_class classform; - bool relrowsecurity; - Oid user_id = checkAsUser ? checkAsUser : GetUserId(); + HeapTuple tuple; + Form_pg_class classform; + bool relrowsecurity; + Oid user_id = checkAsUser ? checkAsUser : GetUserId(); tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid)); if (!HeapTupleIsValid(tuple)) @@ -88,25 +88,24 @@ check_enable_rls(Oid relid, Oid checkAsUser, bool noError) /* * If the row_security GUC is 'off' then check if the user has permission - * to bypass it. Note that we have already handled the case where the user - * is the table owner above. + * to bypass it. Note that we have already handled the case where the + * user is the table owner above. * - * Note that row_security is always considered 'on' when querying - * through a view or other cases where checkAsUser is true, so skip this - * if checkAsUser is in use. + * Note that row_security is always considered 'on' when querying through + * a view or other cases where checkAsUser is true, so skip this if + * checkAsUser is in use. */ if (!checkAsUser && row_security == ROW_SECURITY_OFF) { if (has_bypassrls_privilege(user_id)) /* OK to bypass */ return RLS_NONE_ENV; + else if (noError) + return RLS_ENABLED; else - if (noError) - return RLS_ENABLED; - else - ereport(ERROR, - (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), - errmsg("insufficient privilege to bypass row security."))); + ereport(ERROR, + (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), + errmsg("insufficient privilege to bypass row security."))); } /* RLS should be fully enabled for this relation. */ |