Re: json_query conditional wrapper bug
Peter Eisentraut <peter@eisentraut.org>
From: Peter Eisentraut <peter@eisentraut.org>
To: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2024-09-04T10:16:31Z
Lists: pgsql-hackers
Attachments
- 0001-WIP-Fix-JSON_QUERY-WITH-CONDITIONAL-WRAPPER.patch (text/plain) patch 0001
On 28.08.24 11:21, Peter Eisentraut wrote:
> These are ok:
>
> select json_query('{"a": 1, "b": 42}'::jsonb, 'lax $.b' without wrapper);
> json_query
> ------------
> 42
>
> select json_query('{"a": 1, "b": 42}'::jsonb, 'lax $.b' with
> unconditional wrapper);
> json_query
> ------------
> [42]
>
> But this appears to be wrong:
>
> select json_query('{"a": 1, "b": 42}'::jsonb, 'lax $.b' with conditional
> wrapper);
> json_query
> ------------
> [42]
>
> This should return an unwrapped 42.
If I make the code change illustrated in the attached patch, then I get
the correct result here. And various regression test results change,
which, to me, all look more correct after this patch. I don't know what
the code I removed was supposed to accomplish, but it seems to be wrong
somehow. In the current implementation, the WITH CONDITIONAL WRAPPER
clause doesn't appear to work correctly in any case I could identify.
Commits
-
SQL/JSON: Fix JSON_QUERY(... WITH CONDITIONAL WRAPPER)
- e6c45d85dc16 18.0 landed
- 2c27346ed684 17.0 landed