Re: aggregate of bitstrings

Поиск
Список
Период
Сортировка
От Joe Conway
Тема Re: aggregate of bitstrings
Дата
Msg-id 449AFDD7.5060209@joeconway.com
обсуждение исходный текст
Ответ на aggregate of bitstrings  (TJ O'Donnell <tjo@acm.org>)
Список 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

В списке pgsql-general по дате отправления:

Предыдущее
От: "Guy Rouillier"
Дата:
Сообщение: Re: sql question; checks if data already exists before inserted
Следующее
От: Tom Lane
Дата:
Сообщение: Re: auto-vacuum & Negative "anl" Values