Re: [HACKERS] array_accum aggregate - Mailing list pgsql-patches

From Tom Lane
Subject Re: [HACKERS] array_accum aggregate
Date
Msg-id 29129.1160747769@sss.pgh.pa.us
Whole thread Raw
In response to Re: [HACKERS] array_accum aggregate  (Martijn van Oosterhout <kleptog@svana.org>)
Responses Re: [HACKERS] array_accum aggregate  (Stephen Frost <sfrost@snowman.net>)
List pgsql-patches
Martijn van Oosterhout <kleptog@svana.org> writes:
> What this really calls for is a type that users are forbidden to
> interact with directly. Basically, the type may only be used by C
> functions and such C functions may not appear in an SQL query.

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 any case, "internal" isn't quite the right model, because with that,
the type system is basically disclaiming all knowledge of the data's
properties.  With an "aggregate_state" datatype, the type system would
be asserting that it's OK to use this type (or more accurately, these
functions) in an aggregate.

            regards, tom lane

pgsql-patches by date:

Previous
From: Martijn van Oosterhout
Date:
Subject: Re: [HACKERS] array_accum aggregate
Next
From: Bruce Momjian
Date:
Subject: Re: test_fsync on MinGW(win32)