   FROM
     delete_objects;
 
-  -- delete citydb.implicit_geometry(s)
+  -- delete implicit_geometry(s)
   IF -1 = ALL(implicit_geometry_ids) IS NOT NULL THEN
     PERFORM
-      citydb.del_implicit_geometry(array_agg(a.a_id))
+      del_implicit_geometry(array_agg(a.a_id))
     FROM
       (SELECT DISTINCT unnest(implicit_geometry_ids) AS a_id) a
     LEFT JOIN
-      citydb.bridge_constr_element n1
+      bridge_constr_element n1
       ON n1.lod3_implicit_rep_id  = a.a_id
     LEFT JOIN
-      citydb.bridge_constr_element n2
+      bridge_constr_element n2
       ON n2.lod2_implicit_rep_id  = a.a_id
     LEFT JOIN
-      citydb.bridge_constr_element n3
+      bridge_constr_element n3
       ON n3.lod1_implicit_rep_id  = a.a_id
     LEFT JOIN
-      citydb.bridge_constr_element n4
+      bridge_constr_element n4
       ON n4.lod4_implicit_rep_id  = a.a_id
     LEFT JOIN
-      citydb.bridge_furniture n5
+      bridge_furniture n5
       ON n5.lod4_implicit_rep_id  = a.a_id
     LEFT JOIN
-      citydb.bridge_installation n6
+      bridge_installation n6
       ON n6.lod4_implicit_rep_id  = a.a_id
     LEFT JOIN
-      citydb.bridge_installation n7
+      bridge_installation n7
       ON n7.lod3_implicit_rep_id  = a.a_id
     LEFT JOIN
-      citydb.bridge_installation n8
+      bridge_installation n8
       ON n8.lod2_implicit_rep_id  = a.a_id
     LEFT JOIN
-      citydb.bridge_opening n9
+      bridge_opening n9
       ON n9.lod4_implicit_rep_id  = a.a_id
     LEFT JOIN
-      citydb.bridge_opening n10
+      bridge_opening n10
       ON n10.lod3_implicit_rep_id  = a.a_id
     LEFT JOIN
-      citydb.building_furniture n11
+      building_furniture n11
       ON n11.lod4_implicit_rep_id  = a.a_id
     LEFT JOIN
-      citydb.building_installation n12
+      building_installation n12
       ON n12.lod2_implicit_rep_id  = a.a_id
     LEFT JOIN
-      citydb.building_installation n13
+      building_installation n13
       ON n13.lod3_implicit_rep_id  = a.a_id
     LEFT JOIN
-      citydb.building_installation n14
+      building_installation n14
       ON n14.lod4_implicit_rep_id  = a.a_id
     LEFT JOIN
-      citydb.city_furniture n15
+      city_furniture n15
       ON n15.lod1_implicit_rep_id  = a.a_id
     LEFT JOIN
-      citydb.city_furniture n16
+      city_furniture n16
       ON n16.lod2_implicit_rep_id  = a.a_id
     LEFT JOIN
-      citydb.city_furniture n17
+      city_furniture n17
       ON n17.lod3_implicit_rep_id  = a.a_id
     LEFT JOIN
-      citydb.city_furniture n18
+      city_furniture n18
       ON n18.lod4_implicit_rep_id  = a.a_id
     LEFT JOIN
-      citydb.generic_cityobject n19
+      generic_cityobject n19
       ON n19.lod4_implicit_rep_id  = a.a_id
     LEFT JOIN
-      citydb.generic_cityobject n20
+      generic_cityobject n20
       ON n20.lod1_implicit_rep_id  = a.a_id
     LEFT JOIN
-      citydb.generic_cityobject n21
+      generic_cityobject n21
       ON n21.lod2_implicit_rep_id  = a.a_id
     LEFT JOIN
-      citydb.generic_cityobject n22
+      generic_cityobject n22
       ON n22.lod0_implicit_rep_id  = a.a_id
     LEFT JOIN
-      citydb.generic_cityobject n23
+      generic_cityobject n23
       ON n23.lod3_implicit_rep_id  = a.a_id
     LEFT JOIN
-      citydb.opening n24
+      opening n24
       ON n24.lod4_implicit_rep_id  = a.a_id
     LEFT JOIN
-      citydb.opening n25
+      opening n25
       ON n25.lod3_implicit_rep_id  = a.a_id
     LEFT JOIN
-      citydb.solitary_vegetat_object n26
+      solitary_vegetat_object n26
       ON n26.lod2_implicit_rep_id  = a.a_id
     LEFT JOIN
-      citydb.solitary_vegetat_object n27
+      solitary_vegetat_object n27
       ON n27.lod3_implicit_rep_id  = a.a_id
     LEFT JOIN
-      citydb.solitary_vegetat_object n28
+      solitary_vegetat_object n28
       ON n28.lod4_implicit_rep_id  = a.a_id
     LEFT JOIN
-      citydb.solitary_vegetat_object n29
+      solitary_vegetat_object n29
       ON n29.lod1_implicit_rep_id  = a.a_id
     LEFT JOIN
-      citydb.tunnel_furniture n30
+      tunnel_furniture n30
       ON n30.lod4_implicit_rep_id  = a.a_id
     LEFT JOIN
-      citydb.tunnel_installation n31
+      tunnel_installation n31
       ON n31.lod4_implicit_rep_id  = a.a_id
     LEFT JOIN
-      citydb.tunnel_installation n32
+      tunnel_installation n32
       ON n32.lod3_implicit_rep_id  = a.a_id
     LEFT JOIN
-      citydb.tunnel_installation n33
+      tunnel_installation n33
       ON n33.lod2_implicit_rep_id  = a.a_id
     LEFT JOIN
-      citydb.tunnel_opening n34
+      tunnel_opening n34
       ON n34.lod4_implicit_rep_id  = a.a_id
     LEFT JOIN
-      citydb.tunnel_opening n35
+      tunnel_opening n35
       ON n35.lod3_implicit_rep_id  = a.a_id
     WHERE n1.lod3_implicit_rep_id IS NULL
       AND n2.lod2_implicit_rep_id IS NULL

  FROM
    del_surface_data_refs;

  -- delete citydb.surface_data(s)
  IF -1 = ALL(surface_data_ids) IS NOT NULL THEN
    PERFORM
      citydb.del_surface_data(array_agg(a.a_id))
    FROM
      (SELECT DISTINCT unnest(surface_data_ids) AS a_id) a
    LEFT JOIN
      citydb.appear_to_surface_data n1
      ON n1.surface_data_id  = a.a_id
    WHERE n1.surface_data_id IS NULL;
  END IF;

  -- delete citydb.appearances
  WITH delete_objects AS (
    DELETE FROM
      citydb.appearance t
    USING
      unnest($1) a(a_id)
    WHERE

LANGUAGE plpgsql STRICT;
------------------------------------------

CREATE OR REPLACE FUNCTION del_tunnel_furniture(int[], caller INTEGER DEFAULT 0) RETURNS SETOF int AS
$body$
DECLARE
  deleted_ids int[] := '{}';
