Re: Function array_agg(array)

From: Ali Akbar <the(dot)apaan(at)gmail(dot)com>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Function array_agg(array)
Date: 2014-10-25 08:16:35
Message-ID: CACQjQLoaM9+7kfTzwDTjY=tvqmsdsMLaAY774kxBUu4qnMhqHg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>
> makeArrayResult1 - I have no better name now
>>
>> I found one next minor detail.
>>
>> you reuse a array_agg_transfn function. Inside is a message
>> "array_agg_transfn called in non-aggregate context". It is not correct for
>> array_agg_anyarray_transfn
>>
>
Fixed.

> probably specification dim and lbs in array_agg_finalfn is useless, when
>> you expect a natural result. A automatic similar to
>> array_agg_anyarray_finalfn should work there too.
>>
>> makeMdArrayResultArray and appendArrayDatum should be marked as "static"
>>
>
ok, marked all of that as static.

> I am thinking so change of makeArrayResult is wrong. It is developed for
> 1D array. When we expect somewhere ND result now, then we should to use
> makeMdArrayResult there. So makeArrayResult should to return 1D array in
> all cases. Else a difference between makeArrayResult and makeMdArrayResult
> hasn't big change and we have a problem with naming.
>

I'm thinking it like this:
- if we want to accumulate array normally, use accumArrayResult and
makeArrayResult. If we accumulate scalar the result will be 1D array. if we
accumulate array, the resulting dimension is incremented by 1.
- if we want, somehow to affect the normal behavior, and change the
dimensions, use makeMdArrayResult.

Searching through the postgres' code, other than internal use in
arrayfuncs.c, makeMdArrayResult is used only
in src/pl/plperl/plperl.c:plperl_array_to_datum, while converting perl
array to postgres array.

So if somehow we will accumulate array other than in array_agg, i think the
most natural way is using accumArrayResult and then makeArrayResult.

CMIIW

Regards,
--
Ali Akbar

Attachment Content-Type Size
array_agg_anyarray-10.patch text/x-patch 34.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2014-10-25 08:43:07 Re: Function array_agg(array)
Previous Message Pavel Stehule 2014-10-25 06:54:24 Re: Function array_agg(array)