Skip to content

Commit 5840317

Browse files
author
Nikita Glukhov
committed
Simplify json container pushing
1 parent 974c3a9 commit 5840317

File tree

1 file changed

+6
-38
lines changed

1 file changed

+6
-38
lines changed

src/backend/utils/adt/jsonfuncs.c

Lines changed: 6 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4926,24 +4926,9 @@ setPathObject(JsonbIterator **it, Datum *path_elems, bool *path_nulls,
49264926
}
49274927

49284928
(void) pushJsonbValue(st, r, &k);
4929-
r = JsonbIteratorNext(it, &v, false);
4930-
(void) pushJsonbValue(st, r, r < WJB_BEGIN_ARRAY ? &v : NULL);
4931-
if (r == WJB_BEGIN_ARRAY || r == WJB_BEGIN_OBJECT)
4932-
{
4933-
int walking_level = 1;
4934-
4935-
while (walking_level != 0)
4936-
{
4937-
r = JsonbIteratorNext(it, &v, false);
4938-
4939-
if (r == WJB_BEGIN_ARRAY || r == WJB_BEGIN_OBJECT)
4940-
++walking_level;
4941-
if (r == WJB_END_ARRAY || r == WJB_END_OBJECT)
4942-
--walking_level;
4943-
4944-
(void) pushJsonbValue(st, r, r < WJB_BEGIN_ARRAY ? &v : NULL);
4945-
}
4946-
}
4929+
r = JsonbIteratorNext(it, &v, true);
4930+
Assert(r == WJB_VALUE);
4931+
(void) pushJsonbValue(st, r, &v);
49474932
}
49484933
}
49494934
}
@@ -5039,26 +5024,9 @@ setPathArray(JsonbIterator **it, Datum *path_elems, bool *path_nulls,
50395024
}
50405025
else
50415026
{
5042-
r = JsonbIteratorNext(it, &v, false);
5043-
5044-
(void) pushJsonbValue(st, r, r < WJB_BEGIN_ARRAY ? &v : NULL);
5045-
5046-
if (r == WJB_BEGIN_ARRAY || r == WJB_BEGIN_OBJECT)
5047-
{
5048-
int walking_level = 1;
5049-
5050-
while (walking_level != 0)
5051-
{
5052-
r = JsonbIteratorNext(it, &v, false);
5053-
5054-
if (r == WJB_BEGIN_ARRAY || r == WJB_BEGIN_OBJECT)
5055-
++walking_level;
5056-
if (r == WJB_END_ARRAY || r == WJB_END_OBJECT)
5057-
--walking_level;
5058-
5059-
(void) pushJsonbValue(st, r, r < WJB_BEGIN_ARRAY ? &v : NULL);
5060-
}
5061-
}
5027+
r = JsonbIteratorNext(it, &v, true);
5028+
Assert(r == WJB_ELEM);
5029+
(void) pushJsonbValue(st, r, &v);
50625030

50635031
if ((op_type & JB_PATH_CREATE_OR_INSERT) && !done &&
50645032
level == path_len - 1 && i == nelems - 1)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy