ORDER BY clause in aggregate doesn't work well with multi argument aggregates - Mailing list pgsql-hackers

From Pavel Stehule
Subject ORDER BY clause in aggregate doesn't work well with multi argument aggregates
Date
Msg-id 162867790912251040q5bb0e4bfrf777b9305a601300@mail.gmail.com
Whole thread Raw
Responses Re: ORDER BY clause in aggregate doesn't work well with multi argument aggregates
List pgsql-hackers
Hello

It is maybe a bug. I cannot use ORDER BY clause in two parameter aggregate.

create aggregate la(text, text) (SFUNC=listagg2_transfn,
STYPE=internal, FINALFUNC=listagg_finalfn);

postgres=# select la(town,',') from country;             la
-------------------------------Prague,Brno,Bratislava,Kosice
(1 row)

but when I add ORDER BY clause

postgres=# select la(town order by town,',') from country;
ERROR:  function la(character varying) does not exist
LINE 1: select la(town order by town,',') from country;              ^
HINT:  No function matches the given name and argument types. You
might need to add explicit type casts.
postgres=#

Probably it don't use correct count of parameters, because when I add
one parameter aggregate:

postgres=# create aggregate la(text) (SFUNC=listagg1_transfn,
STYPE=internal, FINALFUNC=listagg_finalfn);
CREATE AGGREGATE

postgres=# select la(town order by town,',') from country;            la
----------------------------BratislavaBrnoKosicePrague
(1 row)

Then it working, but it call wrong aggregates.

Regards
Pavel Stehule


pgsql-hackers by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: PQescapeByteaConn and the new hex encoding
Next
From: Tom Lane
Date:
Subject: Re: info about patch: using parametrised query in psql