Reputation: 3798
One might forget to enable it, so I'd rather explicitly disable it for tables that don't need it.
Upvotes: 1
Views: 638
Reputation: 26454
I think you can probably enable it by default by creating an event trigger.
I haven't tried this but this should be enough to get you started.
In this case you effectively have a function which runs after any CREATE TABLE and enables row level security.
The PostgreSQL docs for PostgreSQL 9.5 are at http://www.postgresql.org/docs/9.5/static/functions-event-triggers.html for functions you can use to get the table info. This looks feasible.
Upvotes: 2
Reputation: 32179
Row level security can not be enabled or disabled by default. You have to ALTER TABLE ... ENABLE ROW LEVEL SECURITY
. However, I don't see how you can forget it as a table is only accessible by its owner initially. If you then create a row security policy with CREATE POLICY
you will still not have access so you'll know you did something wrong.
You can ask yourself why you have to ALTER TABLE ... ENABLE ROW LEVEL SECURITY
to begin with, but that is a question for the postgresql-devel
mailing list, not for SO.
Upvotes: 3