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