Implement width_bucket() for the float8 data type.
authorNeil Conway <neilc@samurai.com>
Tue, 16 Jan 2007 21:41:14 +0000 (21:41 +0000)
committerNeil Conway <neilc@samurai.com>
Tue, 16 Jan 2007 21:41:14 +0000 (21:41 +0000)
commitbcd997935a8d1ac3275c04b64eca18b8f8ab6be3
tree51755e35fd6376664fec22bcb982080e16cac4c5
parente1a3e2d1226b6ebb91a85b2cf7ac35056168c24c
Implement width_bucket() for the float8 data type.

The implementation is somewhat ugly logic-wise, but I don't see an
easy way to make it more concise.

When writing this, I noticed that my previous implementation of
width_bucket() doesn't handle NaN correctly:

    postgres=# select width_bucket('NaN', 1, 5, 5);
     width_bucket
    --------------
                6
    (1 row)

AFAICS SQL:2003 does not define a NaN value, so it doesn't address how
width_bucket() should behave here. The patch changes width_bucket() so
that ereport(ERROR) is raised if NaN is specified for the operand or the
lower or upper bounds to width_bucket(). For float8, NaN is disallowed
for any of the floating-point inputs, and +/- infinity is disallowed
for the histogram bounds (but allowed for the operand).

Update docs and regression tests, bump the catversion.
doc/src/sgml/func.sgml
src/backend/utils/adt/float.c
src/backend/utils/adt/numeric.c
src/include/catalog/catversion.h
src/include/catalog/pg_proc.h
src/include/utils/builtins.h
src/test/regress/expected/numeric.out
src/test/regress/sql/numeric.sql