Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xBFIJ-0000000367O-43kd for pgsql-bugs@arkaria.postgresql.org; Mon, 28 Sep 2026 17:37:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xBFII-0000000Ako5-4Bgo for pgsql-bugs@arkaria.postgresql.org; Mon, 28 Sep 2026 17:37:39 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xBFII-0000000Aknc-39v8 for pgsql-bugs@lists.postgresql.org; Mon, 28 Sep 2026 17:37:38 +0000 Received: from mail-vs2-x0f.google.com ([2a00:1450:4864:3a::f]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1xBFIG-00000001j2j-1SOv for pgsql-bugs@lists.postgresql.org; Mon, 28 Sep 2026 17:37:37 +0000 Received: by mail-vs2-x0f.google.com with SMTP id 71dfb90a1353d-5ce01a47cacso90643e0c.2 for ; Mon, 28 Sep 2026 10:37:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790617055; x=1791221855; darn=lists.postgresql.org; h=mime-version:content-transfer-encoding:content-type:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=n4/iDvGd2v4Ycx9zfJO+en5McM91nBIwXjDypPYnAUw=; b=SIEakVk7FrGT9RYL8eO87LWDAF5CGkXgSorDDe1S5QfPkQPAgUcAvBQgaqd/5NLynF VCJdjG96ZYMXIe+uzUbnfV/aCQBPUg030ZefGBtjemMPofUUrIWUobqfRY34ccy3lOTV vyZVsjXrGeCpKo8Vgs9Mu75zOq37Jzxb7d14Px9Dmg6Xt0sQTIch/9abdThTxkvcxXr4 a2nzc2VuIuE+M8VY6t5FL28whtnq+6tqdbudQ9Jc90h5+pDolQ79mowztZMWeNaG2TvX 9laHhPAAgteO/U0SzH2W2wlPNLCmxtRfVQffq3/Ah+B7q0bWmTwHelpjvNW/dD2sKzIV 1Kfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790617055; x=1791221855; h=mime-version:content-transfer-encoding:content-type:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=n4/iDvGd2v4Ycx9zfJO+en5McM91nBIwXjDypPYnAUw=; b=PxvGkQL39lEfbR+CYJ9eCeOWoOO9f5qzB32BpqsW3k8BA1EVDKjLaQVoF5Y7XGgsfQ lhXxIuArQ1Q3t+UUYGb/W0yO5UySyxHswn2qUNyZT+3L44GB47WUCGPBuoxUqzMqOiKY 8RVLpxm9xy0oflzF7/VU+5xQPS6xDcHonpDvqU4rB3BiL9wPwDJVZ2xbl1cWx88YG7dI 6KpL3nZ3M2QVqhGcG1e1zunwYCNQ2IfAhJwZQfuEXvfRP3tJCFGxnNI3BEiVtgt0w3s3 pCGXFBqDKeR5e1o27SN/ObSggUk0HgokyjiGAeZ1/XKrHXLpbN8evxrIK0Euu4G1kdcO pKgQ== X-Forwarded-Encrypted: i=1; AKwUvBzkQNsHx5MgKZnOFXh0lhHt1/+NTlAh02SX9c6SZ0YTiVrp4hi3smt34Lxt3C1IpInkFslxjI6LSl+n@lists.postgresql.org X-Gm-Message-State: AFq9FYKoPggJZRTfCzZqZnzYAI1shXlOhrMTS+/vNasLaQdoxAh34Zkq oN4tUy8Y4nj66htyi/6l73ihMagDuc5JuEfd8WhkiYdd6AO+Boo7TW5b X-Gm-Gg: AYBFou1VzCYT/hCM28PLQ7f1SuJpb7wdwTvT6i1EdJhIBhzXvIJkYyv1+aFxaPLLlJI G8g0nGipEjIvVrzh8B4AJMw3t+e0nHRkc/8UkkA9cHjiU4K34T3LCWs0NdL01bF3r+zq2wB3+HD vKrJeTpmniM5C8pGupVTT6i9Pt3xQo4NYeRMoZMQutm8g5O7K5bb8iVBqMGtmTkPu4/9QO2S1+X WUYATr7Nm6Kzmc5dclU6yivTS0UEqpEloKMGeIctYv4FJhBpJlICOV/8kSPa5ddPvrbOvPdekx5 hXOmcCwKfQQbczBtHj0u3Si4onhu/fLGGeVXSw9HbTs8wSQV00bz2fSi68Vq4CpIEzEmo8Behy9 Ea5FEFbDIxxCzzOeHkqCVnalHc5HzTttH+Z7SxmjiTrnU6fR1ZxJCFI18bt5RaDEUeDspVD8Rrk RIUirr+YIGUft9KFCGvxRgt7rPQsslFQO7W4XUneHDqgWA4C+P6qsEXDST8sANhMuLWByjqwxv9 A1wpdeh8wL8e2SKRrApRlQJDz3QMFv5s3aLPLydU7MM0yNzvMidVlZVDgvd642k4P7O+IQIZtNr wUefxqbRKJQnKSBYjkFsm5ENXKjPNIWu5jqO X-Received: by 2002:a05:6122:e012:10b0:5cd:b3e:3bb2 with SMTP id 71dfb90a1353d-5cd0b3e3e5bmr1929970e0c.2.1790617055449; Mon, 28 Sep 2026 10:37:35 -0700 (PDT) Received: from [192.168.1.4] ([2803:3c90:cee:ea00:5c3c:7e70:29e3:7a55]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-5cde5f620ddsm9510024e0c.12.2026.09.28.10.37.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Sep 2026 10:37:35 -0700 (PDT) From: Manu To: shihao zhong Cc: Kirill Reshke , Andrey Borodin , kehan5800@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #19705: One NaN box makes a BRIN box_inclusion_ops index omit unrelated rows Date: Mon, 28 Sep 2026 14:37:32 -0300 Message-ID: <179061705243.332245.12138813025099450814@gmail.com> In-Reply-To: References: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi Shihao, I ran v6 (0001 through 0004) through the same differential matrix as v5, on master (a5447a2deac) and REL_18_STABLE, built without assertions. 6769 checks per build: seq scan versus index for every operator the box, point, polygon and circle opclasses list, with NaN rows first, last, alone and scattered. > With your script, GiST has 9 mismatches left on master, all point <@ > polygon with a NaN vertex. Confirmed. On master, v6 takes BRIN box_inclusion_ops from 79 mismatches to 0, GiST box_ops from 85 to 0, GiST circle_ops from 60 to 0, and GiST poly_ops from 71 to 0. GiST point_ops goes from 162 to 9, and those 9 are exactly the point <@ polygon case with a NaN vertex in the polygon: the seq scan returns about 2025 rows and the index 0. The SP-GiST box_ops and poly_ops counts (10 and 28) are unchanged, as expected; they are the separate matter from earlier in the thread. > v6-0004 gives distance 0 to keys and query points with a NaN, as 0002 > already does for internal keys. 0004 also clears the KNN failure I reported. On master, CREATE TABLE b (v box); INSERT INTO b VALUES ('(1,NaN),(0,0)'); INSERT INTO b SELECT box(point(x, y), point(x + 1, y + 1)) FROM generate_series(0, 44) x, generate_series(0, 44) y; CREATE INDEX ON b USING gist (v); SET enable_seqscan = off; SELECT v <-> point '(0.5,0.5)' FROM b ORDER BY v <-> point '(0.5,0.5)' LIMIT 3; fails the assertion box->low.y <= box->high.y in computeDistance() (and raises "inconsistent point values" without assertions). With 0004 the index returns 0, 0.5, 0.5, the same as the seq scan, with no assertion and no error. On REL_18 the BRIN backport (v6-REL_18-0001) also takes BRIN box_inclusion_ops from 79 to 0. 0002 does not apply there, the 1b105f9472b context you mentioned, so I tested only the BRIN change on that branch; the GiST counts stay at the master control numbers. That leaves the point <@ polygon NaN-vertex case as the only mismatch on master. I am happy to keep it out of scope for this set if you would rather handle a NaN in the query polygon separately. Regards, Manu