diff --git a/src/backend/access/gist/gistproc.c b/src/backend/access/gist/gistproc.c index d474612b77..19a7d5ef2b 100644 --- a/src/backend/access/gist/gistproc.c +++ b/src/backend/access/gist/gistproc.c @@ -1237,11 +1237,15 @@ computeDistance(bool isLeaf, BOX *box, Point *point) else if (point->x <= box->high.x && point->x >= box->low.x) { /* point is over or below box */ - Assert(box->low.y <= box->high.y); + Assert(box->low.y <= box->high.y + || isnan(box->low.y) || isnan(box->high.y)); + if (point->y > box->high.y) result = float8_mi(point->y, box->high.y); else if (point->y < box->low.y) result = float8_mi(box->low.y, point->y); + else if (isnan(point->y) || isnan(box->high.y) || isnan(box->low.y)) + result = get_float8_nan(); else elog(ERROR, "inconsistent point values"); }