X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/b4e6d72fde248153207b0b311af4f46ee30e5e52..c5fe2ac2067c7154370c3abd6ccca45b0d657547:/lib/setup/SetupClass.php diff --git a/lib/setup/SetupClass.php b/lib/setup/SetupClass.php index 34ece8e0..100e3847 100755 --- a/lib/setup/SetupClass.php +++ b/lib/setup/SetupClass.php @@ -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');