Re: BUG #19956: json #>, #>> and json_extract_path resolve a negative array index against an earlier sibling array

From: Andrey Rachitskiy <pl0h0yp1(at)gmail(dot)com>
To: Ishjaap Singh <ishjaap(dot)singh07(at)gmail(dot)com>
Cc: e1638616(at)u(dot)nus(dot)edu, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #19956: json #>, #>> and json_extract_path resolve a negative array index against an earlier sibling array
Date: 2026-12-03 18:13:05
Message-ID: CAB8bMiuQodWkW0ipHzB2ot-AjBWU+KTZsYd6Zk3=97MBp9nWFQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

чт, 3 дек. 2026 г. в 22:21, Ishjaap Singh <ishjaap(dot)singh07(at)gmail(dot)com>:

>
> Master gives NULL, like jsonb and the chained -> form. The patch gives
> 1, from the first "a" (#>> too). The first "a" now matches, and the
> second one doesn't clear that result. That's BUG #19970 [1]:
> get_object_field_start() only clears the result when the key is the
> last path element. So I think #19970 should be fixed together with
> this. Would you like to include it in your patch, or should I send a
> separate fix for it?
>
>
Hi Ishjapp,

Thanks for the review and tests, added in v2.

> Minor: is the (size_t) -idx <= input_length check needed? A negative
> index that is too large already gives NULL on master, for example
> '[1,2,3]'::json #> '{-1000}', so it seems to only skip the counting.
>
>
fixed

--
Regards,
Rachitskiy Andrey

Attachment Content-Type Size
v2-0001-Fix-json-negative-subscripts-on-the-selected-array.patch text/x-patch 6.5 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Kirill Reshke 2026-12-03 18:16:23 Re: btree_gist: <-> fails on same-sign infinite intervals
Previous Message Kirill Reshke 2026-12-03 17:57:38 Re: BUG #19968: ALTER COLUMN TYPE fails with internal errors if a dependent object is dropped concurrently