]> granicus.if.org Git - postgresql/commit
Fix pgstatindex() to give consistent results for empty indexes.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 25 Aug 2011 03:50:31 +0000 (23:50 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 25 Aug 2011 03:50:31 +0000 (23:50 -0400)
commit5fd3b6a705d62275fce82de85bce4376533b608f
tree06a8035ee0ccc3944ef9e7a14a919552929fb10d
parentf4fe6c643361670f085f4915ef05882810ffdee9
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.
contrib/pgstattuple/pgstatindex.c