Provide moving-aggregate support for a bunch of numerical aggregates

Enterprise / PostgreSQL - Tom Lane [sss.pgh.pa.us] - 12 April 2014 19:33 UTC

First installment of the promised moving-aggregate support in built-in aggregates: count(), sum(), avg(), stddev() and variance() for assorted datatypes, though not for float4/float8.

In passing, remove a 2001-vintage kluge in interval_accum(): interval array elements have been properly aligned since around 2003, but nobody remembered to take out this workaround. Also, fix a thinko in the opr_sanity tests for moving-aggregate catalog entries.

David Rowley and Florian Pflug, reviewed by Dean Rasheed

9d229f3 Provide moving-aggregate support for a bunch of numerical aggregates.
src/backend/utils/adt/int8.c | 63 +++-
src/backend/utils/adt/numeric.c | 379 +++++++++++++++++++++---
src/backend/utils/adt/timestamp.c | 72 +++--
src/include/catalog/catversion.h | 2 +-
src/include/catalog/pg_aggregate.h | 266 ++++++++---------
src/include/catalog/pg_proc.h | 20 ++
src/include/utils/builtins.h | 7 +
src/include/utils/int8.h | 2 +
src/include/utils/timestamp.h | 1 +
src/test/regress/expected/opr_sanity.out | 12 +-
src/test/regress/expected/window.out | 475 ++++++++++++++++++++++++++++++
src/test/regress/sql/opr_sanity.sql | 12 +-
src/test/regress/sql/window.sql | 141 +++++++++
13 files changed, 1230 insertions(+), 222 deletions(-)

Upstream: git.postgresql.org


  • Share