Re: json_query conditional wrapper bug

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: json_query conditional wrapper bug
Date: 2024-09-04 10:16:31
Message-ID: 0919c21e-af83-458b-8e40-1228429eaaa4@eisentraut.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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.

Attachment Content-Type Size
0001-WIP-Fix-JSON_QUERY-WITH-CONDITIONAL-WRAPPER.patch text/plain 1.9 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dean Rasheed 2024-09-04 10:33:53 Re: Virtual generated columns
Previous Message Junwang Zhao 2024-09-04 09:55:29 Re: BUG #18598: AddressSanitizer detects use after free inside json_unique_hash_match()