From: marc tobias Date: Sat, 8 Feb 2020 14:16:20 +0000 (+0100) Subject: setup: delete invalid indices in create-search-indices step X-Git-Tag: v3.5.0~87^2 X-Git-Url: https://git.openstreetmap.org/nominatim.git/commitdiff_plain/540b12537a6cf34b3cb21886f17aff560dcd00c5 setup: delete invalid indices in create-search-indices step --- 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');