@@ -565,7 +565,7 @@ jsonb_object_keys(PG_FUNCTION_ARGS)
565
565
state -> sent_count = 0 ;
566
566
state -> result = palloc (state -> result_size * sizeof (char * ));
567
567
568
- it = JsonbIteratorInit (& jb -> root );
568
+ it = JsonbIteratorInit (JsonbRoot ( jb ) );
569
569
570
570
while ((r = JsonbIteratorNext (& it ,& v ,skipNested ))!= WJB_DONE )
571
571
{
@@ -830,7 +830,7 @@ jsonb_object_field(PG_FUNCTION_ARGS)
830
830
if (!JB_ROOT_IS_OBJECT (jb ))
831
831
PG_RETURN_NULL ();
832
832
833
- v = getKeyJsonValueFromContainer (& jb -> root ,
833
+ v = getKeyJsonValueFromContainer (JsonbRoot ( jb ) ,
834
834
VARDATA_ANY (key ),
835
835
VARSIZE_ANY_EXHDR (key ),
836
836
& vbuf );
@@ -868,7 +868,7 @@ jsonb_object_field_text(PG_FUNCTION_ARGS)
868
868
if (!JB_ROOT_IS_OBJECT (jb ))
869
869
PG_RETURN_NULL ();
870
870
871
- v = getKeyJsonValueFromContainer (& jb -> root ,
871
+ v = getKeyJsonValueFromContainer (JsonbRoot ( jb ) ,
872
872
VARDATA_ANY (key ),
873
873
VARSIZE_ANY_EXHDR (key ),
874
874
& vbuf );
@@ -915,7 +915,7 @@ jsonb_array_element(PG_FUNCTION_ARGS)
915
915
element += nelements ;
916
916
}
917
917
918
- v = getIthJsonbValueFromContainer (& jb -> root ,element );
918
+ v = getIthJsonbValueFromContainer (JsonbRoot ( jb ) ,element );
919
919
if (v != NULL )
920
920
PG_RETURN_JSONB_P (JsonbValueToJsonb (v ));
921
921
@@ -958,7 +958,7 @@ jsonb_array_element_text(PG_FUNCTION_ARGS)
958
958
element += nelements ;
959
959
}
960
960
961
- v = getIthJsonbValueFromContainer (& jb -> root ,element );
961
+ v = getIthJsonbValueFromContainer (JsonbRoot ( jb ) ,element );
962
962
963
963
if (v != NULL && v -> type != jbvNull )
964
964
PG_RETURN_TEXT_P (JsonbValueAsText (v ));
@@ -1468,7 +1468,7 @@ get_jsonb_path_all(FunctionCallInfo fcinfo, bool as_text)
1468
1468
& pathtext ,& pathnulls ,& npath );
1469
1469
1470
1470
/* Identify whether we have object, array, or scalar at top-level */
1471
- container = & jb -> root ;
1471
+ container = JsonbRoot ( jb ) ;
1472
1472
1473
1473
if (JB_ROOT_IS_OBJECT (jb ))
1474
1474
have_object = true;
@@ -1496,7 +1496,7 @@ get_jsonb_path_all(FunctionCallInfo fcinfo, bool as_text)
1496
1496
{
1497
1497
PG_RETURN_TEXT_P (cstring_to_text (JsonbToCString (NULL ,
1498
1498
container ,
1499
- VARSIZE (jb ))));
1499
+ JsonbGetSize (jb ))));
1500
1500
}
1501
1501
else
1502
1502
{
@@ -1813,7 +1813,7 @@ each_worker_jsonb(FunctionCallInfo fcinfo, const char *funcname, bool as_text)
1813
1813
"jsonb_each temporary cxt" ,
1814
1814
ALLOCSET_DEFAULT_SIZES );
1815
1815
1816
- it = JsonbIteratorInit (& jb -> root );
1816
+ it = JsonbIteratorInit (JsonbRoot ( jb ) );
1817
1817
1818
1818
while ((r = JsonbIteratorNext (& it ,& v ,skipNested ))!= WJB_DONE )
1819
1819
{
@@ -2110,7 +2110,7 @@ elements_worker_jsonb(FunctionCallInfo fcinfo, const char *funcname,
2110
2110
"jsonb_array_elements temporary cxt" ,
2111
2111
ALLOCSET_DEFAULT_SIZES );
2112
2112
2113
- it = JsonbIteratorInit (& jb -> root );
2113
+ it = JsonbIteratorInit (JsonbRoot ( jb ) );
2114
2114
2115
2115
while ((r = JsonbIteratorNext (& it ,& v ,skipNested ))!= WJB_DONE )
2116
2116
{
@@ -2899,7 +2899,7 @@ populate_scalar(ScalarIOData *io, Oid typid, int32 typmod, JsValue *jsv)
2899
2899
*/
2900
2900
Jsonb * jsonb = JsonbValueToJsonb (jbv );
2901
2901
2902
- str = JsonbToCString (NULL ,& jsonb -> root , VARSIZE (jsonb ));
2902
+ str = JsonbToCString (NULL ,JSonbRoot ( jsonb ), JsonbGetSize (jsonb ));
2903
2903
}
2904
2904
else if (jbv -> type == jbvString )/* quotes are stripped */
2905
2905
str = pnstrdup (jbv -> val .string .val ,jbv -> val .string .len );
@@ -3774,7 +3774,7 @@ populate_recordset_worker(FunctionCallInfo fcinfo, const char *funcname,
3774
3774
errmsg ("cannot call %s on a non-array" ,
3775
3775
funcname )));
3776
3776
3777
- it = JsonbIteratorInit (& jb -> root );
3777
+ it = JsonbIteratorInit (JsonbRoot ( jb ) );
3778
3778
3779
3779
while ((r = JsonbIteratorNext (& it ,& v ,skipNested ))!= WJB_DONE )
3780
3780
{
@@ -4113,7 +4113,7 @@ jsonb_strip_nulls(PG_FUNCTION_ARGS)
4113
4113
if (JB_ROOT_IS_SCALAR (jb ))
4114
4114
PG_RETURN_JSONB_P (jb );
4115
4115
4116
- it = JsonbIteratorInit (& jb -> root );
4116
+ it = JsonbIteratorInit (JsonbRoot ( jb ) );
4117
4117
4118
4118
while ((type = JsonbIteratorNext (& it ,& v , false))!= WJB_DONE )
4119
4119
{
@@ -4167,7 +4167,7 @@ addJsonbToParseState(JsonbParseState **jbps, Jsonb *jb)
4167
4167
JsonbValue v ;
4168
4168
JsonbIteratorToken type ;
4169
4169
4170
- it = JsonbIteratorInit (& jb -> root );
4170
+ it = JsonbIteratorInit (JsonbRoot ( jb ) );
4171
4171
4172
4172
Assert (* jbps );
4173
4173
@@ -4203,7 +4203,7 @@ jsonb_pretty(PG_FUNCTION_ARGS)
4203
4203
Jsonb * jb = PG_GETARG_JSONB_P (0 );
4204
4204
StringInfo str = makeStringInfo ();
4205
4205
4206
- JsonbToCStringIndent (str ,& jb -> root , VARSIZE (jb ));
4206
+ JsonbToCStringIndent (str ,JsonbRoot ( jb ), JsonbGetSize (jb ));
4207
4207
4208
4208
PG_RETURN_TEXT_P (cstring_to_text_with_len (str -> data ,str -> len ));
4209
4209
}
@@ -4214,7 +4214,7 @@ jsonb_canonical(PG_FUNCTION_ARGS)
4214
4214
Jsonb * jb = PG_GETARG_JSONB_P (0 );
4215
4215
StringInfo str = makeStringInfo ();
4216
4216
4217
- JsonbToCStringCanonical (str ,& jb -> root , VARSIZE (jb ));
4217
+ JsonbToCStringCanonical (str ,JsonbRoot ( jb ), JsonbGetSize (jb ));
4218
4218
4219
4219
PG_RETURN_TEXT_P (cstring_to_text_with_len (str -> data ,str -> len ));
4220
4220
}
@@ -4248,8 +4248,8 @@ jsonb_concat(PG_FUNCTION_ARGS)
4248
4248
PG_RETURN_JSONB_P (jb1 );
4249
4249
}
4250
4250
4251
- it1 = JsonbIteratorInit (& jb1 -> root );
4252
- it2 = JsonbIteratorInit (& jb2 -> root );
4251
+ it1 = JsonbIteratorInit (JsonbRoot ( jb1 ) );
4252
+ it2 = JsonbIteratorInit (JsonbRoot ( jb2 ) );
4253
4253
4254
4254
res = IteratorConcat (& it1 ,& it2 ,& state );
4255
4255
@@ -4287,7 +4287,7 @@ jsonb_delete(PG_FUNCTION_ARGS)
4287
4287
if (JB_ROOT_COUNT (in )== 0 )
4288
4288
PG_RETURN_JSONB_P (in );
4289
4289
4290
- it = JsonbIteratorInit (& in -> root );
4290
+ it = JsonbIteratorInit (JsonbRoot ( in ) );
4291
4291
4292
4292
while ((r = JsonbIteratorNext (& it ,& v ,skipNested ))!= WJB_DONE )
4293
4293
{
@@ -4352,7 +4352,7 @@ jsonb_delete_array(PG_FUNCTION_ARGS)
4352
4352
if (keys_len == 0 )
4353
4353
PG_RETURN_JSONB_P (in );
4354
4354
4355
- it = JsonbIteratorInit (& in -> root );
4355
+ it = JsonbIteratorInit (JsonbRoot ( in ) );
4356
4356
4357
4357
while ((r = JsonbIteratorNext (& it ,& v ,skipNested ))!= WJB_DONE )
4358
4358
{
@@ -4431,7 +4431,7 @@ jsonb_delete_idx(PG_FUNCTION_ARGS)
4431
4431
if (JB_ROOT_COUNT (in )== 0 )
4432
4432
PG_RETURN_JSONB_P (in );
4433
4433
4434
- it = JsonbIteratorInit (& in -> root );
4434
+ it = JsonbIteratorInit (JsonbRoot ( in ) );
4435
4435
4436
4436
r = JsonbIteratorNext (& it ,& v , false);
4437
4437
Assert (r == WJB_BEGIN_ARRAY );
@@ -4502,7 +4502,7 @@ jsonb_set(PG_FUNCTION_ARGS)
4502
4502
if (path_len == 0 )
4503
4503
PG_RETURN_JSONB_P (in );
4504
4504
4505
- it = JsonbIteratorInit (& in -> root );
4505
+ it = JsonbIteratorInit (JsonbRoot ( in ) );
4506
4506
4507
4507
res = setPath (& it ,path_elems ,path_nulls ,path_len ,& st ,
4508
4508
0 ,newval ,create ?JB_PATH_CREATE :JB_PATH_REPLACE );
@@ -4614,7 +4614,7 @@ jsonb_delete_path(PG_FUNCTION_ARGS)
4614
4614
if (path_len == 0 )
4615
4615
PG_RETURN_JSONB_P (in );
4616
4616
4617
- it = JsonbIteratorInit (& in -> root );
4617
+ it = JsonbIteratorInit (JsonbRoot ( in ) );
4618
4618
4619
4619
res = setPath (& it ,path_elems ,path_nulls ,path_len ,& st ,
4620
4620
0 ,NULL ,JB_PATH_DELETE );
@@ -4657,7 +4657,7 @@ jsonb_insert(PG_FUNCTION_ARGS)
4657
4657
if (path_len == 0 )
4658
4658
PG_RETURN_JSONB_P (in );
4659
4659
4660
- it = JsonbIteratorInit (& in -> root );
4660
+ it = JsonbIteratorInit (JsonbRoot ( in ) );
4661
4661
4662
4662
res = setPath (& it ,path_elems ,path_nulls ,path_len ,& st ,0 ,newval ,
4663
4663
after ?JB_PATH_INSERT_AFTER :JB_PATH_INSERT_BEFORE );
@@ -5033,7 +5033,7 @@ parse_jsonb_index_flags(Jsonb *jb)
5033
5033
JsonbIteratorToken type ;
5034
5034
uint32 flags = 0 ;
5035
5035
5036
- it = JsonbIteratorInit (& jb -> root );
5036
+ it = JsonbIteratorInit (JsonbRoot ( jb ) );
5037
5037
5038
5038
type = JsonbIteratorNext (& it ,& v , false);
5039
5039
@@ -5101,7 +5101,7 @@ iterate_jsonb_values(Jsonb *jb, uint32 flags, void *state,
5101
5101
JsonbValue v ;
5102
5102
JsonbIteratorToken type ;
5103
5103
5104
- it = JsonbIteratorInit (& jb -> root );
5104
+ it = JsonbIteratorInit (JsonbRoot ( jb ) );
5105
5105
5106
5106
/*
5107
5107
* Just recursively iterating over jsonb and call callback on all
@@ -5241,7 +5241,7 @@ transform_jsonb_string_values(Jsonb *jsonb, void *action_state,
5241
5241
JsonbParseState * st = NULL ;
5242
5242
text * out ;
5243
5243
5244
- it = JsonbIteratorInit (& jsonb -> root );
5244
+ it = JsonbIteratorInit (JsonbRoot ( jsonb ) );
5245
5245
5246
5246
while ((type = JsonbIteratorNext (& it ,& v , false))!= WJB_DONE )
5247
5247
{