pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: John Naylor <john.naylor@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Check all four box corners in SP-GiST quad tree <@ search
Date: Fri, 30 Oct 2026 05:36:12 +0000
Message-ID: <E1xMfHg-00000001MGk-1c6f@gemulon.postgresql.org> (raw)

Check all four box corners in SP-GiST quad tree <@ search

When the centroid lies outside the query box, spg_quad_inner_consistent()
keeps only the quadrants that contain a corner of the box.  It meant to
test all four corners, but the last step set x back to low.x instead of
y to low.y, so it tested (low.x, high.y) twice and never (high.x, low.y).

With exact comparisons the missing corner would not matter: a box that
does not contain the centroid lies on one side of it on at least one
axis, so (high.x, low.y) shares a quadrant with another corner, but
getQuadrant() compares with FPeq(), which tiebreaks to the lowest
numbered quadrant.

When a box edge lies within EPSILON of the centroid, the corner on that
edge counts as being on the centroid's line, and (high.x, low.y) may be
the only corner in its quadrant.  That quadrant was then skipped.  Fix
the missing corner test.

Discussion: https://postgr.es/m/CANWCAZZZpkwrX0kC4Jo6KM27J6dyBdCDir-PbjEYAS06r%3D4-ag%40mail.gmail.com
Backpatch-through: 14

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/0496d85f9f086de109b06427ef72d22029312227

Modified Files
--------------
src/backend/access/spgist/spgquadtreeproc.c | 2 +-
src/test/regress/expected/spgist.out        | 9 +++++++++
src/test/regress/sql/spgist.sql             | 5 +++++
3 files changed, 15 insertions(+), 1 deletion(-)



view thread (7+ messages)  latest in thread

Message-ID: <E1xMfHg-00000001MGk-1c6f@gemulon.postgresql.org>
Permalink:  ../E1xMfHg-00000001MGk-1c6f@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1xMfHg-00000001MGk-1c6f@gemulon.postgresql.org

 · 

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-committers@postgresql.org
  Cc: john.naylor@postgresql.org
  Subject: Re: pgsql: Check all four box corners in SP-GiST quad tree <@ search
  In-Reply-To: <E1xMfHg-00000001MGk-1c6f@gemulon.postgresql.org>
  References: <E1xMfHg-00000001MGk-1c6f@gemulon.postgresql.org>

* 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