Skip to content

Open Infrastructure Map, a view of infrastructure data in OpenStreetMap

Limit the text length of integers we attempt to convert

Russ Garrett47bbb12eae88
diff --git a/schema/functions.sql b/schema/functions.sql
index fbe7133..58e2569 100644
--- a/schema/functions.sql
+++ b/schema/functions.sql
@@ -75,6 +75,7 @@ END
$$ LANGUAGE plpgsql;
-- Convert a text integer value into an integer.
+-- Only supports 9-decimal-digit positive integers
CREATE OR REPLACE FUNCTION convert_integer(value TEXT) RETURNS INTEGER
IMMUTABLE
PARALLEL SAFE
@@ -83,7 +84,7 @@ AS $$
DECLARE
parts TEXT[];
BEGIN
- parts := regexp_matches(value, '^([0-9]+)$', '');
+ parts := regexp_matches(value, '^([0-9]{1,9})$', '');
RETURN parts[1];
END
$$ LANGUAGE plpgsql;