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

Commita7de1c7

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

File tree

1 file changed

+24
-40
lines changed

1 file changed

+24
-40
lines changed

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

Lines changed: 24 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -452,10 +452,10 @@ static JsonbValue *setPath(JsonbIterator **it, Datum *path_elems,
452452
bool*path_nulls,intpath_len,
453453
JsonbParseState**st,intlevel,Jsonb*newval,
454454
intop_type);
455-
staticvoidsetPathObject(JsonbIterator**it,Datum*path_elems,
455+
staticJsonbIteratorTokensetPathObject(JsonbIterator**it,Datum*path_elems,
456456
bool*path_nulls,intpath_len,JsonbParseState**st,
457457
intlevel,
458-
Jsonb*newval,uint32npairs,intop_type);
458+
Jsonb*newval,intop_type);
459459
staticvoidsetPathArray(JsonbIterator**it,Datum*path_elems,
460460
bool*path_nulls,intpath_len,JsonbParseState**st,
461461
intlevel,Jsonb*newval,uint32nelems,intop_type);
@@ -4550,9 +4550,8 @@ setPath(JsonbIterator **it, Datum *path_elems,
45504550
break;
45514551
caseWJB_BEGIN_OBJECT:
45524552
(void)pushJsonbValue(st,r,NULL);
4553-
setPathObject(it,path_elems,path_nulls,path_len,st,level,
4554-
newval,v.val.object.nPairs,op_type);
4555-
r=JsonbIteratorNext(it,&v, true);
4553+
r=setPathObject(it,path_elems,path_nulls,path_len,st,level,
4554+
newval,op_type);
45564555
Assert(r==WJB_END_OBJECT);
45574556
res=pushJsonbValue(st,r,NULL);
45584557
break;
@@ -4572,39 +4571,21 @@ setPath(JsonbIterator **it, Datum *path_elems,
45724571
/*
45734572
* Object walker for setPath
45744573
*/
4575-
staticvoid
4574+
staticJsonbIteratorToken
45764575
setPathObject(JsonbIterator**it,Datum*path_elems,bool*path_nulls,
45774576
intpath_len,JsonbParseState**st,intlevel,
4578-
Jsonb*newval,uint32npairs,intop_type)
4577+
Jsonb*newval,intop_type)
45794578
{
45804579
JsonbValuev;
4581-
inti;
45824580
JsonbValuek;
4581+
JsonbIteratorTokenr;
45834582
booldone= false;
45844583

45854584
if (level >=path_len||path_nulls[level])
45864585
done= true;
45874586

4588-
/* empty object is a special case for create */
4589-
if ((npairs==0)&& (op_type&JB_PATH_CREATE_OR_INSERT)&&
4590-
(level==path_len-1))
4587+
while ((r=JsonbIteratorNext(it,&k, true))==WJB_KEY)
45914588
{
4592-
JsonbValuenewkey;
4593-
4594-
newkey.type=jbvString;
4595-
newkey.val.string.len=VARSIZE_ANY_EXHDR(path_elems[level]);
4596-
newkey.val.string.val=VARDATA_ANY(path_elems[level]);
4597-
4598-
(void)pushJsonbValue(st,WJB_KEY,&newkey);
4599-
addJsonbToParseState(st,newval);
4600-
}
4601-
4602-
for (i=0;i<npairs;i++)
4603-
{
4604-
JsonbIteratorTokenr=JsonbIteratorNext(it,&k, true);
4605-
4606-
Assert(r==WJB_KEY);
4607-
46084589
if (!done&&
46094590
k.val.string.len==VARSIZE_ANY_EXHDR(path_elems[level])&&
46104591
memcmp(k.val.string.val,VARDATA_ANY(path_elems[level]),
@@ -4624,6 +4605,8 @@ setPathObject(JsonbIterator **it, Datum *path_elems, bool *path_nulls,
46244605
"to replace key value.")));
46254606

46264607
r=JsonbIteratorNext(it,&v, true);/* skip value */
4608+
Assert(r==WJB_VALUE);
4609+
46274610
if (!(op_type&JB_PATH_DELETE))
46284611
{
46294612
(void)pushJsonbValue(st,WJB_KEY,&k);
@@ -4640,25 +4623,26 @@ setPathObject(JsonbIterator **it, Datum *path_elems, bool *path_nulls,
46404623
}
46414624
else
46424625
{
4643-
if ((op_type&JB_PATH_CREATE_OR_INSERT)&& !done&&
4644-
level==path_len-1&&i==npairs-1)
4645-
{
4646-
JsonbValuenewkey;
4647-
4648-
newkey.type=jbvString;
4649-
newkey.val.string.len=VARSIZE_ANY_EXHDR(path_elems[level]);
4650-
newkey.val.string.val=VARDATA_ANY(path_elems[level]);
4651-
4652-
(void)pushJsonbValue(st,WJB_KEY,&newkey);
4653-
addJsonbToParseState(st,newval);
4654-
}
4655-
46564626
(void)pushJsonbValue(st,r,&k);
46574627
r=JsonbIteratorNext(it,&v, true);
46584628
Assert(r==WJB_VALUE);
46594629
(void)pushJsonbValue(st,r,&v);
46604630
}
46614631
}
4632+
4633+
if ((op_type&JB_PATH_CREATE_OR_INSERT)&& !done&&level==path_len-1)
4634+
{
4635+
JsonbValuenewkey;
4636+
4637+
newkey.type=jbvString;
4638+
newkey.val.string.len=VARSIZE_ANY_EXHDR(path_elems[level]);
4639+
newkey.val.string.val=VARDATA_ANY(path_elems[level]);
4640+
4641+
(void)pushJsonbValue(st,WJB_KEY,&newkey);
4642+
addJsonbToParseState(st,newval);
4643+
}
4644+
4645+
returnr;
46624646
}
46634647

46644648
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp