Re: SQL syntax extentions - to put postgres ahead in the race

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
Cc: Ram Nathaniel <ram_nathaniel(at)hotmail(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: SQL syntax extentions - to put postgres ahead in the race
Date: 2004-08-06 14:30:06
Message-ID: 11623.1091802606@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 neighbor
more stuff
and 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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Gordon Ross 2004-08-06 15:29:19 Make a column case insensitive
Previous Message N. David 2004-08-06 14:02:35 New PHP + PostgreSQL group on Google Groups2