pgsql: Fix handling of NULL distances in KNN-GiST

From: Alexander Korotkov <akorotkov(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix handling of NULL distances in KNN-GiST
Date: 2019-09-08 19:30:34
Message-ID: E1i72tO-0001Or-Ls@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/02f90879e75b3d4ccdba1ec7c3cad6af08dff77d

Modified Files
--------------
src/backend/access/gist/gistget.c | 70 ++++++++++++++++++++----------
src/backend/access/gist/gistscan.c | 25 +++++++++--
src/backend/access/index/indexam.c | 14 ++++--
src/backend/access/spgist/spgscan.c | 1 +
src/include/access/genam.h | 4 +-
src/include/access/gist_private.h | 26 +++++++++--
src/test/regress/expected/create_index.out | 2 +-
7 files changed, 106 insertions(+), 36 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Alexander Korotkov 2019-09-08 19:30:44 pgsql: Fix handling Inf and Nan values in GiST pairing heap comparator
Previous Message Tom Lane 2019-09-08 17:45:48 pgsql: configure: Update python search order