--
-- pa_photo__delete/1
--
create or replace function pa_photo__delete(
  integer
) returns int4 as $$

declare
    del__item_id	alias for $1;
    v_rec		record;
begin
    for v_rec in 
	select child_id
	from cr_child_rels
	where parent_id = del__item_id
    LOOP
	PERFORM image__delete (v_rec.child_id);
    end loop;

    -- content_item__delete takes care of all revisions
    -- on delete cascades take care of rest

    PERFORM content_item__delete (del__item_id);

    return 0; 
end; $$ language plpgsql;