I have a table with such columns as a int, b boolean. All users in database have privileged or non-privileged role. Privileged users have access to all rows from table, non-privileged - only to those rows where b is true.
So when non-privileged user executes SELECT, UPDATE or DELETE query it must save it's WHERE condition but also filter all rows what aren't b.
Example: if we have in table:
a | c
--+--
1 | T
2 | T
3 | F
4 | F
and privileged user executes SELECT FROM table WHERE a > 1, he must get
a | c
--+--
2 | T
3 | F
4 | F
whilst non-privileged user on the same query must get
a | c
--+--
2 | T
Is there any ways to implement it using triggers or something?