Re: [HACKERS] array_accum aggregate

From: Stephen Frost <sfrost(at)snowman(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Martijn van Oosterhout <kleptog(at)svana(dot)org>, pgsql-hackers(at)postgresql(dot)org, Neil Conway <neilc(at)samurai(dot)com>, pgsql-patches(at)postgresql(dot)org, Joe Conway <mail(at)joeconway(dot)com>
Subject: Re: [HACKERS] array_accum aggregate
Date: 2006-10-13 15:33:43
Message-ID: 20061013153343.GK24675@kenobi.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

* Tom Lane (tgl(at)sss(dot)pgh(dot)pa(dot)us) wrote:
> That's not really the flavor of solution I'd like to have. Ideally,
> it'd actually *work* to write
>
> my_ffunc(my_sfunc(my_sfunc(null, 1), 2))
>
> and get the same result as aggregating over the values 1 and 2. The
> trick is to make sure that my_sfunc and my_ffunc can only be used
> together. Maybe we do need a type for each such aggregate ...

In general I like this idea but there are some complications, the main
one being where would the memory be allocated? I guess we could just
always use the QueryContext. The other issue is, in the above scenario
is it acceptable to modify the result of my_sfunc(null, 1) in the ,2
call? Normally it's unacceptable to modify your input, aggregates get a
special exception when called as an aggregate, but in this case you'd
have to copy the entire custom structure underneath, I'd think.

As for a type for each such aggregate, that seems reasonable to me,
honestly. I'd like for the type creation to be reasonably simple
though, if possible. ie: could we just provide NULLs for the
input/output functions instead of having to implement functions that
just return an error? Or perhaps have a polymorphic function which can
be reused that just returns an error. Additionally, we'd have to be
able to mark the types as being polymorhpic along the same lines as
anyelement/anyarray. Hopefully that's already easy, but if not it'd be
nice if it could be made easy...

Thanks,

Stephen

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Merlin Moncure 2006-10-13 15:35:22 Re: more anti-postgresql FUD
Previous Message Alvaro Herrera 2006-10-13 15:25:28 Re: ./configure argument checking

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2006-10-13 16:02:02 Re: [HACKERS] array_accum aggregate
Previous Message Bruce Momjian 2006-10-13 14:19:27 Re: test_fsync on MinGW(win32)