Re: Function array_agg(array)

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Ali Akbar <the(dot)apaan(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-24 18:51:01
Message-ID: CAFj8pRAo4d9UBxSirR14yQdaOmV4issy2WDZvZiqNucD_zpzcQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Ali

I checked a code. I am thinking so code organization is not good.
accumArrayResult is too long now. makeMdArrayResult will not work, when
arrays was joined (it is not consistent now). I don't like a usage of
state->is_array_accum in array_userfunc.c -- it is signal of wrong
wrapping.

next question: there is function array_append(anyarray, anyelement). Isn't
time to define array_append(anyarray, anyarray) now?

Regards

Pavel

2014-10-24 15:05 GMT+02:00 Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>:

>
>
> 2014-10-24 13:58 GMT+02:00 Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>:
>
>>
>>
>> 2014-10-24 11:43 GMT+02:00 Ali Akbar <the(dot)apaan(at)gmail(dot)com>:
>>
>>>
>>> 2014-10-24 16:26 GMT+07:00 Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>:
>>>
>>>> Hi
>>>>
>>>> some in last patch is wrong, I cannot to compile it:
>>>>
>>>> arrayfuncs.c: In function ‘accumArrayResult’:
>>>> arrayfuncs.c:4603:9: error: ‘ArrayBuildState’ has no member named ‘alen’
>>>> astate->alen = 64; /* arbitrary starting array size */
>>>> ^
>>>> arrayfuncs.c:4604:9: error: ‘ArrayBuildState’ has no member named
>>>> ‘dvalues’
>>>> astate->dvalues = (Datum *) palloc(astate->alen * sizeof(Datum));
>>>> ^
>>>> arrayfuncs.c:4604:44: error: ‘ArrayBuildState’ has no member named
>>>> ‘alen’
>>>> astate->dvalues = (Datum *) palloc(astate->alen * sizeof(Datum));
>>>> ^
>>>> arrayfuncs.c:4605:9: error: ‘ArrayBuildState’ has no member named
>>>> ‘dnulls’
>>>> astate->dnulls = (bool *) palloc(astate->alen * sizeof(bool));
>>>> ^
>>>> arrayfuncs.c:4605:42: error: ‘ArrayBuildState’ has no member named
>>>> ‘alen’
>>>> astate->dnulls = (bool *) palloc(astate->alen * sizeof(bool));
>>>> ^
>>>> arrayfuncs.c:4606:9: error: ‘ArrayBuildState’ has no member named
>>>> ‘nelems’
>>>> astate->nelems = 0;
>>>> ^
>>>> arrayfuncs.c:4618:13: error: ‘ArrayBuildState’ has no member named
>>>> ‘nelems’
>>>> if (astate->nelems >= astate->alen)
>>>> ^
>>>> arrayfuncs.c:4618:31: error: ‘ArrayBuildState’ has no member named
>>>> ‘alen’
>>>> if (astate->nelems >= astate->alen)
>>>> ^
>>>> arrayfuncs.c:4620:10: error: ‘ArrayBuildState’ has no member named
>>>> ‘alen’
>>>> astate->alen *= 2;
>>>>
>>>
>>> Sorry, correct patch attached.
>>>
>>> This patch is in patience format (git --patience ..). In previous
>>> patches, i use context format (git --patience ... | filterdiff
>>> --format=context), but it turns out that some modification is lost.
>>>
>>
>> last version is compileable, but some is still broken
>>
>> postgres=# select array_agg(array[i, i+1, i-1])
>> from generate_series(1,2) a(i);
>> ERROR: could not find array type for data type integer[]
>>
>
> I am sorry, it works - I had a problem with broken database
>
> I fixed small issue in regress tests and I enhanced tests for varlena
> types and null values.
>
> Regards
>
> Pavel
>
>
>>
>> but array(subselect) works
>>
>> postgres=# select array(select a from xx);
>> array
>> -------------------
>> {{1,2,3},{1,2,3}}
>> (1 row)
>>
>> Regards
>>
>> Pavel
>>
>>
>>
>>>
>>> --
>>> Ali Akbar
>>>
>>
>>
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Florian Pflug 2014-10-24 18:58:42 Re: Question about RI checks
Previous Message Robert Haas 2014-10-24 18:28:27 Re: How ugly would this be? (ALTER DATABASE)