Home PostgreSQL - additional condition over the given in WHERE clause in dependency on user's role
Reply: 0

PostgreSQL - additional condition over the given in WHERE clause in dependency on user's role

user929
1#
user929 Published in June 21, 2018, 8:44 am

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?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.349233 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO