Re: 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: Re: Incorrect matching of sql/json PASSING variable names
Date: 2024-06-13 08:04:29
Message-ID: CA+HiwqG4PSQf9E=c7+BzzRvnfQLEmmL=c6dDmio+ztc9_wx69w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Jun 6, 2024 at 6:20 PM Amit Langote <amitlangote09(at)gmail(dot)com> wrote:
>
> 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.

Here's an updated version that I'll push tomorrow.

--
Thanks, Amit Langote

Attachment Content-Type Size
v2-0001-SQL-JSON-Correct-jsonpath-variable-name-matching.patch application/octet-stream 4.2 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Richard Guo 2024-06-13 08:07:51 Re: Eager aggregation, take 3
Previous Message Michael Paquier 2024-06-13 08:01:09 Re: Doc: fix a description regarding WAL summarizer on glossary page