Created
December 20, 2011 16:33
-
-
Save drogus/1502187 to your computer and use it in GitHub Desktop.
This file contains 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_array_agg_sfunc(state integer[][], p integer[]) RETURNS integer[][] AS $$ | |
BEGIN | |
IF p IS NULL THEN | |
RETURN state; | |
END IF; | |
IF array_dims(state) IS NULL THEN | |
RETURN ARRAY[p]; | |
END IF; | |
RETURN array_cat(state, p); | |
END; | |
$$ LANGUAGE plpgsql IMMUTABLE; | |
DROP AGGREGATE IF EXISTS array_array_agg(integer[]); | |
CREATE AGGREGATE array_array_agg ( | |
basetype = integer[][], | |
sfunc = array_array_agg_sfunc, | |
stype = integer[][], | |
initcond = '{}' | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment