From: | Maxim Boguk <maxim(dot)boguk(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Problem with custom aggregates and record pseudo-type |
Date: | 2011-12-01 19:51:15 |
Message-ID: | CAK-MWwQMQtGeBsaC7E-pD8sYjfdUdQexTRdF_t97HC10NFHsMA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Fri, Dec 2, 2011 at 3:19 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Maxim Boguk <maxim(dot)boguk(at)gmail(dot)com> writes:
> > I created special custom aggregate function to append arrays defined as:
> > CREATE AGGREGATE array_accum (anyarray)
> > (
> > sfunc = array_cat,
> > stype = anyarray,
> > initcond = '{}'
> > );
>
>
> > On arrays of common types it work without any problems:
> > SELECT array_accum(i) from (values (ARRAY[1,2]), (ARRAY[3,4])) as t(i);
> > array_accum
> > -------------
> > {1,2,3,4}
> > (1 row)
>
>
> > However once I try use it with record[] type I get an error:
> > SELECT array_accum(i) from (values (ARRAY[row(1,2),row(2,3)]),
> > (ARRAY[row(1,2),row(2,3)])) as t(i);
> > ERROR: cannot concatenate incompatible arrays
>
> Hm ... it looks like this case can be made to work with a simple adjustment
> to getTypeIOData, but in the meantime you might be able to get away with
> leaving the initial value as NULL (ie, leave off the initcond clause).
> The only behavioral difference would be that you'd get NULL not an empty
> array for zero rows of input.
>
> regards, tom lane
>
Thank you very much for an idea, you suggestiong work excellent as usual.
And again thank you for commiting a fix.
Kind Regards,
Maksym
From | Date | Subject | |
---|---|---|---|
Next Message | Lonni J Friedman | 2011-12-01 21:12:59 | returning rows from an implicit JOIN where results either exist in both tables OR only one table |
Previous Message | Red Light | 2011-12-01 19:36:44 | Re: recursive inner trigger call |