Hello,
I've found something missing in multiparameter aggregates SQL reverse-
engineering. I defined multiparameter aggregate function + aggregate
itself as:
Function:
CREATE OR REPLACE FUNCTION agg_text_sum(in_base TEXT, new_text TEXT,
separator TEXT) RETURNS TEXT AS $BODY$
DECLARE
BEGIN
IF in_base IS NULL THEN
RETURN new_text;
END IF;
RETURN in_base || separator || new_text;
END;
$BODY$ language 'plpgsql';
And aggregate:
CREATE aggregate sum(TEXT, TEXT) (
sfunc = agg_text_sum,
stype = TEXT
);
(SQL code from depesz.com) All goes well, aggregate works as expected
(think of it rather as PHP implode() than real sum()).
Unfortunately, SQL code of reverse engineered aggregate in pgAdmin3 1.7.0
(6301M) is as follows:
-- Aggregate: sum
-- DROP AGGREGATE sum(text);
CREATE AGGREGATE sum(
BASETYPE=text,
SFUNC=agg_text_sum,
STYPE=text
);
ALTER AGGREGATE sum(text) OWNER TO postgres;
It has lost one attribute, and so it is impossible to recreate aggregate
(as agg_text_sum function has 3 text attributes, not two as reverse-
engineered definiton requires). I guess pgAdmin needs to support newer
aggregate definition syntax...
--
Greetings,
Leszek Trenkner