From: Sarah Hoffmann Date: Sun, 6 Jul 2014 19:05:16 +0000 (+0200) Subject: Merge remote-tracking branch 'upstream/master' X-Git-Tag: deploy~528 X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/d6f4448ed33298e563c520fc654fe5d445ff7f57?hp=f1cbca788531e9eefe5fbbadd7ac0d218f6aa076 Merge remote-tracking branch 'upstream/master' --- diff --git a/sql/functions.sql b/sql/functions.sql index 488d340f..d86f4a9b 100644 --- a/sql/functions.sql +++ b/sql/functions.sql @@ -1379,10 +1379,10 @@ BEGIN IF NEW.osm_type = 'R' and NEW.class = 'waterway' THEN FOR relation IN select * from planet_osm_rels r where r.id = NEW.osm_id LOOP - FOR i IN relation.way_off+1..relation.rel_off LOOP - IF relation.members[2*i] in ('', 'main_stream') THEN + FOR i IN 1..array_upper(relation.members, 1) BY 2 LOOP + IF relation.members[i+1] in ('', 'main_stream') AND substring(relation.members[i],1,1) = 'w' THEN --DEBUG: RAISE WARNING 'waterway parent %, child %/%', NEW.osm_id, i, relation.parts[i]; - FOR location IN SELECT * FROM placex WHERE osm_type = 'W' and osm_id = relation.parts[i] and class = NEW.class and type = NEW.type + FOR location IN SELECT * FROM placex WHERE osm_type = 'W' and osm_id = substring(relation.members[i],2,200)::bigint and class = NEW.class and type = NEW.type LOOP UPDATE placex SET linked_place_id = NEW.place_id WHERE place_id = location.place_id; END LOOP; diff --git a/sql/tiger_import_start.sql b/sql/tiger_import_start.sql index d9def2b4..a6f417f2 100644 --- a/sql/tiger_import_start.sql +++ b/sql/tiger_import_start.sql @@ -53,12 +53,12 @@ BEGIN END IF; place_centroid := ST_Centroid(linegeo); - out_partition := get_partition(place_centroid, 'us'); + out_partition := get_partition('us'); out_parent_place_id := null; address_street_word_id := get_name_id(make_standard_name(in_street)); IF address_street_word_id IS NOT NULL THEN - FOR location IN SELECT * from getNearestNamedRoadFeature(out_partition, place_centroid, address_street_word_id) LOOP + FOR location IN SELECT * from getNearestNamedRoadFeature(out_partition, place_centroid, ARRAY[address_street_word_id]) LOOP out_parent_place_id := location.place_id; END LOOP; END IF; diff --git a/utils/setup.php b/utils/setup.php index 734f669f..870d37ec 100755 --- a/utils/setup.php +++ b/utils/setup.php @@ -803,10 +803,6 @@ fclose($ahPipes[1]); $iReturn = proc_close($hProcess); - if ($iReturn > 0) - { - fail("pgsql returned with error code ($iReturn)"); - } } function pgsqlRunDropAndRestore($sDumpFile) @@ -835,10 +831,6 @@ fclose($ahPipes[1]); $iReturn = proc_close($hProcess); - if ($iReturn > 0) - { - fail("pgsql returned with error code ($iReturn)"); - } } function passthruCheckReturn($cmd) diff --git a/utils/update.php b/utils/update.php index ccf69300..a561aaa3 100755 --- a/utils/update.php +++ b/utils/update.php @@ -253,6 +253,13 @@ if ($aResult['deduplicate']) { + + $pgver = (float) CONST_Postgresql_Version; + if ($pgver < 9.3) { + echo "ERROR: deduplicate is only currently supported in postgresql 9.3"; + exit; + } + $oDB =& getDB(); $sSQL = 'select partition from country_name order by country_code'; $aPartitions = $oDB->getCol($sSQL); @@ -275,15 +282,15 @@ var_dump($aTokenSet, $sSQL); exit; } - + $aKeep = array_shift($aTokenSet); $iKeepID = $aKeep['word_id']; foreach($aTokenSet as $aRemove) { $sSQL = "update search_name set"; - $sSQL .= " name_vector = (name_vector - ".$aRemove['word_id'].")+".$iKeepID.","; - $sSQL .= " nameaddress_vector = (nameaddress_vector - ".$aRemove['word_id'].")+".$iKeepID; + $sSQL .= " name_vector = array_replace(name_vector,".$aRemove['word_id'].",".$iKeepID."),"; + $sSQL .= " nameaddress_vector = array_replace(nameaddress_vector,".$aRemove['word_id'].",".$iKeepID.")"; $sSQL .= " where name_vector @> ARRAY[".$aRemove['word_id']."]"; $x = $oDB->query($sSQL); if (PEAR::isError($x)) @@ -293,7 +300,7 @@ } $sSQL = "update search_name set"; - $sSQL .= " nameaddress_vector = (nameaddress_vector - ".$aRemove['word_id'].")+".$iKeepID; + $sSQL .= " nameaddress_vector = array_replace(nameaddress_vector,".$aRemove['word_id'].",".$iKeepID.")"; $sSQL .= " where nameaddress_vector @> ARRAY[".$aRemove['word_id']."]"; $x = $oDB->query($sSQL); if (PEAR::isError($x)) @@ -303,7 +310,7 @@ } $sSQL = "update location_area_country set"; - $sSQL .= " keywords = (keywords - ".$aRemove['word_id'].")+".$iKeepID; + $sSQL .= " keywords = array_replace(keywords,".$aRemove['word_id'].",".$iKeepID.")"; $sSQL .= " where keywords @> ARRAY[".$aRemove['word_id']."]"; $x = $oDB->query($sSQL); if (PEAR::isError($x)) @@ -315,8 +322,7 @@ foreach ($aPartitions as $sPartition) { $sSQL = "update search_name_".$sPartition." set"; - $sSQL .= " name_vector = (name_vector - ".$aRemove['word_id'].")+".$iKeepID.","; - $sSQL .= " nameaddress_vector = (nameaddress_vector - ".$aRemove['word_id'].")+".$iKeepID; + $sSQL .= " name_vector = array_replace(name_vector,".$aRemove['word_id'].",".$iKeepID.")"; $sSQL .= " where name_vector @> ARRAY[".$aRemove['word_id']."]"; $x = $oDB->query($sSQL); if (PEAR::isError($x)) @@ -325,18 +331,8 @@ exit; } - $sSQL = "update search_name_".$sPartition." set"; - $sSQL .= " nameaddress_vector = (nameaddress_vector - ".$aRemove['word_id'].")+".$iKeepID; - $sSQL .= " where nameaddress_vector @> ARRAY[".$aRemove['word_id']."]"; - $x = $oDB->query($sSQL); - if (PEAR::isError($x)) - { - var_dump($x); - exit; - } - $sSQL = "update location_area_country set"; - $sSQL .= " keywords = (keywords - ".$aRemove['word_id'].")+".$iKeepID; + $sSQL .= " keywords = array_replace(keywords,".$aRemove['word_id'].",".$iKeepID.")"; $sSQL .= " where keywords @> ARRAY[".$aRemove['word_id']."]"; $x = $oDB->query($sSQL); if (PEAR::isError($x))