postgresql7.1 select acs_object__name(:object_id) select grantee_id, grantee_name, privilege from (select grantee_id, acs_object__name(grantee_id) as grantee_name, privilege, 1 as counter from acs_permissions_all where object_id = :object_id union all select grantee_id, acs_object__name(grantee_id) as grantee_name, privilege, -1 as counter from acs_permissions where object_id = :object_id ) dummy group by grantee_id, grantee_name, privilege having sum(counter) > 0 select grantee_id, acs_object__name(grantee_id) as grantee_name, privilege from acs_permissions where object_id = :object_id $extra_where_clause SELECT acs_object__name(context_id) as context_name, context_id, security_inherit_p FROM acs_objects WHERE object_id = :object_id select object_id as c_object_id,acs_object__name(object_id) as c_name, object_type as c_type from acs_objects o where context_id = :object_id and exists (select 1 from acs_permissions_all where object_id = o.object_id and grantee_id = :user_id and privilege = 'admin') select count(*) as num_children from acs_objects o where context_id = :object_id and acs_permission__permission_p(o.object_id, :user_id, 'admin') = 't'