| From: | Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> |
|---|---|
| To: | Ilya Gladyshev <ilya(dot)gladyshev(at)linux(dot)dev> |
| Cc: | pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: [PATCH] Remove redundant path_nulls checks in setPathObject/Array |
| Date: | 2026-09-07 07:22:53 |
| Message-ID: | 56F71416-E3C3-4758-81B7-BA9FA32D3A98@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
> On Aug 26, 2026, at 20:03, Ilya Gladyshev <ilya(dot)gladyshev(at)linux(dot)dev> wrote:
>
> Hi all,
>
> I noticed redundant path_nulls checks in setPathObject and setPathArray,
> so here's a small refactoring patch to remove them.
>
> - Both checks were introduced in c694701 (12 May 2015, "Additional
> functions and operators for jsonb") with the functions' initial code.
>
> - Both functions always had a single call site, `setPath`, as they are
> internal implementations for the two cases (array/object) in a generic
> function.
>
> - Later, in 1edd4ec (4 Oct 2015, "Disallow invalid path elements in
> jsonb_set"), the path_nulls check was propagated into setPath itself.
>
> If desired, those conditions can be transformed into Assert()s with a
> comment about setPath() validation.
>
> ---
> Ilya Gladyshev // foxido.dev<0001-Remove-redundant-NULL-checks-in-setPathObject-Array.patch>
Looks reasonable to me, since setPath() already checks path_nulls[level] and raises an error for a NULL path element.
I think this patch does more than just remove a redundant check, it also eliminates a potential source of confusion. setPath() treats path_nulls[level] being true as an error, while setPathObject() currently treats the same condition as an indication of done.
Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Jelte Fennema-Nio | 2026-09-07 07:31:37 | Re: Python/pytest test framework take two |
| Previous Message | Yuhang Qiu | 2026-09-07 07:18:19 | Re: [PATCH] Use streaming read I/O in sample scans |