Created
December 7, 2016 10:50
-
-
Save Suor/2623bb8ef65a63972fd21af3713ede90 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Возвращает уникальные элементы массива, порядок не сохраняет | |
create or replace function array_uniq(anyarray) returns anyarray as $$ | |
select array(select distinct unnest($1)) | |
$$ language sql immutable strict; | |
-- Аггрегирующая функция для конкатенации массивов | |
create aggregate array_concat ( | |
sfunc = array_cat, | |
basetype = anyarray, | |
stype = anyarray, | |
initcond = '{}' | |
); | |
-- Аггрегирующая функция для конкатенации массивов с сохранением только уникальных элементов, порядок не сохраняется | |
create aggregate array_concat_uniq ( | |
sfunc = array_cat, | |
finalfunc = array_uniq, | |
basetype = anyarray, | |
stype = anyarray, | |
initcond = '{}' | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment