[open-ils-commits] r8690 - trunk/Open-ILS/src/sql/Pg
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Feb 7 15:16:54 EST 2008
Author: miker
Date: 2008-02-07 14:48:17 -0500 (Thu, 07 Feb 2008)
New Revision: 8690
Modified:
trunk/Open-ILS/src/sql/Pg/006.schema.permissions.sql
Log:
adding index for object perms, and re-tabbing a bit
Modified: trunk/Open-ILS/src/sql/Pg/006.schema.permissions.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/006.schema.permissions.sql 2008-02-07 19:36:16 UTC (rev 8689)
+++ trunk/Open-ILS/src/sql/Pg/006.schema.permissions.sql 2008-02-07 19:48:17 UTC (rev 8690)
@@ -49,6 +49,8 @@
CONSTRAINT perm_usr_obj_once UNIQUE (usr,perm,object_type,object_id)
);
+CREATE INDEX uopm_usr_idx ON permission.usr_object_perm_map (usr);
+
CREATE TABLE permission.usr_grp_map (
id SERIAL PRIMARY KEY,
usr INT NOT NULL REFERENCES actor.usr (id) ON DELETE CASCADE,
@@ -221,7 +223,7 @@
CREATE OR REPLACE FUNCTION permission.usr_has_object_perm ( iuser INT, tperm TEXT, obj_type TEXT, obj_id TEXT, target_ou INT ) RETURNS BOOL AS $$
DECLARE
r_usr actor.usr%ROWTYPE;
- res BOOL;
+ res BOOL;
BEGIN
SELECT * INTO r_usr FROM actor.usr WHERE id = iuser;
@@ -234,17 +236,17 @@
RETURN TRUE;
END IF;
- SELECT TRUE INTO res FROM permission.usr_object_perm_map WHERE usr = r_usr.id AND object_type = obj_type AND object_id = obj_id;
+ SELECT TRUE INTO res FROM permission.usr_object_perm_map WHERE usr = r_usr.id AND object_type = obj_type AND object_id = obj_id;
- IF FOUND THEN
- RETURN TRUE;
- END IF;
+ IF FOUND THEN
+ RETURN TRUE;
+ END IF;
- IF target_ou > -1 THEN
- RETURN permission.usr_has_perm( iuser, tperm, target_ou);
+ IF target_ou > -1 THEN
+ RETURN permission.usr_has_perm( iuser, tperm, target_ou);
END IF;
- RETURN FALSE;
+ RETURN FALSE;
END;
$$ LANGUAGE PLPGSQL;
More information about the open-ils-commits
mailing list