Re: SQL syntax extentions - to put postgres ahead in the race - Mailing list pgsql-sql

From Tom Lane
Subject Re: SQL syntax extentions - to put postgres ahead in the race
Date
Msg-id 11623.1091802606@sss.pgh.pa.us
Whole thread Raw
In response to Re: SQL syntax extentions - to put postgres ahead in the race  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-sql
I wrote:
> There's nothing particularly stopping us from supporting
> multiple-argument aggregates, except a lack of round tuits.

BTW, you can actually fake this pretty well in 8.0, by making an
aggregate that uses a rowtype input.  For example:

regression=# create type twostrings as (s1 text, s2 text);
CREATE TYPE
regression=# create function list_concat(text, twostrings) returns text as $$
regression$# select case when $1 is null then $2.s1
regression$# when $2.s1 is null then $1
regression$# else $1 || $2.s2 || $2.s1
regression$# end$$ language sql;
CREATE FUNCTION
regression=# create aggregate concat (
regression(# basetype = twostrings,
regression(# stype = text,
regression(# sfunc = list_concat);
CREATE AGGREGATE
regression=# select * from text_tbl;       f1
-------------------doh!hi de ho neighbormore stuffand more
(4 rows)

regression=# select concat((f1, '|')) from text_tbl;                  concat
--------------------------------------------doh!|hi de ho neighbor|more stuff|and more
(1 row)


This is somewhat inefficient compared to native support for
multi-argument aggregates, but at least we have something we can point
people to until we find time to make that happen.
        regards, tom lane


pgsql-sql by date:

Previous
From: Achilleus Mantzios
Date:
Subject: Re: retrieve the tables names based on the owner
Next
From: "Gordon Ross"
Date:
Subject: Make a column case insensitive