]> git.openstreetmap.org Git - nominatim.git/blobdiff - sql/functions.sql
user-agent based blocking
[nominatim.git] / sql / functions.sql
index af9c47bbdcce5ed5fa555167f8f53143a01fff4d..6ad13892c6341646606a9166e60fe301424b05d4 100644 (file)
@@ -793,7 +793,7 @@ BEGIN
           linestr := linestr||','||ST_X(nextnode.geometry)||' '||ST_Y(nextnode.geometry);
           endnumber := ('0'||substring(nextnode.housenumber,'[0-9]+'))::integer;
 
-          IF startnumber IS NOT NULL and startnumber > 0 AND endnumber IS NOT NULL and endnumber > 0 THEN
+          IF startnumber IS NOT NULL and startnumber > 0 AND endnumber IS NOT NULL and endnumber > 0 AND @(startnumber - endnumber) < 1000 THEN
 
 --RAISE WARNING 'interpolation end % % ',nextnode.place_id,endnumber;
 
@@ -1217,9 +1217,9 @@ BEGIN
     RETURN NEW;
   END IF;
 
-  -- defered delete
+  -- deferred delete
   IF OLD.indexed_status = 100 THEN
-    delete from placex where osm_type = OLD.osm_type and osm_id = OLD.osm_id and class = OLD.class and type = OLD.type;
+    delete from placex where place_id = OLD.place_id;
     RETURN NULL;
   END IF;
 
@@ -1232,11 +1232,13 @@ BEGIN
       RETURN NEW;
     END IF;
 
-    result := deleteSearchName(NEW.partition, NEW.place_id);
-    DELETE FROM place_addressline WHERE place_id = NEW.place_id;
-    DELETE FROM place_boundingbox where place_id = NEW.place_id;
-    result := deleteRoad(NEW.partition, NEW.place_id);
-    result := deleteLocationArea(NEW.partition, NEW.place_id);
+    IF OLD.indexed_status > 1 THEN
+      result := deleteSearchName(NEW.partition, NEW.place_id);
+      DELETE FROM place_addressline WHERE place_id = NEW.place_id;
+      DELETE FROM place_boundingbox where place_id = NEW.place_id;
+      result := deleteRoad(NEW.partition, NEW.place_id);
+      result := deleteLocationArea(NEW.partition, NEW.place_id);
+    END IF;
 
     -- reclaculate country and partition (should probably have a country_code and calculated_country_code as seperate fields)
     SELECT country_code from place where osm_type = NEW.osm_type and osm_id = NEW.osm_id and class = NEW.class and type = NEW.type INTO NEW.country_code;