Fix bug in pairingheap_SpGistSearchItem_cmp()
authorAlexander Korotkov <akorotkov@postgresql.org>
Tue, 24 Sep 2019 22:47:36 +0000 (01:47 +0300)
committerAlexander Korotkov <akorotkov@postgresql.org>
Tue, 24 Sep 2019 22:47:36 +0000 (01:47 +0300)
Our item contains only so->numberOfNonNullOrderBys of distances.  Reflect that
in the loop upper bound.

Discussion: https://postgr.es/m/53536807-784c-e029-6e92-6da802ab8d60%40postgrespro.ru
Author: Nikita Glukhov
Backpatch-through: 12

src/backend/access/spgist/spgscan.c

index cfba47067cc15f14cc0df0befe0fead35394d448..6e940fd3defdba1b7160d34cef28aa8929317fb9 100644 (file)
@@ -56,7 +56,7 @@ pairingheap_SpGistSearchItem_cmp(const pairingheap_node *a,
        else
        {
                /* Order according to distance comparison */
-               for (i = 0; i < so->numberOfOrderBys; i++)
+               for (i = 0; i < so->numberOfNonNullOrderBys; i++)
                {
                        if (isnan(sa->distances[i]) && isnan(sb->distances[i]))
                                continue;               /* NaN == NaN */