Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: has_rls_enabled, hasnt_rls_enabled #235

Open
madflow opened this issue Mar 13, 2020 · 0 comments
Open

Feature Request: has_rls_enabled, hasnt_rls_enabled #235

madflow opened this issue Mar 13, 2020 · 0 comments

Comments

@madflow
Copy link

madflow commented Mar 13, 2020

Feature Request: has_rls_enabled, hasnt_rls_enabled

Tests whether or not a table has row level security (RLS) enabled.

has_rls_enabled()

SELECT has_rls_enabled( :schema, :table, :description );
SELECT has_rls_enabled( :table, :description );
SELECT has_rls_enabled( :table );

hasnt_rls_enabled()

SELECT hasnt_rls_enabled( :schema, :table, :description );
SELECT hasnt_rls_enabled( :table, :description );
SELECT hasnt_rls_enabled( :table );

Parameters

  • :schema Schema in which to find the table.
  • :table Name of a table containing the check constraint.
  • :description A short description of the test.

Quick and dirty SQL:

SELECT
c.relrowsecurity as "has_rls_enabled"
FROM pg_catalog.pg_class c
     LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
WHERE c.relkind IN ('r')
AND n.nspname = 'schemaname'
AND c.relname = 'tablename'
AND pg_catalog.pg_table_is_visible(c.oid);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants