 end;
 $$ language 'plpgsql' immutable;
 
--- returns all relations the supplied feature is member of, with the
--- additional column link_tags, e.g. "role"=>"stop", "index"=>"492", "member_id"=>"n1231934421"
-create or replace function objects_relation_member_of(member_id text)
+create or replace function objects_relation(text)
 returns setof pgmapcss_parent_object
 as $$
 #variable_conflict use_variable
 declare
-  w text[];
-  bbox text;
-begin
+  relation_id bigint;
+begin
+  relation_id := cast(substring($1, 2) as bigint);
+
   return query select
     'r' || id,
     t.tags,

      from
	planet_osm_rels
      where
	members @> Array[member_id]
      ) t
    group by
      id,

  ;
end;
$$ language 'plpgsql' immutable;

-- returns all relations the supplied feature is member of, with the
-- additional column link_tags, e.g. "role"=>"stop", "index"=>"492", "member_id"=>"n1231934421"
create or replace function objects_relation_member_of(member_id text)
returns setof pgmapcss_parent_object
as $$
#variable_conflict use_variable
declare
  w text[];
  bbox text;
begin
  return query select
    (ob).*
  from
    (select
      objects_relation('r' || id) ob
    from
      planet_osm_rels
    where
      members @> Array[member_id]
    offset 0
    ) t
  where
    (ob).link_tags->'member_id' = member_id
  ;
end;
$$ language 'plpgsql' immutable;
