]> git.openstreetmap.org Git - nominatim.git/commitdiff
setup: delete invalid indices in create-search-indices step
authormarc tobias <mtmail@gmx.net>
Sat, 8 Feb 2020 14:16:20 +0000 (15:16 +0100)
committermarc tobias <mtmail@gmx.net>
Sat, 8 Feb 2020 14:16:20 +0000 (15:16 +0100)
lib/setup/SetupClass.php

index 34ece8e0f7567d327793a002782c320fb2bcebca..100e384744d42f03f0342104c53017e7053c99cd 100755 (executable)
@@ -566,6 +566,15 @@ class SetupFunctions
     {
         info('Create Search indices');
 
+        $sSQL = 'SELECT relname FROM pg_class, pg_index ';
+        $sSQL .= 'WHERE pg_index.indisvalid = false AND pg_index.indexrelid = pg_class.oid';
+        $aInvalidIndices = $this->oDB->getCol($sSQL);
+
+        foreach ($aInvalidIndices as $sIndexName) {
+            info("Cleaning up invalid index $sIndexName");
+            $this->oDB->exec("DROP INDEX $sIndexName;");
+        }
+
         $sTemplate = file_get_contents(CONST_BasePath.'/sql/indices.src.sql');
         if (!$this->dbReverseOnly()) {
             $sTemplate .= file_get_contents(CONST_BasePath.'/sql/indices_search.src.sql');