X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/c98e59be03a8ccf1a42c3ecb4ae21a7701cabfb3..ad89c1f0ca8ba72a820cbce244dc7e5a7a2d5a52:/sql/functions.sql

diff --git a/sql/functions.sql b/sql/functions.sql
index 03104dd5..4c679f3b 100644
--- a/sql/functions.sql
+++ b/sql/functions.sql
@@ -571,6 +571,20 @@ END;
 $$
 LANGUAGE plpgsql IMMUTABLE;
 
+CREATE OR REPLACE FUNCTION get_country_language_codes(search_country_code VARCHAR(2)) RETURNS TEXT[]
+  AS $$
+DECLARE
+  nearcountry RECORD;
+BEGIN
+  FOR nearcountry IN select country_default_language_codes from country_name where country_code = search_country_code limit 1
+  LOOP
+    RETURN lower(nearcountry.country_default_language_codes);
+  END LOOP;
+  RETURN NULL;
+END;
+$$
+LANGUAGE plpgsql IMMUTABLE;
+
 CREATE OR REPLACE FUNCTION get_partition(place geometry, in_country_code VARCHAR(10)) RETURNS INTEGER
   AS $$
 DECLARE
@@ -2157,7 +2171,9 @@ BEGIN
     END IF;
   END LOOP;
 
-  RETURN null;
+  -- anything will do as a fallback - just take the first name type thing there is
+  search := avals(name);
+  RETURN search[1];
 END;
 $$
 LANGUAGE plpgsql IMMUTABLE;
