pgsql: Fix pgstatindex() to give consistent results for empty indexes.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix pgstatindex() to give consistent results for empty indexes.
Date: 2011-08-25 03:51:08
Message-ID: E1QwQyC-0003LY-HP@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix pgstatindex() to give consistent results for empty indexes.

For an empty index, the pgstatindex() function would compute 0.0/0.0 for
its avg_leaf_density and leaf_fragmentation outputs. On machines that
follow the IEEE float arithmetic standard with any care, that results in
a NaN. However, per report from Rushabh Lathia, Microsoft couldn't
manage to get this right, so you'd get a bizarre error on Windows.

Fix by forcing the results to be NaN explicitly, rather than relying on
the division operator to give that or the snprintf function to print it
correctly. I have some doubts that this is really the most useful
definition, but it seems better to remain backward-compatible with
those platforms for which the behavior wasn't completely broken.

Back-patch to 8.2, since the code is like that in all current releases.

Branch
------
REL8_3_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/5fd3b6a705d62275fce82de85bce4376533b608f

Modified Files
--------------
contrib/pgstattuple/pgstatindex.c | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2011-08-25 04:06:31 pgsql: Add a regression test for pgstattuple.
Previous Message Alvaro Herrera 2011-08-24 21:35:15 pgsql: Update FK alternative test output to new whitespace rules