Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mwYPS-00047Z-Sh for pgsql-bugs@arkaria.postgresql.org; Sun, 12 Dec 2021 23:37:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mwYPR-00061D-20 for pgsql-bugs@arkaria.postgresql.org; Sun, 12 Dec 2021 23:37:37 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mwYPQ-000613-PV for pgsql-bugs@lists.postgresql.org; Sun, 12 Dec 2021 23:37:36 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mwYPF-0008Bq-G1 for pgsql-bugs@lists.postgresql.org; Sun, 12 Dec 2021 23:37:33 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 1BCNbLSR746817; Sun, 12 Dec 2021 18:37:22 -0500 From: Tom Lane To: Tomas Vondra cc: exclusion@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #17334: Assert failed inside computeDistance() on gist index scanning In-reply-to: <7c191fd2-9103-ae81-8f4f-22f39edd3c90@enterprisedb.com> References: <17334-135f485c21739caa@postgresql.org> <7c191fd2-9103-ae81-8f4f-22f39edd3c90@enterprisedb.com> Comments: In-reply-to Tomas Vondra message dated "Sun, 12 Dec 2021 23:59:43 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <746815.1639352241.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sun, 12 Dec 2021 18:37:21 -0500 Message-ID: <746816.1639352241@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Tomas Vondra writes: > FWIW I can reproduce this on master too. The failure happens because of = > NaN value in the index: Man, what a pain those are. > I'm not sure if the issue is in allowing the NaN to be added to the = > index, or not handling it correctly during the index scan. Surely omitting the entry from the index would lead to incorrect answers. Without any index, we get regression=3D# CREATE TABLE point_tbl(f1 point); CREATE TABLE regression=3D# INSERT INTO point_tbl SELECT ('0,0') FROM generate_series(1= , 2); INSERT 0 2 regression=3D# INSERT INTO point_tbl VALUES ('0,NaN'); INSERT 0 1 regression=3D# SELECT f1, f1 <-> point '(0,0)' AS dist FROM point_tbl ORDE= R BY dist; f1 | dist = ---------+------ (0,0) | 0 (0,0) | 0 (0,NaN) | NaN (3 rows) You can argue about where the NaN distance should sort, but not about whether the row should appear at all. > It's interesting btree_gist does not have issues (for NaN in float8 = > columns). It seems not to store NaN in the index, It seems to replace = > them with tiny values, at least according to pageinspect. Yipes, that's even worse, if true. regards, tom lane