]> git.openstreetmap.org Git - nominatim.git/blobdiff - nominatim/tools/check_database.py
Merge pull request #2293 from darkshredder/update-manpage
[nominatim.git] / nominatim / tools / check_database.py
index e99a3572d49553b28eee6ca3b14f7baf93c55fa7..00393d15d09dd5729becce61db687c9881376990 100644 (file)
@@ -6,8 +6,8 @@ from textwrap import dedent
 
 import psycopg2
 
-from ..db.connection import connect
-from ..errors import UsageError
+from nominatim.db.connection import connect
+from nominatim.errors import UsageError
 
 CHECKLIST = []
 
@@ -60,7 +60,7 @@ def check_database(config):
     """ Run a number of checks on the database and return the status.
     """
     try:
-        conn = connect(config.get_libpq_dsn())
+        conn = connect(config.get_libpq_dsn()).connection
     except UsageError as err:
         conn = _BadConnection(str(err))
 
@@ -70,7 +70,7 @@ def check_database(config):
         if ret == CheckState.FATAL:
             conn.close()
             return 1
-        if ret != CheckState.OK:
+        if ret in (CheckState.FATAL, CheckState.FAIL):
             overall_result = 1
 
     conn.close()
@@ -84,7 +84,7 @@ def _get_indexes(conn):
                'idx_placex_rank_address',
                'idx_placex_parent_place_id',
                'idx_placex_geometry_reverse_lookuppolygon',
-               'idx_placex_geometry_reverse_placenode',
+               'idx_placex_geometry_placenode',
                'idx_osmline_parent_place_id',
                'idx_osmline_parent_osm_id',
                'idx_postcode_id',
@@ -99,6 +99,9 @@ def _get_indexes(conn):
                         'idx_location_area_country_place_id',
                         'idx_place_osm_unique'
                        ))
+    if conn.server_version_tuple() >= (11, 0, 0):
+        indexes.extend(('idx_placex_housenumber',
+                        'idx_osmline_parent_osm_id_with_hnr'))
 
     return indexes
 
@@ -154,6 +157,7 @@ def check_placex_size(conn, config): # pylint: disable=W0613
 
     return CheckState.OK if cnt > 0 else CheckState.FATAL
 
+
 @_check(hint="""\
              The Postgresql extension nominatim.so was not correctly loaded.
 
@@ -198,13 +202,12 @@ def check_indexing(conn, config): # pylint: disable=W0613
         # Likely just an interrupted update.
         index_cmd = 'nominatim index'
     else:
-        # Looks like the import process got interupted.
+        # Looks like the import process got interrupted.
         index_cmd = 'nominatim import --continue indexing'
 
     return CheckState.FAIL, dict(count=cnt, index_cmd=index_cmd)
 
 
-
 @_check(hint="""\
              The following indexes are missing:
                {indexes}