diff --git a/doc/src/sgml/xaggr.sgml b/doc/src/sgml/xaggr.sgml
index 15ef46cc1e7..d050d876de7 100644
--- a/doc/src/sgml/xaggr.sgml
+++ b/doc/src/sgml/xaggr.sgml
@@ -70,7 +70,7 @@ SELECT sum(a) FROM test_complex;
expects sum to behave that way. We can do this simply by
omitting the initcond phrase, so that the initial state
condition is null. Ordinarily this would mean that the sfunc
- would need to check for a null state-condition input, but for
+ would need to check for a null state-condition input. But for
sum and some other simple aggregates like
max> and min>,
it is sufficient to insert the first nonnull input value into
@@ -95,8 +95,8 @@ SELECT sum(a) FROM test_complex;
It requires
two pieces of running state: the sum of the inputs and the count
of the number of inputs. The final result is obtained by dividing
- these quantities. Average is typically implemented by using a
- two-element array as the state value. For example,
+ these quantities. Average is typically implemented by using an
+ array as the state value. For example,
the built-in implementation of avg(float8)
looks like:
@@ -106,9 +106,14 @@ CREATE AGGREGATE avg (float8)
sfunc = float8_accum,
stype = float8[],
finalfunc = float8_avg,
- initcond = '{0,0,0}'
+ initcond = '{0,0}'
);
+
+ (float8_accum> requires a three-element array, not just
+ two elements, because it accumulates the sum of squares as well as
+ the sum and count of the inputs. This is so that it can be used for
+ some other aggregates besides avg>.)