THEN 0
ELSE 1
END, a.name;
-$$ LANGUAGE SQL STABLE;
+$$ LANGUAGE SQL STABLE ROWS 1;
CREATE OR REPLACE FUNCTION permission.grp_ancestors_distance( INT ) RETURNS TABLE (id INT, distance INT) AS $$
WITH RECURSIVE grp_ancestors_distance(id, distance) AS (
WHERE pgt.parent IS NOT NULL
)
SELECT * FROM grp_ancestors_distance;
-$$ LANGUAGE SQL STABLE;
+$$ LANGUAGE SQL STABLE ROWS 1;
CREATE OR REPLACE FUNCTION permission.grp_descendants_distance( INT ) RETURNS TABLE (id INT, distance INT) AS $$
WITH RECURSIVE grp_descendants_distance(id, distance) AS (
FROM permission.grp_tree pgt JOIN grp_descendants_distance gdd ON (pgt.parent = gdd.id)
)
SELECT * FROM grp_descendants_distance;
-$$ LANGUAGE SQL STABLE;
+$$ LANGUAGE SQL STABLE ROWS 1;
CREATE OR REPLACE FUNCTION permission.usr_perms ( INT ) RETURNS SETOF permission.usr_perm_map AS $$
SELECT DISTINCT ON (usr,perm) *
WHERE p.grp IN (SELECT (permission.grp_ancestors(m.grp)).id FROM permission.usr_grp_map m WHERE usr = $1))
) AS x
ORDER BY 2, 3, 1 DESC, 5 DESC ;
-$$ LANGUAGE SQL STABLE;
+$$ LANGUAGE SQL STABLE ROWS 10;
CREATE TABLE permission.usr_work_ou_map (
id SERIAL PRIMARY KEY,
RETURN;
--
END;
-$$ LANGUAGE 'plpgsql';
+$$ LANGUAGE 'plpgsql' ROWS 1;
CREATE OR REPLACE FUNCTION permission.usr_has_perm_at_all_nd(
RETURN;
--
END;
-$$ LANGUAGE 'plpgsql';
+$$ LANGUAGE 'plpgsql' ROWS 1;
CREATE OR REPLACE FUNCTION permission.usr_has_perm_at(
)
RETURNS SETOF INTEGER AS $$
SELECT DISTINCT * FROM permission.usr_has_perm_at_nd( $1, $2 );
-$$ LANGUAGE 'sql';
+$$ LANGUAGE 'sql' ROWS 1;
CREATE OR REPLACE FUNCTION permission.usr_has_perm_at_all(
)
RETURNS SETOF INTEGER AS $$
SELECT DISTINCT * FROM permission.usr_has_perm_at_all_nd( $1, $2 );
-$$ LANGUAGE 'sql';
+$$ LANGUAGE 'sql' ROWS 1;
COMMIT;
JOIN actor.org_unit_type out ON (out.id = ou.ou_type)
JOIN anscestor_depth ot ON (ot.parent_ou = ou.id)
) SELECT ou.* FROM actor.org_unit ou JOIN descendant_depth USING (id);
-$$ LANGUAGE SQL;
+$$ LANGUAGE SQL ROWS 1;
CREATE OR REPLACE FUNCTION actor.org_unit_descendants( INT ) RETURNS SETOF actor.org_unit AS $$
WITH RECURSIVE descendant_depth AS (
JOIN actor.org_unit_type out ON (out.id = ou.ou_type)
JOIN descendant_depth ot ON (ot.id = ou.parent_ou)
) SELECT ou.* FROM actor.org_unit ou JOIN descendant_depth USING (id);
-$$ LANGUAGE SQL;
+$$ LANGUAGE SQL ROWS 1;
CREATE OR REPLACE FUNCTION actor.org_unit_descendants_distance( INT ) RETURNS TABLE (id INT, distance INT) AS $$
WITH RECURSIVE org_unit_descendants_distance(id, distance) AS (
FROM actor.org_unit ou JOIN org_unit_descendants_distance oudd ON (ou.parent_ou = oudd.id)
)
SELECT * FROM org_unit_descendants_distance;
-$$ LANGUAGE SQL STABLE;
+$$ LANGUAGE SQL STABLE ROWS 1;
CREATE OR REPLACE FUNCTION actor.org_unit_ancestors( INT ) RETURNS SETOF actor.org_unit AS $$
WITH RECURSIVE anscestor_depth AS (
FROM actor.org_unit ou
JOIN anscestor_depth ot ON (ot.parent_ou = ou.id)
) SELECT ou.* FROM actor.org_unit ou JOIN anscestor_depth USING (id);
-$$ LANGUAGE SQL;
+$$ LANGUAGE SQL ROWS 1;
CREATE OR REPLACE FUNCTION actor.org_unit_ancestor_at_depth ( INT,INT ) RETURNS actor.org_unit AS $$
SELECT a.*
WHERE ou.parent_ou IS NOT NULL
)
SELECT * FROM org_unit_ancestors_distance;
-$$ LANGUAGE SQL STABLE;
+$$ LANGUAGE SQL STABLE ROWS 1;
CREATE OR REPLACE FUNCTION actor.org_unit_full_path ( INT ) RETURNS SETOF actor.org_unit AS $$
SELECT *
UNION
SELECT *
FROM actor.org_unit_descendants($1);
-$$ LANGUAGE SQL STABLE;
+$$ LANGUAGE SQL STABLE ROWS 1;
CREATE OR REPLACE FUNCTION actor.org_unit_full_path ( INT, INT ) RETURNS SETOF actor.org_unit AS $$
SELECT * FROM actor.org_unit_full_path((actor.org_unit_ancestor_at_depth($1, $2)).id)
-$$ LANGUAGE SQL STABLE;
+$$ LANGUAGE SQL STABLE ROWS 1;
CREATE OR REPLACE FUNCTION actor.org_unit_combined_ancestors ( INT, INT ) RETURNS SETOF actor.org_unit AS $$
SELECT *
UNION
SELECT *
FROM actor.org_unit_ancestors($2);
-$$ LANGUAGE SQL STABLE;
+$$ LANGUAGE SQL STABLE ROWS 1;
CREATE OR REPLACE FUNCTION actor.org_unit_common_ancestors ( INT, INT ) RETURNS SETOF actor.org_unit AS $$
SELECT *
INTERSECT
SELECT *
FROM actor.org_unit_ancestors($2);
-$$ LANGUAGE SQL STABLE;
+$$ LANGUAGE SQL STABLE ROWS 1;
CREATE OR REPLACE FUNCTION actor.org_unit_proximity ( INT, INT ) RETURNS INT AS $$
SELECT COUNT(id)::INT FROM (
END LOOP;
RETURN;
END;
-$$ LANGUAGE plpgsql STABLE;
+$$ LANGUAGE plpgsql STABLE ROWS 1;
COMMENT ON FUNCTION actor.org_unit_ancestor_setting( TEXT, INT) IS $$
/**
--- /dev/null
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0506'); -- miker
+
+ALTER FUNCTION actor.org_unit_descendants( INT, INT ) ROWS 1;
+ALTER FUNCTION actor.org_unit_descendants( INT ) ROWS 1;
+ALTER FUNCTION actor.org_unit_descendants_distance( INT ) ROWS 1;
+ALTER FUNCTION actor.org_unit_ancestors( INT ) ROWS 1;
+ALTER FUNCTION actor.org_unit_ancestors_distance( INT ) ROWS 1;
+ALTER FUNCTION actor.org_unit_full_path ( INT ) ROWS 2;
+ALTER FUNCTION actor.org_unit_full_path ( INT, INT ) ROWS 2;
+ALTER FUNCTION actor.org_unit_combined_ancestors ( INT, INT ) ROWS 1;
+ALTER FUNCTION actor.org_unit_common_ancestors ( INT, INT ) ROWS 1;
+ALTER FUNCTION actor.org_unit_ancestor_setting( TEXT, INT ) ROWS 1;
+ALTER FUNCTION permission.grp_ancestors ( INT ) ROWS 1;
+ALTER FUNCTION permission.grp_ancestors_distance( INT ) ROWS 1;
+ALTER FUNCTION permission.grp_descendants_distance( INT ) ROWS 1;
+ALTER FUNCTION permission.usr_perms ( INT ) ROWS 10;
+ALTER FUNCTION permission.usr_has_perm_at_nd ( INT, TEXT) ROWS 1;
+ALTER FUNCTION permission.usr_has_perm_at_all_nd ( INT, TEXT ) ROWS 1;
+ALTER FUNCTION permission.usr_has_perm_at ( INT, TEXT ) ROWS 1;
+ALTER FUNCTION permission.usr_has_perm_at_all ( INT, TEXT ) ROWS 1;
+
+COMMIT;
+