pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andreas Seltenreich <seltenreich@gmx.de>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-hackers@postgreSQL.org
Subject: Re: GiST index build versus NaN coordinates
Date: Tue, 12 Jul 2016 09:20:17 +0200
Message-ID: <878tx7491q.fsf@credativ.de> (raw)
In-Reply-To: <28685.1468246504@sss.pgh.pa.us>
References: <28685.1468246504@sss.pgh.pa.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

Tom Lane writes:

> More generally, this example makes me fearful that NaN coordinates in
> geometric values are likely to cause all sorts of issues.  It's too late
> to disallow them, probably, but I wonder how can we identify other bugs
> of this ilk.

Sounds like some fuzz testing with nan/infinity is in order.  sqlsmith
doesn't generate any float literals, but it calls functions to satisfy
its need for values of specific types.  Adding suitable functions[1] to
the regression db, I made the following observations:

The infinite loop from the bug report was triggered. Further, two
previously unseen errors are logged:

    ERROR:  timestamp cannot be NaN
    ERROR:  getQuadrant: impossible case

The first is porbably as boring as it gets, the second one is from the
getQuadrant() in spgquadtreeproc.c.

Curiously, the getQuadrant()s in geo_spgist.c and rangetypes_spgist.c do
not have such a check.  I guess the boxes will just end up in an
undefined position in the index for these.

regards
Andreas

Footnotes:
[1]
create function smith_double_inf() returns float as $$select 'infinity'::float$$ language sql immutable;
create function smith_double_ninf() returns float as $$select '-infinity'::float$$ language sql immutable;
create function smith_double_nan() returns float as $$select 'nan'::float$$ language sql immutable;
create function smith_real_nan() returns real as $$select 'nan'::real$$ language sql immutable;
create function smith_real_inf() returns real as $$select 'infinity'::real$$ language sql immutable;
create function smith_real_ninf() returns real as $$select '-infinity'::real$$ language sql immutable;


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



view thread (9+ messages)  latest in thread

Message-ID: <878tx7491q.fsf@credativ.de>
Permalink:  ../878tx7491q.fsf@credativ.de/
Also on:    postgresql.org/message-id/878tx7491q.fsf@credativ.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: seltenreich@gmx.de, tgl@sss.pgh.pa.us
  Subject: Re: GiST index build versus NaN coordinates
  In-Reply-To: <878tx7491q.fsf@credativ.de>
  References: <28685.1468246504@sss.pgh.pa.us> <878tx7491q.fsf@credativ.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox