Re: BUG #19695: JSON_VALUE ... RETURNING jsonb returns NULL for later evaluation once one evaluation returns NULL - Mailing list pgsql-bugs

From Srinath Reddy Sadipiralla
Subject Re: BUG #19695: JSON_VALUE ... RETURNING jsonb returns NULL for later evaluation once one evaluation returns NULL
Date
Msg-id CAFC+b6q5GZFvkpQV1tmioEjY=d-N+3LYCnUPo5bV0LbG95+N8A@mail.gmail.com
Whole thread
In response to Re: BUG #19695: JSON_VALUE ... RETURNING jsonb returns NULL for later evaluation once one evaluation returns NULL  (Manu <manuelreyesbravo@gmail.com>)
Responses Re: BUG #19695: JSON_VALUE ... RETURNING jsonb returns NULL for later evaluation once one evaluation returns NULL
List pgsql-bugs
Hi Manu,

On Thu, Sep 24, 2026 at 1:42 AM Manu <manuelreyesbravo@gmail.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

pgsql-bugs by date:

Previous
From: Ludvig Janiuk
Date:
Subject: Re: 42P16 error when dropping and adding column
Next
From: Srinath Reddy Sadipiralla
Date:
Subject: Re: BUG #19621: Unexpected results of JSON_VALUE with DEFAULT ON EMPTY