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

From: Manu <manuelreyesbravo(at)gmail(dot)com>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: Srinath Reddy Sadipiralla <srinath2133(at)gmail(dot)com>, 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-23 20:12:34
Message-ID: 179019435414.699921.11893679831783704384@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

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

Regards,
Manu

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Masahiko Sawada 2026-09-24 00:38:30 Re: autovacuum: automatically propagate updated parameters
Previous Message Manu 2026-09-23 20:12:30 Re: BUG #19621: Unexpected results of JSON_VALUE with DEFAULT ON EMPTY