Re: aggregate of bitstrings

From: Joe Conway <mail(at)joeconway(dot)com>
To: tjo(at)acm(dot)org
Cc: "Florian G(dot) Pflug" <fgp(at)phlo(dot)org>, ggazan(at)ausd(dot)net, pgsql-general(at)postgresql(dot)org
Subject: Re: aggregate of bitstrings
Date: 2006-06-22 20:30:15
Message-ID: 449AFDD7.5060209@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

TJ O'Donnell wrote:
>
> maybe the aggregator (whoever,whatever that is) handles null args
> differently,
> not calling the func when the arg is null?

see:

http://www.postgresql.org/docs/8.1/interactive/sql-createaggregate.html

specifically:

"If the state transition function is declared "strict", then it cannot
be called with null inputs. With such a transition function, aggregate
execution behaves as follows. Null input values are ignored (the
function is not called and the previous state value is retained). If the
initial state value is null, then the first nonnull input value replaces
the state value, and the transition function is invoked beginning with
the second nonnull input value. This is handy for implementing
aggregates like max. Note that this behavior is only available when
state_data_type is the same as input_data_type. When these types are
different, you must supply a nonnull initial condition or use a
nonstrict transition function.

If the state transition function is not strict, then it will be called
unconditionally at each input value, and must deal with null inputs and
null transition values for itself. This allows the aggregate author to
have full control over the aggregate's handling of null values.

If the final function is declared "strict", then it will not be called
when the ending state value is null; instead a null result will be
returned automatically. (Of course this is just the normal behavior of
strict functions.) In any case the final function has the option of
returning a null value. For example, the final function for avg returns
null when it sees there were zero input rows."

HTH,

Joe

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2006-06-22 20:35:33 Re: auto-vacuum & Negative "anl" Values
Previous Message Jim Nasby 2006-06-22 19:57:48 Re: Adding foreign key constraints without integrity