@@ -51,7 +51,7 @@ struct JsonbParseState
51
51
bool skip_nulls ; /* Skip null object fields */
52
52
};
53
53
54
- struct JsonbIterator
54
+ typedef struct jsonbIterator
55
55
{
56
56
JsonIterator ji ;
57
57
@@ -80,7 +80,7 @@ struct JsonbIterator
80
80
81
81
/* Private state */
82
82
JsonbIterState state ;
83
- };
83
+ } jsonbIterator ;
84
84
85
85
static void fillJsonbValue (const JsonbContainer * container , int index ,
86
86
char * base_addr , uint32 offset ,
@@ -96,7 +96,7 @@ static void convertJsonbScalar(StringInfo buffer, JEntry *header, const JsonbVal
96
96
static void copyToBuffer (StringInfo buffer , int offset , const char * data , int len );
97
97
static short padBufferToInt (StringInfo buffer );
98
98
99
- static JsonbIterator * iteratorFromContainer (JsonContainer * container , JsonbIterator * parent );
99
+ static jsonbIterator * iteratorFromContainer (JsonContainer * container , jsonbIterator * parent );
100
100
static JsonbParseState * pushState (JsonbParseState * * pstate );
101
101
static void appendKey (JsonbParseState * pstate , const JsonbValue * scalarVal );
102
102
static void appendValue (JsonbParseState * pstate , const JsonbValue * scalarVal );
@@ -245,8 +245,8 @@ compareJsonbContainers(JsonContainer *a, JsonContainer *b)
245
245
* itb ;
246
246
int res = 0 ;
247
247
248
- ita = JsonIteratorInit (a );
249
- itb = JsonIteratorInit (b );
248
+ ita = JsonbIteratorInit (a );
249
+ itb = JsonbIteratorInit (b );
250
250
251
251
do
252
252
{
@@ -255,8 +255,8 @@ compareJsonbContainers(JsonContainer *a, JsonContainer *b)
255
255
JsonbIteratorToken ra ,
256
256
rb ;
257
257
258
- ra = JsonIteratorNext (& ita , & va , false);
259
- rb = JsonIteratorNext (& itb , & vb , false);
258
+ ra = JsonbIteratorNext (& ita , & va , false);
259
+ rb = JsonbIteratorNext (& itb , & vb , false);
260
260
261
261
if (ra == rb )
262
262
{
@@ -746,27 +746,27 @@ pushJsonbValue(JsonbParseState **pstate, JsonbIteratorToken seq,
746
746
}
747
747
748
748
/* unpack the binary and add each piece to the pstate */
749
- it = JsonIteratorInit (jbval -> val .binary .data );
749
+ it = JsonbIteratorInit (jbval -> val .binary .data );
750
750
751
751
if (JsonContainerIsScalar (jbval -> val .binary .data ) && * pstate )
752
752
{
753
- tok = JsonIteratorNext (& it , & v , true);
753
+ tok = JsonbIteratorNext (& it , & v , true);
754
754
Assert (tok == WJB_BEGIN_ARRAY );
755
755
Assert (v .type == jbvArray && v .val .array .rawScalar );
756
756
757
- tok = JsonIteratorNext (& it , & v , true);
757
+ tok = JsonbIteratorNext (& it , & v , true);
758
758
Assert (tok == WJB_ELEM );
759
759
760
760
res = pushJsonbValueScalar (pstate , seq , & v );
761
761
762
- tok = JsonIteratorNext (& it , & v , true);
762
+ tok = JsonbIteratorNext (& it , & v , true);
763
763
Assert (tok == WJB_END_ARRAY );
764
764
Assert (it == NULL );
765
765
766
766
return res ;
767
767
}
768
768
769
- while ((tok = JsonIteratorNext (& it , & v , false)) != WJB_DONE )
769
+ while ((tok = JsonbIteratorNext (& it , & v , false)) != WJB_DONE )
770
770
res = pushJsonbValueScalar (pstate , tok ,
771
771
tok < WJB_BEGIN_ARRAY ||
772
772
(tok == WJB_BEGIN_ARRAY &&
@@ -1021,10 +1021,10 @@ appendElement(JsonbParseState *pstate, const JsonbValue *scalarVal)
1021
1021
* WJB_END_OBJECT, on the assumption that it's only useful to access values
1022
1022
* when recursing in.
1023
1023
*/
1024
- JsonbIteratorToken
1025
- JsonbIteratorNext (JsonIterator * * jsit , JsonbValue * val , bool skipNested )
1024
+ static JsonbIteratorToken
1025
+ jsonbIteratorNext (JsonIterator * * jsit , JsonbValue * val , bool skipNested )
1026
1026
{
1027
- JsonbIterator * * it = (JsonbIterator * * ) jsit ;
1027
+ jsonbIterator * * it = (jsonbIterator * * ) jsit ;
1028
1028
1029
1029
if (* it == NULL )
1030
1030
return WJB_DONE ;
@@ -1064,7 +1064,7 @@ JsonbIteratorNext(JsonIterator **jsit, JsonbValue *val, bool skipNested)
1064
1064
* independently tracks iteration progress at its level of
1065
1065
* nesting).
1066
1066
*/
1067
- * it = (JsonbIterator * )
1067
+ * it = (jsonbIterator * )
1068
1068
JsonIteratorFreeAndGetParent ((JsonIterator * ) * it );
1069
1069
return WJB_END_ARRAY ;
1070
1070
}
@@ -1118,7 +1118,7 @@ JsonbIteratorNext(JsonIterator **jsit, JsonbValue *val, bool skipNested)
1118
1118
* (which independently tracks iteration progress at its level
1119
1119
* of nesting).
1120
1120
*/
1121
- * it = (JsonbIterator * )
1121
+ * it = (jsonbIterator * )
1122
1122
JsonIteratorFreeAndGetParent ((JsonIterator * ) * it );
1123
1123
return WJB_END_OBJECT ;
1124
1124
}
@@ -1168,30 +1168,30 @@ JsonbIteratorNext(JsonIterator **jsit, JsonbValue *val, bool skipNested)
1168
1168
return -1 ;
1169
1169
}
1170
1170
1171
- static JsonbIterator *
1172
- iteratorFromContainer (JsonContainer * container , JsonbIterator * parent )
1171
+ static jsonbIterator *
1172
+ iteratorFromContainer (JsonContainer * container , jsonbIterator * parent )
1173
1173
{
1174
- JsonbIterator * it = (JsonbIterator * ) JsonIteratorInit (container );
1174
+ jsonbIterator * it = (jsonbIterator * ) JsonbIteratorInit (container );
1175
1175
it -> ji .parent = & parent -> ji ;
1176
1176
return it ;
1177
1177
}
1178
1178
1179
1179
/*
1180
- * Given a JsonbContainer, expand to JsonbIterator to iterate over items
1180
+ * Given a JsonbContainer, expand to jsonbIterator to iterate over items
1181
1181
* fully expanded to in-memory representation for manipulation.
1182
1182
*
1183
- * See JsonbIteratorNext () for notes on memory management.
1183
+ * See jsonbIteratorNext () for notes on memory management.
1184
1184
*/
1185
1185
static JsonIterator *
1186
- JsonbIteratorInit (JsonContainer * cont )
1186
+ jsonbIteratorInit (JsonContainer * cont )
1187
1187
{
1188
1188
const JsonbContainer * container = cont -> data ;
1189
- JsonbIterator * it ;
1189
+ jsonbIterator * it ;
1190
1190
1191
- it = palloc0 (sizeof (JsonbIterator ));
1191
+ it = palloc0 (sizeof (jsonbIterator ));
1192
1192
it -> ji .container = cont ;
1193
1193
it -> ji .parent = NULL ;
1194
- it -> ji .next = JsonbIteratorNext ;
1194
+ it -> ji .next = jsonbIteratorNext ;
1195
1195
it -> container = container ;
1196
1196
it -> nElems = container -> header & JB_CMASK ;
1197
1197
@@ -1252,8 +1252,8 @@ JsonbDeepContains(JsonIterator **val, JsonIterator **mContained)
1252
1252
*/
1253
1253
check_stack_depth ();
1254
1254
1255
- rval = JsonIteratorNext (val , & vval , false);
1256
- rcont = JsonIteratorNext (mContained , & vcontained , false);
1255
+ rval = JsonbIteratorNext (val , & vval , false);
1256
+ rcont = JsonbIteratorNext (mContained , & vcontained , false);
1257
1257
1258
1258
if (rval != rcont )
1259
1259
{
@@ -1288,7 +1288,7 @@ JsonbDeepContains(JsonIterator **val, JsonIterator **mContained)
1288
1288
JsonbValue * lhsVal ; /* lhsVal is from pair in lhs object */
1289
1289
JsonbValue lhsValBuf ;
1290
1290
1291
- rcont = JsonIteratorNext (mContained , & vcontained , false);
1291
+ rcont = JsonbIteratorNext (mContained , & vcontained , false);
1292
1292
1293
1293
/*
1294
1294
* When we get through caller's rhs "is it contained within?"
@@ -1313,7 +1313,7 @@ JsonbDeepContains(JsonIterator **val, JsonIterator **mContained)
1313
1313
* ...at this stage it is apparent that there is at least a key
1314
1314
* match for this rhs pair.
1315
1315
*/
1316
- rcont = JsonIteratorNext (mContained , & vcontained , true);
1316
+ rcont = JsonbIteratorNext (mContained , & vcontained , true);
1317
1317
1318
1318
Assert (rcont == WJB_VALUE );
1319
1319
@@ -1339,8 +1339,8 @@ JsonbDeepContains(JsonIterator **val, JsonIterator **mContained)
1339
1339
Assert (lhsVal -> type == jbvBinary );
1340
1340
Assert (vcontained .type == jbvBinary );
1341
1341
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 );
1344
1344
1345
1345
/*
1346
1346
* Match "value" side of rhs datum object's pair recursively.
@@ -1391,7 +1391,7 @@ JsonbDeepContains(JsonIterator **val, JsonIterator **mContained)
1391
1391
/* Work through rhs "is it contained within?" array */
1392
1392
for (;;)
1393
1393
{
1394
- rcont = JsonIteratorNext (mContained , & vcontained , true);
1394
+ rcont = JsonbIteratorNext (mContained , & vcontained , true);
1395
1395
1396
1396
/*
1397
1397
* When we get through caller's rhs "is it contained within?"
@@ -1428,7 +1428,7 @@ JsonbDeepContains(JsonIterator **val, JsonIterator **mContained)
1428
1428
for (i = 0 ; i < nLhsElems ; i ++ )
1429
1429
{
1430
1430
/* Store all lhs elements in temp array */
1431
- rcont = JsonIteratorNext (val , & vval , true);
1431
+ rcont = JsonbIteratorNext (val , & vval , true);
1432
1432
Assert (rcont == WJB_ELEM );
1433
1433
1434
1434
if (vval .type == jbvBinary )
@@ -1451,8 +1451,8 @@ JsonbDeepContains(JsonIterator **val, JsonIterator **mContained)
1451
1451
* nestContained ;
1452
1452
bool contains ;
1453
1453
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 );
1456
1456
1457
1457
contains = JsonbDeepContains (& nestval , & nestContained );
1458
1458
@@ -2227,7 +2227,7 @@ JsonContainerOps
2227
2227
jsonbContainerOps =
2228
2228
{
2229
2229
jsonbInit ,
2230
- JsonbIteratorInit ,
2230
+ jsonbIteratorInit ,
2231
2231
jsonbFindKeyInObject ,
2232
2232
jsonbFindValueInArray ,
2233
2233
jsonbGetArrayElement ,
0 commit comments