X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 866C75E4244 for ; Fri, 6 Aug 2004 11:30:10 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 79935-03 for ; Fri, 6 Aug 2004 14:30:11 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 5C4595E4249 for ; Fri, 6 Aug 2004 11:30:04 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i76EU6uG011624; Fri, 6 Aug 2004 10:30:08 -0400 (EDT) To: Stephan Szabo Cc: Ram Nathaniel , pgsql-sql@postgresql.org Subject: Re: SQL syntax extentions - to put postgres ahead in the race In-reply-to: <8583.1091776047@sss.pgh.pa.us> References: <20040805220147.O92438@megazone.bigpanda.com> <8583.1091776047@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Fri, 06 Aug 2004 03:07:27 -0400" Date: Fri, 06 Aug 2004 10:30:06 -0400 Message-ID: <11623.1091802606@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200408/39 X-Sequence-Number: 18536 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