 *   delete_bridge_them_srf(pid int, objclass_id int) RETURNS int
 *   delete_bridge_them_srf(pids int[], objclass_ids int[]) RETURNS SETOF int
 *   delete_building(pid int, objclass_id int) RETURNS int
-*   delete_buildings(pids int[], objclass_ids int[]) RETURNS SETOF int
+*   delete_building(pids int[], objclass_ids int[]) RETURNS SETOF int
 *   delete_building_furniture(pid int, objclass_id int) RETURNS int
 *   delete_building_furniture(pids int[], objclass_ids int[]) RETURNS SETOF int
 *   delete_building_installation(pid int, objclass_id int) RETURNS int

  SELECT
    array_agg(waterboundary_surface_id)
  INTO
    waterboundary_sur_ids
  FROM
    delete_waterboundary_sur_refs;

  -- delete waterboundary_surface(s) not being referenced any more
  IF -1 = ALL(waterboundary_sur_ids) IS NOT NULL THEN
    PERFORM
      delete_waterbnd_surface(array_agg(a.a_id))
    FROM
      (SELECT DISTINCT unnest(waterboundary_sur_ids) AS a_id) a
    LEFT JOIN
      waterbod_to_waterbnd_srf n1
      ON n1.waterboundary_surface_id = a.a_id

  SELECT
    array_agg(waterboundary_surface_id)
  INTO
    waterboundary_srf_ids
  FROM
    delete_waterboundary_sur_refs;

  -- delete waterboundary_surface(s) not being referenced any more
  IF -1 = ALL(waterboundary_srf_ids) IS NOT NULL THEN
    PERFORM
      delete_waterbnd_surface(array_agg(a.a_id))
    FROM
      (SELECT DISTINCT unnest(waterboundary_srf_ids) AS a_id) a
    LEFT JOIN
      waterbod_to_waterbnd_srf n1
      ON n1.waterboundary_surface_id = a.a_id
