Mercurial > gemma
changeset 2818:89f5af7e14ad
Due to performance problems with users.current_user_country() inlined it as
(SELECT country FROM users.list_users WHERE username = current_user) in RLS policies.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Wed, 27 Mar 2019 10:52:09 +0100 |
parents | ff58440ce809 |
children | 53c2bd009c68 |
files | schema/auth.sql |
diffstat | 1 files changed, 5 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/schema/auth.sql Wed Mar 27 10:19:31 2019 +0100 +++ b/schema/auth.sql Wed Mar 27 10:52:09 2019 +0100 @@ -112,10 +112,10 @@ -- RLS policies for templates -- CREATE POLICY select_templates ON users.templates FOR SELECT TO waterway_user - USING (country IS NULL OR country = users.current_user_country()); + USING (country IS NULL OR country = (SELECT country FROM users.list_users WHERE username = current_user)); CREATE POLICY user_templates ON users.templates FOR ALL TO waterway_admin - USING (country = users.current_user_country()); + USING (country = (SELECT country FROM users.list_users WHERE username = current_user)); CREATE POLICY admin_templates ON users.templates FOR ALL TO sys_admin USING (true); @@ -131,11 +131,11 @@ CREATE POLICY same_country ON waterway.gauge_measurements FOR ALL TO waterway_admin - USING ((fk_gauge_id).country_code = users.current_user_country()); + USING ((fk_gauge_id).country_code = (SELECT country FROM users.list_users WHERE username = current_user)); CREATE POLICY same_country ON waterway.waterway_profiles FOR ALL TO waterway_admin - USING ((location).country_code = users.current_user_country()); + USING ((location).country_code = (SELECT country FROM users.list_users WHERE username = current_user)); CREATE POLICY responsibility_area ON waterway.bottlenecks FOR ALL TO waterway_admin @@ -212,7 +212,7 @@ CREATE POLICY import_configuration_policy ON import.import_configuration FOR ALL TO waterway_admin USING ( - users.current_user_country() = ( + (SELECT country FROM users.list_users WHERE username = current_user) = ( SELECT country FROM users.list_users lu WHERE lu.username = import.import_configuration.username));