Add all structured objects passed to pushJsonbValue piecewise.
Commit 9b74f32cdbff8b9be47fc69164eae552050509ff 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.
This commit is contained in:
parent
79f2b5d583
commit
54547bd87f
@ -509,8 +509,8 @@ fillJsonbValue(JsonbContainer *container, int index,
|
|||||||
* "raw scalar" pseudo array to append it - the actual scalar should be passed
|
* "raw scalar" pseudo array to append it - the actual scalar should be passed
|
||||||
* next and it will be added as the only member of the array.
|
* next and it will be added as the only member of the array.
|
||||||
*
|
*
|
||||||
* Values of type jvbBinary, which are rolled up arrays and objects,
|
* All non-scalar types (jvbBinary, jbvArray and jbvObject) passed as
|
||||||
* are unpacked before being added to the result.
|
* elements or values are unpacked before being added to the result.
|
||||||
*/
|
*/
|
||||||
JsonbValue *
|
JsonbValue *
|
||||||
pushJsonbValue(JsonbParseState **pstate, JsonbIteratorToken seq,
|
pushJsonbValue(JsonbParseState **pstate, JsonbIteratorToken seq,
|
||||||
@ -522,14 +522,18 @@ pushJsonbValue(JsonbParseState **pstate, JsonbIteratorToken seq,
|
|||||||
JsonbIteratorToken tok;
|
JsonbIteratorToken tok;
|
||||||
|
|
||||||
if (!jbval || (seq != WJB_ELEM && seq != WJB_VALUE) ||
|
if (!jbval || (seq != WJB_ELEM && seq != WJB_VALUE) ||
|
||||||
jbval->type != jbvBinary)
|
IsAJsonbScalar(jbval))
|
||||||
{
|
{
|
||||||
/* drop through */
|
/* drop through */
|
||||||
return pushJsonbValueScalar(pstate, seq, jbval);
|
return pushJsonbValueScalar(pstate, seq, jbval);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* unpack the binary and add each piece to the pstate */
|
/* unpack the data and add each piece to the pstate */
|
||||||
it = JsonbIteratorInit(jbval->val.binary.data);
|
if (jbval->type == jbvBinary)
|
||||||
|
it = JsonbIteratorInit(jbval->val.binary.data);
|
||||||
|
else
|
||||||
|
it = JsonbIteratorInit(jbval);
|
||||||
|
|
||||||
while ((tok = JsonbIteratorNext(&it, &v, false)) != WJB_DONE)
|
while ((tok = JsonbIteratorNext(&it, &v, false)) != WJB_DONE)
|
||||||
res = pushJsonbValueScalar(pstate, tok,
|
res = pushJsonbValueScalar(pstate, tok,
|
||||||
tok < WJB_BEGIN_ARRAY ? &v : NULL);
|
tok < WJB_BEGIN_ARRAY ? &v : NULL);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user