rls.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*-------------------------------------------------------------------------
  2. *
  3. * rls.h
  4. * Header file for Row Level Security (RLS) utility commands to be used
  5. * with the rowsecurity feature.
  6. *
  7. * Copyright (c) 2007-2016, PostgreSQL Global Development Group
  8. *
  9. * src/include/utils/rls.h
  10. *
  11. *-------------------------------------------------------------------------
  12. */
  13. #ifndef RLS_H
  14. #define RLS_H
  15. /* GUC variable */
  16. extern bool row_security;
  17. /*
  18. * Used by callers of check_enable_rls.
  19. *
  20. * RLS could be completely disabled on the tables involved in the query,
  21. * which is the simple case, or it may depend on the current environment
  22. * (the role which is running the query or the value of the row_security
  23. * GUC), or it might be simply enabled as usual.
  24. *
  25. * If RLS isn't on the table involved then RLS_NONE is returned to indicate
  26. * that we don't need to worry about invalidating the query plan for RLS
  27. * reasons. If RLS is on the table, but we are bypassing it for now, then
  28. * we return RLS_NONE_ENV to indicate that, if the environment changes,
  29. * we need to invalidate and replan. Finally, if RLS should be turned on
  30. * for the query, then we return RLS_ENABLED, which means we also need to
  31. * invalidate if the environment changes.
  32. *
  33. * Note that RLS_ENABLED will also be returned if noError is true
  34. * (indicating that the caller simply want to know if RLS should be applied
  35. * for this user but doesn't want an error thrown if it is; this is used
  36. * by other error cases where we're just trying to decide if data from the
  37. * table should be passed back to the user or not).
  38. */
  39. enum CheckEnableRlsResult
  40. {
  41. RLS_NONE,
  42. RLS_NONE_ENV,
  43. RLS_ENABLED
  44. };
  45. extern int check_enable_rls(Oid relid, Oid checkAsUser, bool noError);
  46. #endif /* RLS_H */