Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7179b67

Browse files
author
Nikita Glukhov
committed
Remove JsonbValue.val.object.nPairs references outside of jsonb_uitls.c
1 parent8084453 commit7179b67

File tree

1 file changed

+23
-40
lines changed

1 file changed

+23
-40
lines changed

‎src/backend/utils/adt/jsonfuncs.c

Lines changed: 23 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -466,8 +466,7 @@ static JsonbValue *setPath(JsonbIterator **it, Datum *path_elems,
466466
intop_type);
467467
staticvoidsetPathObject(JsonbIterator**it,Datum*path_elems,
468468
bool*path_nulls,intpath_len,JsonbParseState**st,
469-
intlevel,
470-
Jsonb*newval,uint32npairs,intop_type);
469+
intlevel,Jsonb*newval,intop_type);
471470
staticvoidsetPathArray(JsonbIterator**it,Datum*path_elems,
472471
bool*path_nulls,intpath_len,JsonbParseState**st,
473472
intlevel,Jsonb*newval,uint32nelems,intop_type);
@@ -4822,9 +4821,8 @@ setPath(JsonbIterator **it, Datum *path_elems,
48224821
break;
48234822
caseWJB_BEGIN_OBJECT:
48244823
(void)pushJsonbValue(st,r,NULL);
4825-
setPathObject(it,path_elems,path_nulls,path_len,st,level,
4826-
newval,v.val.object.nPairs,op_type);
4827-
r=JsonbIteratorNext(it,&v, true);
4824+
r=setPathObject(it,path_elems,path_nulls,path_len,st,level,
4825+
newval,op_type);
48284826
Assert(r==WJB_END_OBJECT);
48294827
res=pushJsonbValue(st,r,NULL);
48304828
break;
@@ -4844,39 +4842,21 @@ setPath(JsonbIterator **it, Datum *path_elems,
48444842
/*
48454843
* Object walker for setPath
48464844
*/
4847-
staticvoid
4845+
staticJsonbIteratorToken
48484846
setPathObject(JsonbIterator**it,Datum*path_elems,bool*path_nulls,
48494847
intpath_len,JsonbParseState**st,intlevel,
4850-
Jsonb*newval,uint32npairs,intop_type)
4848+
Jsonb*newval,intop_type)
48514849
{
48524850
JsonbValuev;
4853-
inti;
48544851
JsonbValuek;
4852+
JsonbIteratorTokenr;
48554853
booldone= false;
48564854

48574855
if (level >=path_len||path_nulls[level])
48584856
done= true;
48594857

4860-
/* empty object is a special case for create */
4861-
if ((npairs==0)&& (op_type&JB_PATH_CREATE_OR_INSERT)&&
4862-
(level==path_len-1))
4858+
while ((r=JsonbIteratorNext(it,&k, true))==WJB_KEY)
48634859
{
4864-
JsonbValuenewkey;
4865-
4866-
newkey.type=jbvString;
4867-
newkey.val.string.len=VARSIZE_ANY_EXHDR(path_elems[level]);
4868-
newkey.val.string.val=VARDATA_ANY(path_elems[level]);
4869-
4870-
(void)pushJsonbValue(st,WJB_KEY,&newkey);
4871-
addJsonbToParseState(st,newval);
4872-
}
4873-
4874-
for (i=0;i<npairs;i++)
4875-
{
4876-
JsonbIteratorTokenr=JsonbIteratorNext(it,&k, true);
4877-
4878-
Assert(r==WJB_KEY);
4879-
48804860
if (!done&&
48814861
k.val.string.len==VARSIZE_ANY_EXHDR(path_elems[level])&&
48824862
memcmp(k.val.string.val,VARDATA_ANY(path_elems[level]),
@@ -4896,6 +4876,8 @@ setPathObject(JsonbIterator **it, Datum *path_elems, bool *path_nulls,
48964876
"to replace key value.")));
48974877

48984878
r=JsonbIteratorNext(it,&v, true);/* skip value */
4879+
Assert(r==WJB_VALUE);
4880+
48994881
if (!(op_type&JB_PATH_DELETE))
49004882
{
49014883
(void)pushJsonbValue(st,WJB_KEY,&k);
@@ -4912,25 +4894,26 @@ setPathObject(JsonbIterator **it, Datum *path_elems, bool *path_nulls,
49124894
}
49134895
else
49144896
{
4915-
if ((op_type&JB_PATH_CREATE_OR_INSERT)&& !done&&
4916-
level==path_len-1&&i==npairs-1)
4917-
{
4918-
JsonbValuenewkey;
4919-
4920-
newkey.type=jbvString;
4921-
newkey.val.string.len=VARSIZE_ANY_EXHDR(path_elems[level]);
4922-
newkey.val.string.val=VARDATA_ANY(path_elems[level]);
4923-
4924-
(void)pushJsonbValue(st,WJB_KEY,&newkey);
4925-
addJsonbToParseState(st,newval);
4926-
}
4927-
49284897
(void)pushJsonbValue(st,r,&k);
49294898
r=JsonbIteratorNext(it,&v, true);
49304899
Assert(r==WJB_VALUE);
49314900
(void)pushJsonbValue(st,r,&v);
49324901
}
49334902
}
4903+
4904+
if ((op_type&JB_PATH_CREATE_OR_INSERT)&& !done&&level==path_len-1)
4905+
{
4906+
JsonbValuenewkey;
4907+
4908+
newkey.type=jbvString;
4909+
newkey.val.string.len=VARSIZE_ANY_EXHDR(path_elems[level]);
4910+
newkey.val.string.val=VARDATA_ANY(path_elems[level]);
4911+
4912+
(void)pushJsonbValue(st,WJB_KEY,&newkey);
4913+
addJsonbToParseState(st,newval);
4914+
}
4915+
4916+
returnr;
49344917
}
49354918

49364919
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp