ORDER BY clause in aggregate doesn't work well with multi argument aggregates

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: ORDER BY clause in aggregate doesn't work well with multi argument aggregates
Date: 2009-12-25 18:40:53
Message-ID: 162867790912251040q5bb0e4bfrf777b9305a601300@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2009-12-25 18:41:06 Re: info about patch: using parametrised query in psql
Previous Message Andrew Dunstan 2009-12-25 18:36:38 Re: PQescapeByteaConn and the new hex encoding