   surface_geometry_ids int[] := '{}';
   address_ids int[] := '{}';
 BEGIN
-  -- delete citydb.bridge_openings
+  -- delete bridge_openings
   WITH delete_objects AS (
     DELETE FROM
-      citydb.bridge_opening t
+      bridge_opening t
     USING
       unnest($1) a(a_id)
     WHERE

BEGIN
  IF $2 = 0 THEN
    SELECT array_agg(c.id) FROM
      citydb.cityobject c
    INTO
      deleted_ids
    WHERE
      c.lineage = $1;
  ELSE
    SELECT array_agg(c.id) FROM
      citydb.cityobject c
    INTO
      deleted_ids
    WHERE

  FROM
    delete_objects;

  -- delete surface_geometry(s)
  IF -1 = ALL(surface_geometry_ids) IS NOT NULL THEN
    PERFORM
      del_surface_geometry(array_agg(a.a_id))
    FROM
      (SELECT DISTINCT unnest(surface_geometry_ids) AS a_id) a;
  END IF;

  IF $2 <> 1 THEN
    -- delete cityobject
    PERFORM del_cityobject(deleted_ids, 2);
  END IF;

  RETURN QUERY
