Fix handling of NULL distances in KNN-GiST

Alexander Korotkov <akorotkov@postgresql.org>

Commit: a5431b7d5f6bcccd1fc69c4e4ae6e4d5f39b83f8
Author: Alexander Korotkov <akorotkov@postgresql.org>
Date: 2019-09-08T18:48:45Z
Releases: 9.6.16
Fix handling of NULL distances in KNN-GiST

In order to implement NULL LAST semantic GiST previously assumed distance to
the NULL value to be Inf.  However, our distance functions can return Inf and
NaN for non-null values.  In such cases, NULL LAST semantic appears to be
broken.  This commit fixes that by introducing separate array of null flags for
distances.

Backpatch to all supported versions.

Discussion: https://postgr.es/m/CAPpHfdsNvNdA0DBS%2BwMpFrgwT6C3-q50sFVGLSiuWnV3FqOJuQ%40mail.gmail.com
Author: Alexander Korotkov
Backpatch-through: 9.4

Files

Discussion