pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Amit Langote <amitlan@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: SQL/JSON: Correct jsonpath variable name matching
Date: Wed, 19 Jun 2024 06:48:09 +0000
Message-ID: <E1sJp72-002765-A3@gemulon.postgresql.org> (raw)

SQL/JSON: Correct jsonpath variable name matching

Previously, GetJsonPathVar() allowed a jsonpath expression to
reference any prefix of a PASSING variable's name. For example, the
following query would incorrectly work:

SELECT JSON_QUERY(context_item, jsonpath '$xy' PASSING val AS xyz);

The fix ensures that the length of the variable name mentioned in a
jsonpath expression matches exactly with the name of the PASSING
variable before comparing the strings using strncmp().

Reported-by: Alvaro Herrera (off-list)
Discussion: https://postgr.es/m/CA+HiwqFGkLWMvELBH6E4SQ45qUHthgcRH6gCJL20OsYDRtFx_w@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/0f271e8e8d9c8db0ea86c0d12b3221009b81d8bf

Modified Files
--------------
src/backend/executor/execExpr.c                  |  1 +
src/backend/utils/adt/jsonpath_exec.c            |  4 +++-
src/include/utils/jsonpath.h                     |  1 +
src/test/regress/expected/sqljson_queryfuncs.out | 11 +++++++++++
src/test/regress/sql/sqljson_queryfuncs.sql      |  5 +++++
5 files changed, 21 insertions(+), 1 deletion(-)



Message-ID: <E1sJp72-002765-A3@gemulon.postgresql.org>
Permalink:  ../E1sJp72-002765-A3@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1sJp72-002765-A3@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 using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: amitlan@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: SQL/JSON: Correct jsonpath variable name matching
  In-Reply-To: <E1sJp72-002765-A3@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