make sure array_merge() never returns null

This commit is contained in:
Sarah Hoffmann
2026-01-07 10:22:03 +01:00
parent a4a2176ded
commit 9ac5e0256d

View File

@@ -2,7 +2,7 @@
-- --
-- This file is part of Nominatim. (https://nominatim.org) -- This file is part of Nominatim. (https://nominatim.org)
-- --
-- Copyright (C) 2025 by the Nominatim developer community. -- Copyright (C) 2026 by the Nominatim developer community.
-- For a full list of authors see the git log. -- For a full list of authors see the git log.
-- Assorted helper functions for the triggers. -- Assorted helper functions for the triggers.
@@ -46,13 +46,13 @@ DECLARE
r INTEGER[]; r INTEGER[];
BEGIN BEGIN
IF array_upper(a, 1) IS NULL THEN IF array_upper(a, 1) IS NULL THEN
RETURN b; RETURN COALESCE(b, '{}'::INTEGER[]);
END IF; END IF;
IF array_upper(b, 1) IS NULL THEN IF array_upper(b, 1) IS NULL THEN
RETURN a; RETURN COALESCE(a, '{}'::INTEGER[]);
END IF; END IF;
r := a; r := a;
FOR i IN 1..array_upper(b, 1) LOOP FOR i IN 1..array_upper(b, 1) LOOP
IF NOT (ARRAY[b[i]] <@ r) THEN IF NOT (ARRAY[b[i]] <@ r) THEN
r := r || b[i]; r := r || b[i];
END IF; END IF;