Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 10eb60c

Browse files
committed
Add all structured objects passed to pushJsonbValue piecewise.
Commit 9b74f32 did this for objects of type jbvBinary, but in trying further to simplify some of the new jsonb code I discovered that objects of type jbvObject or jbvArray passed as WJB_ELEM or WJB_VALUE also caused problems. These too are now added component by component. Backpatch to 9.4.
1 parent 833c396 commit 10eb60c

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/backend/utils/adt/jsonb_util.c

+9-5
Original file line numberDiff line numberDiff line change
@@ -509,8 +509,8 @@ fillJsonbValue(JsonbContainer *container, int index,
509509
* "raw scalar" pseudo array to append it - the actual scalar should be passed
510510
* next and it will be added as the only member of the array.
511511
*
512-
* Values of type jvbBinary, which are rolled up arrays and objects,
513-
* are unpacked before being added to the result.
512+
* All non-scalar types (jvbBinary, jbvArray and jbvObject) passed as
513+
* elements or values are unpacked before being added to the result.
514514
*/
515515
JsonbValue *
516516
pushJsonbValue(JsonbParseState **pstate, JsonbIteratorToken seq,
@@ -522,14 +522,18 @@ pushJsonbValue(JsonbParseState **pstate, JsonbIteratorToken seq,
522522
JsonbIteratorToken tok;
523523

524524
if (!jbval || (seq != WJB_ELEM && seq != WJB_VALUE) ||
525-
jbval->type != jbvBinary)
525+
IsAJsonbScalar(jbval))
526526
{
527527
/* drop through */
528528
return pushJsonbValueScalar(pstate, seq, jbval);
529529
}
530530

531-
/* unpack the binary and add each piece to the pstate */
532-
it = JsonbIteratorInit(jbval->val.binary.data);
531+
/* unpack the data and add each piece to the pstate */
532+
if (jbval->type == jbvBinary)
533+
it = JsonbIteratorInit(jbval->val.binary.data);
534+
else
535+
it = JsonbIteratorInit(jbval);
536+
533537
while ((tok = JsonbIteratorNext(&it, &v, false)) != WJB_DONE)
534538
res = pushJsonbValueScalar(pstate, tok,
535539
tok < WJB_BEGIN_ARRAY ? &v : NULL);

0 commit comments

Comments
 (0)