Fix handling Inf and Nan values in GiST pairing heap comparator

Alexander Korotkov <akorotkov@postgresql.org>

Commit: 986319d467cfefaa54b5cb72e063e28b66f04d42
Author: Alexander Korotkov <akorotkov@postgresql.org>
Date: 2019-09-08T18:49:15Z
Releases: 9.5.20
Fix handling Inf and Nan values in GiST pairing heap comparator

Previously plain float comparison was used in GiST pairing heap.  Such
comparison doesn't provide proper ordering for value sets containing Inf and Nan
values.  This commit fixes that by usage of float8_cmp_internal().  Note, there
is remaining problem with NULL distances, which are represented as Inf in
pairing heap.  It would be fixes in subsequent commit.

Backpatch to all supported versions.

Reported-by: Andrey Borodin
Discussion: https://postgr.es/m/CAPpHfdsNvNdA0DBS%2BwMpFrgwT6C3-q50sFVGLSiuWnV3FqOJuQ%40mail.gmail.com
Author: Alexander Korotkov
Reviewed-by: Heikki Linnakangas
Backpatch-through: 9.4

Files

PathChange+/−
src/backend/access/gist/gistscan.c modified +5 −2

Discussion