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

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: SQL syntax extentions - to put postgres ahead in the race
Дата
Msg-id 11623.1091802606@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: SQL syntax extentions - to put postgres ahead in the race  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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 по дате отправления:

Предыдущее
От: Achilleus Mantzios
Дата:
Сообщение: Re: retrieve the tables names based on the owner
Следующее
От: "Gordon Ross"
Дата:
Сообщение: Make a column case insensitive