Index: openacs-4/contrib/obsolete-packages/acs-workflow/www/admin/wizard/create-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/obsolete-packages/acs-workflow/www/admin/wizard/create-postgresql.xql,v diff -u -r1.1 -r1.2 --- openacs-4/contrib/obsolete-packages/acs-workflow/www/admin/wizard/create-postgresql.xql 3 May 2001 04:03:03 -0000 1.1 +++ openacs-4/contrib/obsolete-packages/acs-workflow/www/admin/wizard/create-postgresql.xql 12 May 2001 21:48:54 -0000 1.2 @@ -26,14 +26,14 @@ select '[db_quote $workflow_key]' as workflow_key, '[db_quote $transition_key]' as transition_key, workflow__create_attribute( - workflow_key => '[db_quote $workflow_key]', - attribute_name => '[db_quote $task($transition_key,loop_attribute_name)]', - datatype => 'boolean', - pretty_name => '[db_quote "$task($transition_key,loop_question)"]', + '[db_quote $workflow_key]', + '[db_quote $task($transition_key,loop_attribute_name)]', + 'boolean', + '[db_quote "$task($transition_key,loop_question)"]', null, null, null, - default_value => '[ad_decode $task($transition_key,loop_answer) "t" "f" "t"]', + '[ad_decode $task($transition_key,loop_answer) "t" "f" "t"]', 1, 1, null, Index: openacs-4/packages/acs-kernel/sql/postgresql/acs-permissions-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/acs-permissions-create.sql,v diff -u -r1.13 -r1.14 --- openacs-4/packages/acs-kernel/sql/postgresql/acs-permissions-create.sql 1 May 2001 15:11:24 -0000 1.13 +++ openacs-4/packages/acs-kernel/sql/postgresql/acs-permissions-create.sql 12 May 2001 21:48:54 -0000 1.14 @@ -541,6 +541,31 @@ -- show errors +-- This table acts as a mutex for inserts/deletes from acs_permissions. +-- This is used since postgresql's exception handing mechanism is non- +-- existant. A dup insert on acs_permissions will roll-back the +-- transaction and give an error, which is not what we want. Using a +-- separate table for locking allows us exclusive access for +-- inserts/deletes, but does not block readers. That way we don't +-- slow down permissions-checking which is known to have performance +-- problems already. + +-- (OpenACS - DanW) + +create table acs_permissions_lock ( + lck integer +); + +create function acs_permissions_lock_tr () returns opaque as ' +begin + raise EXCEPTION ''FOR LOCKING ONLY, NO DML STATEMENTS ALLOWED''; + return null; +end;' language 'plpgsql'; + +create trigger acs_permissions_lock_tr +before insert or update or delete on acs_permissions_lock +for each row execute procedure acs_permissions_lock_tr(); + -- create or replace package body acs_permission -- procedure grant_permission create function acs_permission__grant_permission (integer, integer, varchar) @@ -549,18 +574,31 @@ grant_permission__object_id alias for $1; grant_permission__grantee_id alias for $2; grant_permission__privilege alias for $3; + exists_p boolean; begin - insert into acs_permissions - (object_id, grantee_id, privilege) - values - (grant_permission__object_id, grant_permission__grantee_id, - grant_permission__privilege); + lock table acs_permissions_lock; - -- FIXME: find out what this means? - -- exception - -- when dup_val_on_index then - -- return; - return 0; + select count(*) > 0 into exists_p + from acs_permissions + where object_id = grant_permission__object_id + and grantee_id = grant_permission__grantee_id + and privilege = grant_permission__privilege; + + if not exists_p then + + insert into acs_permissions + (object_id, grantee_id, privilege) + values + (grant_permission__object_id, grant_permission__grantee_id, + grant_permission__privilege); + + end if; + + -- exception + -- when dup_val_on_index then + -- return; + + return 0; end;' language 'plpgsql'; @@ -572,6 +610,8 @@ revoke_permission__grantee_id alias for $2; revoke_permission__privilege alias for $3; begin + lock table acs_permissions_lock; + delete from acs_permissions where object_id = revoke_permission__object_id and grantee_id = revoke_permission__grantee_id