Incorrect matching of sql/json PASSING variable names

From: Amit Langote <amitlangote09(at)gmail(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Incorrect matching of sql/json PASSING variable names
Date: 2024-06-06 09:20:07
Message-ID: CA+HiwqFGkLWMvELBH6E4SQ45qUHthgcRH6gCJL20OsYDRtFx_w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

Alvaro reported off-list that the following should really fail,
because the jsonpath expression refers to a PASSING variable that
doesn't exist:

select json_query('"1"', jsonpath '$xy' passing 2 AS xyz);
json_query
------------
2
(1 row)

This works because of a bug in GetJsonPathVar() whereby it allows a
jsonpath expression to reference any prefix of the PASSING variable
names.

Attached is a patch to fix that.

Thanks Alvaro for the report.

--
Thanks, Amit Langote

Attachment Content-Type Size
v1-0001-in-transformJsonBehavior-better-handle-default-ex.patch application/octet-stream 7.8 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrei Lepikhov 2024-06-06 09:26:13 Re: Proposal: Job Scheduler
Previous Message Jelte Fennema-Nio 2024-06-06 09:12:30 Re: Add new protocol message to change GUCs for usage with future protocol-only GUCs