tmp commit

This commit is contained in:
John Krauss
2016-09-19 16:08:37 +00:00
parent c9e809c061
commit 18cfdc60d0
2 changed files with 320 additions and 1 deletions
+17
View File
@@ -203,3 +203,20 @@ BEGIN
RETURN result;
END;
$$ LANGUAGE plpgsql;
-- Create a function that always returns the first non-NULL item
CREATE OR REPLACE FUNCTION public.first_agg ( anyelement, anyelement )
RETURNS anyelement LANGUAGE SQL IMMUTABLE STRICT AS $$
SELECT $1;
$$;
DROP AGGREGATE IF EXISTS public.FIRST (anyelement);
-- And then wrap an aggregate around it
CREATE AGGREGATE public.FIRST (
sfunc = public.first_agg,
basetype = anyelement,
stype = anyelement
);