0001-Add-psql-AM-info-commands-v10.patch
application/octet-stream
Filename: 0001-Add-psql-AM-info-commands-v10.patch
Type: application/octet-stream
Part: 0
Patch
Format: unified
Series: patch v10-0001
| File | + | − |
|---|---|---|
| src/backend/access/gist/gistscan.c | 4 | 2 |
| src/test/regress/expected/create_index.out | 5 | 5 |
commit f44601ab0bb3d8767783e8f9530f974256ac62ae
Author: Alexander Korotkov <akorotkov@postgresql.org>
Date: Mon Sep 2 07:36:35 2019 +0300
Fix handling Inf and Nan values in GiST pairing heap comparator
Reported-by:
Bug:
Discussion:
Author:
Reviewed-by:
Tested-by:
Backpatch-through:
diff --git a/src/backend/access/gist/gistscan.c b/src/backend/access/gist/gistscan.c
index 893d7765b6c..3bfeb18e2ed 100644
--- a/src/backend/access/gist/gistscan.c
+++ b/src/backend/access/gist/gistscan.c
@@ -17,6 +17,7 @@
#include "access/gist_private.h"
#include "access/gistscan.h"
#include "access/relscan.h"
+#include "utils/float.h"
#include "utils/lsyscache.h"
#include "utils/memutils.h"
#include "utils/rel.h"
@@ -36,8 +37,9 @@ pairingheap_GISTSearchItem_cmp(const pairingheap_node *a, const pairingheap_node
/* Order according to distance comparison */
for (i = 0; i < scan->numberOfOrderBys; i++)
{
- if (sa->distances[i] != sb->distances[i])
- return (sa->distances[i] < sb->distances[i]) ? 1 : -1;
+ int cmp = -float8_cmp_internal(sa->distances[i], sb->distances[i]);
+ if (cmp != 0)
+ return cmp;
}
/* Heap items go before inner pages, to ensure a depth-first search */
diff --git a/src/test/regress/expected/create_index.out b/src/test/regress/expected/create_index.out
index c6d575a2f99..117b11a1a63 100644
--- a/src/test/regress/expected/create_index.out
+++ b/src/test/regress/expected/create_index.out
@@ -523,16 +523,16 @@ SELECT * FROM point_tbl ORDER BY f1 <-> '0,1';
SELECT * FROM point_tbl ORDER BY f1 <-> '0,1';
f1
-------------------
- (10,10)
- (NaN,NaN)
(0,0)
(1e-300,-1e-300)
(-3,4)
(-10,0)
+ (10,10)
(-5,-12)
(5.1,34.5)
-
(1e+300,Infinity)
+
+ (NaN,NaN)
(10 rows)
EXPLAIN (COSTS OFF)
@@ -561,15 +561,15 @@ SELECT * FROM point_tbl WHERE f1 IS NOT NULL ORDER BY f1 <-> '0,1';
SELECT * FROM point_tbl WHERE f1 IS NOT NULL ORDER BY f1 <-> '0,1';
f1
-------------------
- (10,10)
- (NaN,NaN)
(0,0)
(1e-300,-1e-300)
(-3,4)
(-10,0)
+ (10,10)
(-5,-12)
(5.1,34.5)
(1e+300,Infinity)
+ (NaN,NaN)
(9 rows)
EXPLAIN (COSTS OFF)