Open
Description
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);