pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix GIN index search for root strings in strict jsonpath queries
Date: Sat, 24 Oct 2026 18:27:29 +0000
Message-ID: <E1xKgSn-00000000bY6-1xHE@gemulon.postgresql.org> (raw)

Fix GIN index search for root strings in strict jsonpath queries.

A jsonb_ops index scan for 'strict $ == "a scalar"' missed a matching
root string.  Root scalars are stored in single-element arrays, so
gin_extract_jsonb() indexes strings with JGINFLAG_KEY. In strict mode,
jsonb_ops__extract_nodes() instead searches for JGINFLAG_STR at the
root.  Leave gin_extract_jsonb() alone (else we'd force people to
reindex) and make jsonb_ops__extract_nodes() search for JGINFLAG_KEY
instead.

Author: Rui Zhao <zhaorui126@gmail.com>
Reviewed-by: shihao zhong <zhong950419@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAHWVJhHH0k3PxWmS==V1p_PONOMUaSm6LjUV487fwnOqd0jTQw@mail.gmail.com
Backpatch-through: 14

Branch
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/19656b77d16d996e94d01ade59a6132826b8c347

Modified Files
--------------
src/backend/utils/adt/jsonb_gin.c   |  5 +++--
src/test/regress/expected/jsonb.out | 27 +++++++++++++++++++++++++++
src/test/regress/sql/jsonb.sql      |  8 ++++++++
3 files changed, 38 insertions(+), 2 deletions(-)



view thread (7+ messages)  latest in thread

Message-ID: <E1xKgSn-00000000bY6-1xHE@gemulon.postgresql.org>
Permalink:  ../E1xKgSn-00000000bY6-1xHE@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1xKgSn-00000000bY6-1xHE@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: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Fix GIN index search for root strings in strict jsonpath queries
  In-Reply-To: <E1xKgSn-00000000bY6-1xHE@gemulon.postgresql.org>
  References: <E1xKgSn-00000000bY6-1xHE@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