Testing v1.7: Reverse engineering of multiparameter aggregate functions fails

From: Leszek Trenkner <olaf(at)post(dot)pl>
To: pgadmin-hackers(at)postgresql(dot)org
Subject: Testing v1.7: Reverse engineering of multiparameter aggregate functions fails
Date: 2007-05-23 23:39:01
Message-ID: 5ced0$4654d095$594f4043$24425@news.chello.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-hackers

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

Responses

Browse pgadmin-hackers by date

  From Date Subject
Next Message Leszek Trenkner 2007-05-24 00:21:22 Re: Testing v1.7: Server restart/crash crashes pgAdmin
Previous Message svn 2007-05-23 21:59:54 SVN Commit by guillaume: r6320 - trunk/pgadmin3/pgadmin/ui