Clean up a bug in sql/json items commit 66ea94e8e6
authorAndrew Dunstan <[email protected]>
Thu, 25 Jan 2024 21:21:57 +0000 (16:21 -0500)
committerAndrew Dunstan <[email protected]>
Thu, 25 Jan 2024 21:25:11 +0000 (16:25 -0500)
Remove a buggy and unnecessary test, along with an unnecessary pstrdup()
and a line of dead code.

Per report, diagnosis and fix from Tom Lane

Discussion: https://postgr.es/m/439811.1706211069@sss.pgh.pa.us

src/backend/utils/adt/jsonpath_exec.c

index bf37f0195c84730f055d1d16ac2f802e7d138d02..02a700292bbc036450af2db0370940466d520dc7 100644 (file)
@@ -1540,11 +1540,9 @@ executeItemOptUnwrapTarget(JsonPathExecContext *cxt, JsonPathItem *jsp,
                        break;
                }
 
-               res = jperOk;
-
                jb = &jbv;
                Assert(tmp != NULL);    /* We must have set tmp above */
-               jb->val.string.val = (jb->type == jbvString) ? tmp : pstrdup(tmp);
+               jb->val.string.val = tmp;
                jb->val.string.len = strlen(jb->val.string.val);
                jb->type = jbvString;