postgresql7.1
select tree_id, site_wide_p,
acs_permission__permission_p(tree_id, :user_id, 'category_tree_read') has_read_permission
from category_trees t
where not exists (select 1 from category_tree_map m
where m.object_id = :object_id
and m.tree_id = t.tree_id)
order by t.tree_id