schemas/_regproc.postgres.sql
changeset 9364 73bd5012336f
parent 4321 80b455066c9a
child 9419 3e6a1791339d
--- a/schemas/_regproc.postgres.sql	Tue Jan 07 15:48:31 2014 +0100
+++ b/schemas/_regproc.postgres.sql	Thu Nov 14 12:26:29 2013 +0100
@@ -10,10 +10,15 @@
     SELECT array_to_string($1, ', ')
 $$ LANGUAGE SQL;;
 
+
+CREATE FUNCTION cw_array_append_unique (anyarray, anyelement) RETURNS anyarray AS $$
+    SELECT array_append($1, (SELECT $2 WHERE $2 <> ALL($1)))
+$$ LANGUAGE SQL
+
 DROP AGGREGATE IF EXISTS group_concat (anyelement) CASCADE;
 CREATE AGGREGATE group_concat (
   basetype = anyelement,
-  sfunc = array_append,
+  sfunc = cw_array_append_unique,
   stype = anyarray,
   finalfunc = comma_join,
   initcond = '{}'