@@ -51,7 +51,7 @@ struct JsonbParseState
5151 bool skip_nulls ; /* Skip null object fields */
5252};
5353
54- struct JsonbIterator
54+ typedef struct jsonbIterator
5555{
5656 JsonIterator ji ;
5757
@@ -80,7 +80,7 @@ struct JsonbIterator
8080
8181 /* Private state */
8282 JsonbIterState state ;
83- };
83+ } jsonbIterator ;
8484
8585static void fillJsonbValue (const JsonbContainer * container , int index ,
8686 char * base_addr , uint32 offset ,
@@ -96,7 +96,7 @@ static void convertJsonbScalar(StringInfo buffer, JEntry *header, const JsonbVal
9696static void copyToBuffer (StringInfo buffer , int offset , const char * data , int len );
9797static short padBufferToInt (StringInfo buffer );
9898
99- static JsonbIterator * iteratorFromContainer (JsonContainer * container , JsonbIterator * parent );
99+ static jsonbIterator * iteratorFromContainer (JsonContainer * container , jsonbIterator * parent );
100100static JsonbParseState * pushState (JsonbParseState * * pstate );
101101static void appendKey (JsonbParseState * pstate , const JsonbValue * scalarVal );
102102static void appendValue (JsonbParseState * pstate , const JsonbValue * scalarVal );
@@ -245,8 +245,8 @@ compareJsonbContainers(JsonContainer *a, JsonContainer *b)
245245 * itb ;
246246 int res = 0 ;
247247
248- ita = JsonIteratorInit (a );
249- itb = JsonIteratorInit (b );
248+ ita = JsonbIteratorInit (a );
249+ itb = JsonbIteratorInit (b );
250250
251251 do
252252 {
@@ -255,8 +255,8 @@ compareJsonbContainers(JsonContainer *a, JsonContainer *b)
255255 JsonbIteratorToken ra ,
256256 rb ;
257257
258- ra = JsonIteratorNext (& ita , & va , false);
259- rb = JsonIteratorNext (& itb , & vb , false);
258+ ra = JsonbIteratorNext (& ita , & va , false);
259+ rb = JsonbIteratorNext (& itb , & vb , false);
260260
261261 if (ra == rb )
262262 {
@@ -746,27 +746,27 @@ pushJsonbValue(JsonbParseState **pstate, JsonbIteratorToken seq,
746746 }
747747
748748 /* unpack the binary and add each piece to the pstate */
749- it = JsonIteratorInit (jbval -> val .binary .data );
749+ it = JsonbIteratorInit (jbval -> val .binary .data );
750750
751751 if (JsonContainerIsScalar (jbval -> val .binary .data ) && * pstate )
752752 {
753- tok = JsonIteratorNext (& it , & v , true);
753+ tok = JsonbIteratorNext (& it , & v , true);
754754 Assert (tok == WJB_BEGIN_ARRAY );
755755 Assert (v .type == jbvArray && v .val .array .rawScalar );
756756
757- tok = JsonIteratorNext (& it , & v , true);
757+ tok = JsonbIteratorNext (& it , & v , true);
758758 Assert (tok == WJB_ELEM );
759759
760760 res = pushJsonbValueScalar (pstate , seq , & v );
761761
762- tok = JsonIteratorNext (& it , & v , true);
762+ tok = JsonbIteratorNext (& it , & v , true);
763763 Assert (tok == WJB_END_ARRAY );
764764 Assert (it == NULL );
765765
766766 return res ;
767767 }
768768
769- while ((tok = JsonIteratorNext (& it , & v , false)) != WJB_DONE )
769+ while ((tok = JsonbIteratorNext (& it , & v , false)) != WJB_DONE )
770770 res = pushJsonbValueScalar (pstate , tok ,
771771 tok < WJB_BEGIN_ARRAY ||
772772 (tok == WJB_BEGIN_ARRAY &&
@@ -1021,10 +1021,10 @@ appendElement(JsonbParseState *pstate, const JsonbValue *scalarVal)
10211021 * WJB_END_OBJECT, on the assumption that it's only useful to access values
10221022 * when recursing in.
10231023 */
1024- JsonbIteratorToken
1025- JsonbIteratorNext (JsonIterator * * jsit , JsonbValue * val , bool skipNested )
1024+ static JsonbIteratorToken
1025+ jsonbIteratorNext (JsonIterator * * jsit , JsonbValue * val , bool skipNested )
10261026{
1027- JsonbIterator * * it = (JsonbIterator * * ) jsit ;
1027+ jsonbIterator * * it = (jsonbIterator * * ) jsit ;
10281028
10291029 if (* it == NULL )
10301030 return WJB_DONE ;
@@ -1064,7 +1064,7 @@ JsonbIteratorNext(JsonIterator **jsit, JsonbValue *val, bool skipNested)
10641064 * independently tracks iteration progress at its level of
10651065 * nesting).
10661066 */
1067- * it = (JsonbIterator * )
1067+ * it = (jsonbIterator * )
10681068 JsonIteratorFreeAndGetParent ((JsonIterator * ) * it );
10691069 return WJB_END_ARRAY ;
10701070 }
@@ -1118,7 +1118,7 @@ JsonbIteratorNext(JsonIterator **jsit, JsonbValue *val, bool skipNested)
11181118 * (which independently tracks iteration progress at its level
11191119 * of nesting).
11201120 */
1121- * it = (JsonbIterator * )
1121+ * it = (jsonbIterator * )
11221122 JsonIteratorFreeAndGetParent ((JsonIterator * ) * it );
11231123 return WJB_END_OBJECT ;
11241124 }
@@ -1168,30 +1168,30 @@ JsonbIteratorNext(JsonIterator **jsit, JsonbValue *val, bool skipNested)
11681168 return -1 ;
11691169}
11701170
1171- static JsonbIterator *
1172- iteratorFromContainer (JsonContainer * container , JsonbIterator * parent )
1171+ static jsonbIterator *
1172+ iteratorFromContainer (JsonContainer * container , jsonbIterator * parent )
11731173{
1174- JsonbIterator * it = (JsonbIterator * ) JsonIteratorInit (container );
1174+ jsonbIterator * it = (jsonbIterator * ) JsonbIteratorInit (container );
11751175 it -> ji .parent = & parent -> ji ;
11761176 return it ;
11771177}
11781178
11791179/*
1180- * Given a JsonbContainer, expand to JsonbIterator to iterate over items
1180+ * Given a JsonbContainer, expand to jsonbIterator to iterate over items
11811181 * fully expanded to in-memory representation for manipulation.
11821182 *
1183- * See JsonbIteratorNext () for notes on memory management.
1183+ * See jsonbIteratorNext () for notes on memory management.
11841184 */
11851185static JsonIterator *
1186- JsonbIteratorInit (JsonContainer * cont )
1186+ jsonbIteratorInit (JsonContainer * cont )
11871187{
11881188 const JsonbContainer * container = cont -> data ;
1189- JsonbIterator * it ;
1189+ jsonbIterator * it ;
11901190
1191- it = palloc0 (sizeof (JsonbIterator ));
1191+ it = palloc0 (sizeof (jsonbIterator ));
11921192 it -> ji .container = cont ;
11931193 it -> ji .parent = NULL ;
1194- it -> ji .next = JsonbIteratorNext ;
1194+ it -> ji .next = jsonbIteratorNext ;
11951195 it -> container = container ;
11961196 it -> nElems = container -> header & JB_CMASK ;
11971197
@@ -1252,8 +1252,8 @@ JsonbDeepContains(JsonIterator **val, JsonIterator **mContained)
12521252 */
12531253 check_stack_depth ();
12541254
1255- rval = JsonIteratorNext (val , & vval , false);
1256- rcont = JsonIteratorNext (mContained , & vcontained , false);
1255+ rval = JsonbIteratorNext (val , & vval , false);
1256+ rcont = JsonbIteratorNext (mContained , & vcontained , false);
12571257
12581258 if (rval != rcont )
12591259 {
@@ -1288,7 +1288,7 @@ JsonbDeepContains(JsonIterator **val, JsonIterator **mContained)
12881288 JsonbValue * lhsVal ; /* lhsVal is from pair in lhs object */
12891289 JsonbValue lhsValBuf ;
12901290
1291- rcont = JsonIteratorNext (mContained , & vcontained , false);
1291+ rcont = JsonbIteratorNext (mContained , & vcontained , false);
12921292
12931293 /*
12941294 * When we get through caller's rhs "is it contained within?"
@@ -1313,7 +1313,7 @@ JsonbDeepContains(JsonIterator **val, JsonIterator **mContained)
13131313 * ...at this stage it is apparent that there is at least a key
13141314 * match for this rhs pair.
13151315 */
1316- rcont = JsonIteratorNext (mContained , & vcontained , true);
1316+ rcont = JsonbIteratorNext (mContained , & vcontained , true);
13171317
13181318 Assert (rcont == WJB_VALUE );
13191319
@@ -1339,8 +1339,8 @@ JsonbDeepContains(JsonIterator **val, JsonIterator **mContained)
13391339 Assert (lhsVal -> type == jbvBinary );
13401340 Assert (vcontained .type == jbvBinary );
13411341
1342- nestval = JsonIteratorInit (lhsVal -> val .binary .data );
1343- nestContained = JsonIteratorInit (vcontained .val .binary .data );
1342+ nestval = JsonbIteratorInit (lhsVal -> val .binary .data );
1343+ nestContained = JsonbIteratorInit (vcontained .val .binary .data );
13441344
13451345 /*
13461346 * Match "value" side of rhs datum object's pair recursively.
@@ -1391,7 +1391,7 @@ JsonbDeepContains(JsonIterator **val, JsonIterator **mContained)
13911391 /* Work through rhs "is it contained within?" array */
13921392 for (;;)
13931393 {
1394- rcont = JsonIteratorNext (mContained , & vcontained , true);
1394+ rcont = JsonbIteratorNext (mContained , & vcontained , true);
13951395
13961396 /*
13971397 * When we get through caller's rhs "is it contained within?"
@@ -1428,7 +1428,7 @@ JsonbDeepContains(JsonIterator **val, JsonIterator **mContained)
14281428 for (i = 0 ; i < nLhsElems ; i ++ )
14291429 {
14301430 /* Store all lhs elements in temp array */
1431- rcont = JsonIteratorNext (val , & vval , true);
1431+ rcont = JsonbIteratorNext (val , & vval , true);
14321432 Assert (rcont == WJB_ELEM );
14331433
14341434 if (vval .type == jbvBinary )
@@ -1451,8 +1451,8 @@ JsonbDeepContains(JsonIterator **val, JsonIterator **mContained)
14511451 * nestContained ;
14521452 bool contains ;
14531453
1454- nestval = JsonIteratorInit (lhsConts [i ].val .binary .data );
1455- nestContained = JsonIteratorInit (vcontained .val .binary .data );
1454+ nestval = JsonbIteratorInit (lhsConts [i ].val .binary .data );
1455+ nestContained = JsonbIteratorInit (vcontained .val .binary .data );
14561456
14571457 contains = JsonbDeepContains (& nestval , & nestContained );
14581458
@@ -2227,7 +2227,7 @@ JsonContainerOps
22272227jsonbContainerOps =
22282228{
22292229 jsonbInit ,
2230- JsonbIteratorInit ,
2230+ jsonbIteratorInit ,
22312231 jsonbFindKeyInObject ,
22322232 jsonbFindValueInArray ,
22332233 jsonbGetArrayElement ,
0 commit comments