More missing docs (aggs)

Started by Josh Berkusover 19 years ago5 messagesdocs
Jump to latest
#1Josh Berkus
josh@agliodbs.com

Folks,

So I don't forget this:

The docs do not have an example of creating a multi-column aggregate,
and the syntax is NOT obvious. For example, what do you use for stype
in a multi-col aggregate?

--Josh

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Josh Berkus (#1)
Re: More missing docs (aggs)

Josh Berkus <josh@agliodbs.com> writes:

The docs do not have an example of creating a multi-column aggregate,

True...

and the syntax is NOT obvious. For example, what do you use for stype
in a multi-col aggregate?

Uh, why do you think that's significant? The stype is whatever you
need to use.

regards, tom lane

#3Josh Berkus
josh@agliodbs.com
In reply to: Tom Lane (#2)
Re: More missing docs (aggs)

Tom,

Uh, why do you think that's significant? The stype is whatever you
need to use.

Right, but do you have two stypes for a multi-col, a single stype, or a
composite stype? The docs don't say and it's not obvious.

--
Josh Berkus
PostgreSQL @ Sun
San Francisco

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Josh Berkus (#3)
Re: More missing docs (aggs)

Josh Berkus <josh@agliodbs.com> writes:

Uh, why do you think that's significant? The stype is whatever you
need to use.

Right, but do you have two stypes for a multi-col, a single stype, or a
composite stype? The docs don't say and it's not obvious.

There is only one transition state variable, as I should think would be
reasonably obvious from the wording:

An aggregate function is made from one or two ordinary functions: a
state transition function sfunc, and an optional final calculation
function ffunc. These are used as follows:

sfunc( internal-state, next-data-values ) ---> next-internal-state
ffunc( internal-state ) ---> aggregate-value

PostgreSQL creates a temporary variable of data type stype to hold
the current internal state of the aggregate. At each input row, the
aggregate argument value(s) are calculated and the state transition
function is invoked with the current state value and the new
argument value(s) to calculate a new internal state value.

Whether the state value is a composite type or not is up to the
aggregate author. There aren't any examples of using a composite type
in the docs, but there are examples of using an array as stype, so
I would hope that our users are bright enough to think of composites
when they need one.

regards, tom lane

#5Josh Berkus
josh@agliodbs.com
In reply to: Tom Lane (#4)
Re: More missing docs (aggs)

Tom,

Whether the state value is a composite type or not is up to the
aggregate author. There aren't any examples of using a composite type
in the docs, but there are examples of using an array as stype, so
I would hope that our users are bright enough to think of composites
when they need one.

Aha, got it. OK, so this just needs a good example ... will try to think of
one.

--
Josh Berkus
PostgreSQL @ Sun
San Francisco