--
-- bookmark__private_p/1
--
create or replace function bookmark__private_p(
  p_bookmark_id integer
) returns bool as $$

DECLARE
    v_private_p  bm_in_closed_p.closed_p%TYPE;

BEGIN

    SELECT CASE WHEN count(*)=0 THEN 'f' ELSE 't' END INTO v_private_p
    FROM acs_objects,
    (
        SELECT bm.bookmark_id FROM bm_bookmarks bm,
          (SELECT tree_ancestor_keys(bm_bookmarks_get_tree_sortkey(p_bookmark_id)) as tree_sortkey) parents
        WHERE bm.tree_sortkey = parents.tree_sortkey
    ) b
    WHERE b.bookmark_id = acs_objects.object_id
    AND acs_objects.security_inherit_p = 'f';

    RETURN v_private_p;

END;
$$ language plpgsql;