Re: BUG #19695: JSON_VALUE ... RETURNING jsonb returns NULL for later evaluation once one evaluation returns NULL

From: Srinath Reddy Sadipiralla <srinath2133(at)gmail(dot)com>
To: Manu <manuelreyesbravo(at)gmail(dot)com>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org, Amit Langote <amitlangote09(at)gmail(dot)com>, chaitanyyachoudhary(at)gmail(dot)com
Subject: Re: BUG #19695: JSON_VALUE ... RETURNING jsonb returns NULL for later evaluation once one evaluation returns NULL
Date: 2026-09-24 17:03:48
Message-ID: CAFC+b6q5GZFvkpQV1tmioEjY=d-N+3LYCnUPo5bV0LbG95+N8A@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi Manu,

On Thu, Sep 24, 2026 at 1:42 AM Manu <manuelreyesbravo(at)gmail(dot)com> wrote:

> Hi Srinath,
>
> I tested your v1 on master, REL_18_STABLE and REL_17_STABLE, together
> with Andrey's v2 for #19621 [1], which touches the same function. Both
> apply cleanly on all three branches, build without warnings, and the
> main regression suite passes. On all three,
> JSON_VALUE(x, '$' RETURNING jsonb) over '1', 'null', '2' now returns
> 1, NULL, 2 (it was 1, NULL, NULL).
>
> The fix looks right to me: that branch fills val_string but never
> cleared the resnull left by an earlier row.
>
> A small thing: git apply warns about trailing whitespace on four lines
> of the new test in sqljson_queryfuncs.sql.
>
> [1]
>
> https://postgr.es/m/CAB8bMitawD=ERVLwYuDXvMT_OJqf+qAKx=3GEH6V_WHT7jnq7A@mail.gmail.com
>

Thanks for the review; I also looked into the pointed thread
and shared my feedback there, and I fixed the whitespace errors
in this v2 patch.

--
Thanks :)
Srinath Reddy Sadipiralla
EDB: https://www.enterprisedb.com/

Attachment Content-Type Size
v2-0001-Fix-state-leakage-in-JSON_VALUE-returning-json-jsonb.patch application/octet-stream 4.9 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Srinath Reddy Sadipiralla 2026-09-24 17:06:52 Re: BUG #19621: Unexpected results of JSON_VALUE with DEFAULT ON EMPTY
Previous Message Ludvig Janiuk 2026-09-24 14:09:09 Re: 42P16 error when dropping and adding column