I've been successfully able to use a dense_rank() over (order by...)
which AFAIK is a window function - in postgres' row level security policy conditions.
However, the documentation states
Any SQL conditional expression (returning boolean). The conditional expression cannot contain any aggregate or window functions
(emphasis is mine).
Can someone explain this restriction and give an example where it applies?
Thanks.
Basically, it tells you that each row is independent in regard of row-level security.
Consider the table below:
There are several (permissive) policies:
field1 = 'value1'
field1 = 'value2'
You were granted policies #2 and 3 so you can see and update the last record only.
... Until you execute
UPDATE table SET value2 = 11
.This is really bad in terms of:
Interstingly, you can define policies as
MyField IN (SELECT MyOtherField FROM MyOtherTable)
, in which case it all relies on what you defined onMyOtherTable
(it is intended to be used with FK/PK).