X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/7da5196bac0e1d894dc22e7a0c923bfa809125f9..5d98c09ee9f4a16237fd93b759efbe920185db73:/lib/setup/SetupClass.php diff --git a/lib/setup/SetupClass.php b/lib/setup/SetupClass.php index dde834f7..f03085f8 100755 --- a/lib/setup/SetupClass.php +++ b/lib/setup/SetupClass.php @@ -230,7 +230,7 @@ class SetupFunctions $this->createSqlFunctions(); } - public function createTables() + public function createTables($bReverseOnly = false) { info('Create Tables'); @@ -268,6 +268,10 @@ class SetupFunctions ); $this->pgsqlRunScript($sTemplate, false); + + if ($bReverseOnly) { + $this->pgExec('DROP TABLE search_name'); + } } public function createPartitionTables() @@ -356,8 +360,10 @@ class SetupFunctions echo '.'; $this->pgExec('TRUNCATE location_area'); echo '.'; - $this->pgExec('TRUNCATE search_name'); - echo '.'; + if (!$this->dbReverseOnly()) { + $this->pgExec('TRUNCATE search_name'); + echo '.'; + } $this->pgExec('TRUNCATE search_name_blank'); echo '.'; $this->pgExec('DROP SEQUENCE seq_place'); @@ -608,6 +614,9 @@ class SetupFunctions info('Create Search indices'); $sTemplate = file_get_contents(CONST_BasePath.'/sql/indices.src.sql'); + if (!$this->dbReverseOnly()) { + $sTemplate .= file_get_contents(CONST_BasePath.'/sql/indices_search.src.sql'); + } $sTemplate = str_replace('{www-user}', CONST_Database_Web_User, $sTemplate); $sTemplate = $this->replaceTablespace( '{ts:address-index}', @@ -748,6 +757,10 @@ class SetupFunctions if (!CONST_Use_Aux_Location_data) { $sTemplate = str_replace('-- %NOAUXDATA% ', '', $sTemplate); } + + $sReverseOnly = $this->dbReverseOnly() ? 'true' : 'false'; + $sTemplate = str_replace('%REVERSE-ONLY%', $sReverseOnly, $sTemplate); + $this->pgsqlRunScript($sTemplate); } @@ -861,4 +874,15 @@ class SetupFunctions fail(pg_last_error($this->oDB->connection)); } } + + /** + * Check if the database is in reverse-only mode. + * + * @return True if there is no search_name table and infrastructure. + */ + private function dbReverseOnly() + { + $sSQL = "SELECT count(*) FROM pg_tables WHERE tablename = 'search_name'"; + return !(chksql($this->oDB->getOne($sSQL))); + } }