postgresql7.1
select grantee_id, grantee_name, privilege
from (
select grantee_id, acs_object__name(grantee_id) as grantee_name, privilege, 1 as counter
from acs_permission.permissions_all(: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 count(*) from (
select grantee_id, grantee_name, privilege
from (
select grantee_id, acs_object__name(grantee_id) as grantee_name, privilege, 1 as counter
from acs_permission.permissions_all(: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
) as counts
select
o.object_id as c_object_id,
acs_object__name(o.object_id) as c_name,
o.object_type as c_type
from
acs_permission.permission_p_recursive_array(array(
select object_id from acs_objects o where context_id = :object_id
), :user_id, 'admin') p
join acs_objects o on (p.orig_object_id = o.object_id)
select count(*) as num_children
from acs_permission.permission_p_recursive_array(array(
select object_id from acs_objects o where context_id = :object_id
), :user_id, 'admin')