mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
Revert "Simplify addJsonbToParseState()"
This reverts commit fba12c8c6c
.
This relied on a commit that is also being reverted.
This commit is contained in:
@ -3225,9 +3225,8 @@ jsonb_strip_nulls(PG_FUNCTION_ARGS)
|
|||||||
* If the parse state container is an object, the jsonb is pushed as
|
* If the parse state container is an object, the jsonb is pushed as
|
||||||
* a value, not a key.
|
* a value, not a key.
|
||||||
*
|
*
|
||||||
* If the new value is a root scalar, extract the value using an iterator, and
|
* This needs to be done using an iterator because pushJsonbValue doesn't
|
||||||
* just add that. Otherwise, add the value as the type appropriate for
|
* like getting jbvBinary values, so we can't just push jb as a whole.
|
||||||
* the container.
|
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
addJsonbToParseState(JsonbParseState **jbps, Jsonb *jb)
|
addJsonbToParseState(JsonbParseState **jbps, Jsonb *jb)
|
||||||
@ -3237,26 +3236,36 @@ addJsonbToParseState(JsonbParseState **jbps, Jsonb *jb)
|
|||||||
int type;
|
int type;
|
||||||
JsonbValue v;
|
JsonbValue v;
|
||||||
|
|
||||||
|
it = JsonbIteratorInit(&jb->root);
|
||||||
|
|
||||||
Assert(o->type == jbvArray || o->type == jbvObject);
|
Assert(o->type == jbvArray || o->type == jbvObject);
|
||||||
|
|
||||||
if (JB_ROOT_IS_SCALAR(jb))
|
if (JB_ROOT_IS_SCALAR(jb))
|
||||||
{
|
{
|
||||||
it = JsonbIteratorInit(&jb->root);
|
|
||||||
|
|
||||||
(void) JsonbIteratorNext(&it, &v, false); /* skip array header */
|
(void) JsonbIteratorNext(&it, &v, false); /* skip array header */
|
||||||
(void) JsonbIteratorNext(&it, &v, false); /* fetch scalar value */
|
(void) JsonbIteratorNext(&it, &v, false); /* fetch scalar value */
|
||||||
|
|
||||||
if (o->type == jbvArray)
|
switch (o->type)
|
||||||
(void) pushJsonbValue(jbps, WJB_ELEM, &v);
|
{
|
||||||
else
|
case jbvArray:
|
||||||
(void) pushJsonbValue(jbps, WJB_VALUE, &v);
|
(void) pushJsonbValue(jbps, WJB_ELEM, &v);
|
||||||
|
break;
|
||||||
|
case jbvObject:
|
||||||
|
(void) pushJsonbValue(jbps, WJB_VALUE, &v);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
elog(ERROR, "unexpected parent of nested structure");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (o->type == jbvArray)
|
while ((type = JsonbIteratorNext(&it, &v, false)) != WJB_DONE)
|
||||||
(void) pushJsonbValue(jbps, WJB_ELEM, &jb->root);
|
{
|
||||||
else
|
if (type == WJB_KEY || type == WJB_VALUE || type == WJB_ELEM)
|
||||||
(void) pushJsonbValue(jbps, WJB_VALUE, &jb->root);
|
(void) pushJsonbValue(jbps, type, &v);
|
||||||
|
else
|
||||||
|
(void) pushJsonbValue(jbps, type, NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user