Re: More jsonpath methods: translate, split, join - Mailing list pgsql-hackers

From Florents Tselai
Subject Re: More jsonpath methods: translate, split, join
Date
Msg-id CA+v5N40u7kAttYWPK-NTbusUkgZfZkTbnvA7rF63dX+y0hQm2Q@mail.gmail.com
Whole thread
In response to Re: More jsonpath methods: translate, split, join  (Zsolt Parragi <zsolt.parragi@percona.com>)
Responses Re: More jsonpath methods: translate, split, join
List pgsql-hackers




On Fri, Jun 19, 2026 at 11:43 PM Zsolt Parragi <zsolt.parragi@percona.com> wrote:
Hello

+                               /* Validate target is an array */
+                               if (JsonbType(jb) != jbvArray)
+                               {
+                                       RETURN_ERROR(ereport(ERROR,
+                                                                                (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+                                                                                 errmsg("jsonpath item method .join() can only be applied
to an array"))));

Other methods seem to use ERRCODE_SQL_JSON_ARRAY_NOT_FOUND

+                               else
+                               {
+                                       /* Recursive Tree (jbvArray) */
+                                       for (int i = 0; i < jb->val.array.nElems; i++)

Isn't this branch unreachable?

 both of your points are correct. 
Here's a v3 that address them . 

While at it, I've added some additional edge cases about these 3 methods.
The semantics look good to me, and they pass without additional change in the underlying src code in jsonpath_exec.c 



Attachment

pgsql-hackers by date:

Previous
From: Alexander Lakhin
Date:
Subject: Re: Unexpected behavior after OOM errors
Next
From: Tatsuya Kawata
Date:
Subject: Re: [PATCH] doc: clarify pg_stat_lock.fastpath_exceeded scope