Re: array functions - request for opinions (was Re: [PATCHES] - Mailing list pgsql-hackers

From Joe Conway
Subject Re: array functions - request for opinions (was Re: [PATCHES]
Date
Msg-id 3ED22D99.40902@joeconway.com
Whole thread Raw
In response to Re: array functions - request for opinions (was Re: [PATCHES] array  (Peter Eisentraut <peter_e@gmx.net>)
Responses Re: array functions - request for opinions (was Re: [PATCHES]  (Andreas Pflug <Andreas.Pflug@web.de>)
Re: array functions - request for opinions (was Re: [PATCHES] array  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Peter Eisentraut wrote:
> Joe Conway writes:
>>There are many discussions on the lists over the past few years in which
>>people have requested this kind of functionality. There is even a
>>contrib/intagg that does this for integers only. I don't think there is
>>any question that there is a demand for the feature. Some examples:
> 
> These applications should use an empty array as initial value.  Then the
> normal array concatenation can be used as transition function.

How can you create an aggregate using an operator as a transition function?

=# CREATE AGGREGATE myagg
-# (
(#   BASETYPE = text,
(#   SFUNC = '||',
(#   STYPE = text,
(#   INITCOND = ''
(# );
ERROR:  AggregateCreate: function ||(text, text) does not exist

Also (I suppose you could argue this should be fixed, but anyway...), 
you can't currently add elements to an empty array.

regression=# create table t(f float8[]);
CREATE TABLE
regression=# insert into t values('{}');
INSERT 1865486 1
regression=# update t set f[1] = 1;
ERROR:  Invalid array subscripts
regression=# select array_dims(f) from t; array_dims
------------

(1 row)

Joe



pgsql-hackers by date:

Previous
From: Alvaro Herrera Munoz
Date:
Subject: Re: Bug(s) or not?
Next
From: Joe Conway
Date:
Subject: Re: IS OF