pgsql: Implement width_bucket() for the float8 data type. - Mailing list pgsql-committers

From neilc@postgresql.org (Neil Conway)
Subject pgsql: Implement width_bucket() for the float8 data type.
Date
Msg-id 20070116214114.68E7F9FB319@postgresql.org
Whole thread Raw
List pgsql-committers
Log Message:
-----------
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.

Modified Files:
--------------
    pgsql/doc/src/sgml:
        func.sgml (r1.350 -> r1.351)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/doc/src/sgml/func.sgml.diff?r1=1.350&r2=1.351)
    pgsql/src/backend/utils/adt:
        float.c (r1.146 -> r1.147)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/utils/adt/float.c.diff?r1=1.146&r2=1.147)
        numeric.c (r1.98 -> r1.99)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/utils/adt/numeric.c.diff?r1=1.98&r2=1.99)
    pgsql/src/include/catalog:
        catversion.h (r1.371 -> r1.372)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/include/catalog/catversion.h.diff?r1=1.371&r2=1.372)
        pg_proc.h (r1.436 -> r1.437)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/include/catalog/pg_proc.h.diff?r1=1.436&r2=1.437)
    pgsql/src/include/utils:
        builtins.h (r1.285 -> r1.286)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/include/utils/builtins.h.diff?r1=1.285&r2=1.286)
    pgsql/src/test/regress/expected:
        numeric.out (r1.19 -> r1.20)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/test/regress/expected/numeric.out.diff?r1=1.19&r2=1.20)
    pgsql/src/test/regress/sql:
        numeric.sql (r1.12 -> r1.13)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/test/regress/sql/numeric.sql.diff?r1=1.12&r2=1.13)

pgsql-committers by date:

Previous
From: neilc@postgresql.org (Neil Conway)
Date:
Subject: pgsql: Minor improvements to the TODO list.
Next
From: neilc@postgresql.org (Neil Conway)
Date:
Subject: pgsql: vcbuild updates from Magnus: * After Markos patch, now builds