pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Chao Li <li.evan.chao@gmail.com>
To: Ilya Gladyshev <ilya.gladyshev@linux.dev>
Cc: pgsql-hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: [PATCH] Remove redundant path_nulls checks in setPathObject/Array
Date: Mon, 7 Sep 2026 15:22:53 +0800
Message-ID: <56F71416-E3C3-4758-81B7-BA9FA32D3A98@gmail.com> (raw)
In-Reply-To: <bb4175151e040c4b98045d5b01b8128fd923eb1e@linux.dev>
References: <bb4175151e040c4b98045d5b01b8128fd923eb1e@linux.dev>



> On Aug 26, 2026, at 20:03, Ilya Gladyshev <ilya.gladyshev@linux.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/










view thread (4+ messages)

Message-ID: <56F71416-E3C3-4758-81B7-BA9FA32D3A98@gmail.com>
Permalink:  ../56F71416-E3C3-4758-81B7-BA9FA32D3A98@gmail.com/
Also on:    postgresql.org/message-id/56F71416-E3C3-4758-81B7-BA9FA32D3A98@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: li.evan.chao@gmail.com, ilya.gladyshev@linux.dev
  Subject: Re: [PATCH] Remove redundant path_nulls checks in setPathObject/Array
  In-Reply-To: <56F71416-E3C3-4758-81B7-BA9FA32D3A98@gmail.com>
  References: <bb4175151e040c4b98045d5b01b8128fd923eb1e@linux.dev> <56F71416-E3C3-4758-81B7-BA9FA32D3A98@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox