annotate schema/updates/1104/01.remove_function.sql @ 5267:aca4bf7af270

client: remove mapState from import statement
author Fadi Abbud <fadi.abbud@intevation.de>
date Wed, 10 Jun 2020 16:33:10 +0200
parents 5466562cca60
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4158
5466562cca60 Remove utility function with possibly bad performance impact
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
1 DROP POLICY same_country ON import.imports;
5466562cca60 Remove utility function with possibly bad performance impact
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
2 CREATE POLICY same_country ON import.imports
5466562cca60 Remove utility function with possibly bad performance impact
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
3 FOR ALL TO waterway_admin
5466562cca60 Remove utility function with possibly bad performance impact
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
4 USING (EXISTS(SELECT 1 FROM users.list_users lu
5466562cca60 Remove utility function with possibly bad performance impact
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
5 WHERE lu.username = imports.username));
5466562cca60 Remove utility function with possibly bad performance impact
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
6
5466562cca60 Remove utility function with possibly bad performance impact
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
7 ALTER TABLE users.templates ALTER COLUMN country DROP DEFAULT;
5466562cca60 Remove utility function with possibly bad performance impact
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
8
5466562cca60 Remove utility function with possibly bad performance impact
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
9 CREATE OR REPLACE FUNCTION users.current_user_area_utm()
5466562cca60 Remove utility function with possibly bad performance impact
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
10 RETURNS geometry
5466562cca60 Remove utility function with possibly bad performance impact
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
11 AS $$
5466562cca60 Remove utility function with possibly bad performance impact
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
12 DECLARE utm_area geometry;
5466562cca60 Remove utility function with possibly bad performance impact
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
13 BEGIN
5466562cca60 Remove utility function with possibly bad performance impact
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
14 SELECT ST_Transform(area::geometry, best_utm(area))
5466562cca60 Remove utility function with possibly bad performance impact
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
15 INTO STRICT utm_area
5466562cca60 Remove utility function with possibly bad performance impact
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
16 FROM users.responsibility_areas
5466562cca60 Remove utility function with possibly bad performance impact
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
17 WHERE country = (SELECT country
5466562cca60 Remove utility function with possibly bad performance impact
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
18 FROM users.list_users WHERE username = current_user);
5466562cca60 Remove utility function with possibly bad performance impact
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
19 RETURN utm_area;
5466562cca60 Remove utility function with possibly bad performance impact
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
20 END;
5466562cca60 Remove utility function with possibly bad performance impact
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
21 $$
5466562cca60 Remove utility function with possibly bad performance impact
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
22 LANGUAGE plpgsql
5466562cca60 Remove utility function with possibly bad performance impact
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
23 STABLE PARALLEL SAFE;
5466562cca60 Remove utility function with possibly bad performance impact
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
24
5466562cca60 Remove utility function with possibly bad performance impact
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
25 DROP FUNCTION users.current_user_country();