From ad1ad228c4bee6d672958860e0dbd7819223a5c7 Mon Sep 17 00:00:00 2001
From: Ilya Gladyshev <ilya.gladyshev@linux.dev>
Date: Wed, 26 Aug 2026 14:23:21 +0300
Subject: [PATCH] Remove redundant path_null checks in setPathObject/Array

- 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"), path_nulls check was propagated into setPath itself.

Therefore, remove redundant checks in setPathObject/Array.
---
 src/backend/utils/adt/jsonfuncs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/backend/utils/adt/jsonfuncs.c b/src/backend/utils/adt/jsonfuncs.c
index bc7b556e22e..8e5d5faf046 100644
--- a/src/backend/utils/adt/jsonfuncs.c
+++ b/src/backend/utils/adt/jsonfuncs.c
@@ -5260,7 +5260,7 @@ setPathObject(JsonbIterator **it, const Datum *path_elems, const bool *path_null
 				v;
 	bool		done = false;
 
-	if (level >= path_len || path_nulls[level])
+	if (level >= path_len)
 		done = true;
 	else
 	{
@@ -5398,7 +5398,7 @@ setPathArray(JsonbIterator **it, const Datum *path_elems, const bool *path_nulls
 	bool		done = false;
 
 	/* pick correct index */
-	if (level < path_len && !path_nulls[level])
+	if (level < path_len)
 	{
 		char	   *c = TextDatumGetCString(path_elems[level]);
 		char	   *badp;
-- 
2.55.0

