@@ -570,7 +570,7 @@ jsonb_object_keys(PG_FUNCTION_ARGS)
570
570
state -> sent_count = 0 ;
571
571
state -> result = palloc (state -> result_size * sizeof (char * ));
572
572
573
- it = JsonbIteratorInit (& jb -> root );
573
+ it = JsonbIteratorInit (JsonbRoot ( jb ) );
574
574
575
575
while ((r = JsonbIteratorNext (& it , & v , skipNested )) != WJB_DONE )
576
576
{
@@ -826,7 +826,7 @@ jsonb_object_field(PG_FUNCTION_ARGS)
826
826
if (!JB_ROOT_IS_OBJECT (jb ))
827
827
PG_RETURN_NULL ();
828
828
829
- v = getKeyJsonValueFromContainer (& jb -> root ,
829
+ v = getKeyJsonValueFromContainer (JsonbRoot ( jb ) ,
830
830
VARDATA_ANY (key ),
831
831
VARSIZE_ANY_EXHDR (key ),
832
832
& vbuf );
@@ -864,7 +864,7 @@ jsonb_object_field_text(PG_FUNCTION_ARGS)
864
864
if (!JB_ROOT_IS_OBJECT (jb ))
865
865
PG_RETURN_NULL ();
866
866
867
- v = getKeyJsonValueFromContainer (& jb -> root ,
867
+ v = getKeyJsonValueFromContainer (JsonbRoot ( jb ) ,
868
868
VARDATA_ANY (key ),
869
869
VARSIZE_ANY_EXHDR (key ),
870
870
& vbuf );
@@ -911,7 +911,7 @@ jsonb_array_element(PG_FUNCTION_ARGS)
911
911
element += nelements ;
912
912
}
913
913
914
- v = getIthJsonbValueFromContainer (& jb -> root , element );
914
+ v = getIthJsonbValueFromContainer (JsonbRoot ( jb ) , element );
915
915
if (v != NULL )
916
916
PG_RETURN_JSONB_P (JsonbValueToJsonb (v ));
917
917
@@ -954,7 +954,7 @@ jsonb_array_element_text(PG_FUNCTION_ARGS)
954
954
element += nelements ;
955
955
}
956
956
957
- v = getIthJsonbValueFromContainer (& jb -> root , element );
957
+ v = getIthJsonbValueFromContainer (JsonbRoot ( jb ) , element );
958
958
959
959
if (v != NULL && v -> type != jbvNull )
960
960
PG_RETURN_TEXT_P (JsonbValueAsText (v ));
@@ -1468,7 +1468,7 @@ get_jsonb_path_all(FunctionCallInfo fcinfo, bool as_text)
1468
1468
Datum
1469
1469
jsonb_get_element (Jsonb * jb , Datum * path , int npath , bool * isnull , bool as_text )
1470
1470
{
1471
- JsonbContainer * container = & jb -> root ;
1471
+ JsonbContainer * container = JsonbRoot ( jb ) ;
1472
1472
JsonbValue * jbvp = NULL ;
1473
1473
int i ;
1474
1474
bool have_object = false,
@@ -1503,7 +1503,7 @@ jsonb_get_element(Jsonb *jb, Datum *path, int npath, bool *isnull, bool as_text)
1503
1503
{
1504
1504
return PointerGetDatum (cstring_to_text (JsonbToCString (NULL ,
1505
1505
container ,
1506
- VARSIZE (jb ))));
1506
+ JsonbGetSize (jb ))));
1507
1507
}
1508
1508
else
1509
1509
{
@@ -1623,7 +1623,7 @@ jsonb_set_element(Jsonb *jb, Datum *path, int path_len,
1623
1623
if (newval -> type == jbvArray && newval -> val .array .rawScalar )
1624
1624
* newval = newval -> val .array .elems [0 ];
1625
1625
1626
- it = JsonbIteratorInit (& jb -> root );
1626
+ it = JsonbIteratorInit (JsonbRoot ( jb ) );
1627
1627
1628
1628
res = setPath (& it , path , path_nulls , path_len , & state , 0 , newval ,
1629
1629
JB_PATH_CREATE | JB_PATH_FILL_GAPS |
@@ -1927,7 +1927,7 @@ each_worker_jsonb(FunctionCallInfo fcinfo, const char *funcname, bool as_text)
1927
1927
"jsonb_each temporary cxt" ,
1928
1928
ALLOCSET_DEFAULT_SIZES );
1929
1929
1930
- it = JsonbIteratorInit (& jb -> root );
1930
+ it = JsonbIteratorInit (JsonbRoot ( jb ) );
1931
1931
1932
1932
while ((r = JsonbIteratorNext (& it , & v , skipNested )) != WJB_DONE )
1933
1933
{
@@ -2171,7 +2171,7 @@ elements_worker_jsonb(FunctionCallInfo fcinfo, const char *funcname,
2171
2171
"jsonb_array_elements temporary cxt" ,
2172
2172
ALLOCSET_DEFAULT_SIZES );
2173
2173
2174
- it = JsonbIteratorInit (& jb -> root );
2174
+ it = JsonbIteratorInit (JsonbRoot ( jb ) );
2175
2175
2176
2176
while ((r = JsonbIteratorNext (& it , & v , skipNested )) != WJB_DONE )
2177
2177
{
@@ -2928,7 +2928,7 @@ populate_scalar(ScalarIOData *io, Oid typid, int32 typmod, JsValue *jsv)
2928
2928
*/
2929
2929
Jsonb * jsonb = JsonbValueToJsonb (jbv );
2930
2930
2931
- str = JsonbToCString (NULL , & jsonb -> root , VARSIZE (jsonb ));
2931
+ str = JsonbToCString (NULL , JsonbRoot ( jsonb ), JsonbGetSize (jsonb ));
2932
2932
}
2933
2933
else if (jbv -> type == jbvString ) /* quotes are stripped */
2934
2934
str = pnstrdup (jbv -> val .string .val , jbv -> val .string .len );
@@ -3487,7 +3487,7 @@ populate_record_worker(FunctionCallInfo fcinfo, const char *funcname,
3487
3487
3488
3488
/* fill binary jsonb value pointing to jb */
3489
3489
jbv .type = jbvBinary ;
3490
- jbv .val .binary .data = & jb -> root ;
3490
+ jbv .val .binary .data = JsonbRoot ( jb ) ;
3491
3491
jbv .val .binary .len = VARSIZE (jb ) - VARHDRSZ ;
3492
3492
}
3493
3493
@@ -3850,7 +3850,7 @@ populate_recordset_worker(FunctionCallInfo fcinfo, const char *funcname,
3850
3850
errmsg ("cannot call %s on a non-array" ,
3851
3851
funcname )));
3852
3852
3853
- it = JsonbIteratorInit (& jb -> root );
3853
+ it = JsonbIteratorInit (JsonbRoot ( jb ) );
3854
3854
3855
3855
while ((r = JsonbIteratorNext (& it , & v , skipNested )) != WJB_DONE )
3856
3856
{
@@ -4187,7 +4187,7 @@ jsonb_strip_nulls(PG_FUNCTION_ARGS)
4187
4187
if (JB_ROOT_IS_SCALAR (jb ))
4188
4188
PG_RETURN_JSONB_P (jb );
4189
4189
4190
- it = JsonbIteratorInit (& jb -> root );
4190
+ it = JsonbIteratorInit (JsonbRoot ( jb ) );
4191
4191
4192
4192
while ((type = JsonbIteratorNext (& it , & v , false)) != WJB_DONE )
4193
4193
{
@@ -4236,7 +4236,7 @@ jsonb_pretty(PG_FUNCTION_ARGS)
4236
4236
Jsonb * jb = PG_GETARG_JSONB_P (0 );
4237
4237
StringInfo str = makeStringInfo ();
4238
4238
4239
- JsonbToCStringIndent (str , & jb -> root , VARSIZE (jb ));
4239
+ JsonbToCStringIndent (str , JsonbRoot ( jb ), JsonbGetSize (jb ));
4240
4240
4241
4241
PG_RETURN_TEXT_P (cstring_to_text_with_len (str -> data , str -> len ));
4242
4242
}
@@ -4270,8 +4270,8 @@ jsonb_concat(PG_FUNCTION_ARGS)
4270
4270
PG_RETURN_JSONB_P (jb1 );
4271
4271
}
4272
4272
4273
- it1 = JsonbIteratorInit (& jb1 -> root );
4274
- it2 = JsonbIteratorInit (& jb2 -> root );
4273
+ it1 = JsonbIteratorInit (JsonbRoot ( jb1 ) );
4274
+ it2 = JsonbIteratorInit (JsonbRoot ( jb2 ) );
4275
4275
4276
4276
res = IteratorConcat (& it1 , & it2 , & state );
4277
4277
@@ -4309,7 +4309,7 @@ jsonb_delete(PG_FUNCTION_ARGS)
4309
4309
if (JB_ROOT_COUNT (in ) == 0 )
4310
4310
PG_RETURN_JSONB_P (in );
4311
4311
4312
- it = JsonbIteratorInit (& in -> root );
4312
+ it = JsonbIteratorInit (JsonbRoot ( in ) );
4313
4313
4314
4314
while ((r = JsonbIteratorNext (& it , & v , skipNested )) != WJB_DONE )
4315
4315
{
@@ -4373,7 +4373,7 @@ jsonb_delete_array(PG_FUNCTION_ARGS)
4373
4373
if (keys_len == 0 )
4374
4374
PG_RETURN_JSONB_P (in );
4375
4375
4376
- it = JsonbIteratorInit (& in -> root );
4376
+ it = JsonbIteratorInit (JsonbRoot ( in ) );
4377
4377
4378
4378
while ((r = JsonbIteratorNext (& it , & v , skipNested )) != WJB_DONE )
4379
4379
{
@@ -4452,7 +4452,7 @@ jsonb_delete_idx(PG_FUNCTION_ARGS)
4452
4452
if (JB_ROOT_COUNT (in ) == 0 )
4453
4453
PG_RETURN_JSONB_P (in );
4454
4454
4455
- it = JsonbIteratorInit (& in -> root );
4455
+ it = JsonbIteratorInit (JsonbRoot ( in ) );
4456
4456
4457
4457
r = JsonbIteratorNext (& it , & v , false);
4458
4458
Assert (r == WJB_BEGIN_ARRAY );
@@ -4525,7 +4525,7 @@ jsonb_set(PG_FUNCTION_ARGS)
4525
4525
if (path_len == 0 )
4526
4526
PG_RETURN_JSONB_P (in );
4527
4527
4528
- it = JsonbIteratorInit (& in -> root );
4528
+ it = JsonbIteratorInit (JsonbRoot ( in ) );
4529
4529
4530
4530
res = setPath (& it , path_elems , path_nulls , path_len , & st ,
4531
4531
0 , & newval , create ? JB_PATH_CREATE : JB_PATH_REPLACE );
@@ -4636,7 +4636,7 @@ jsonb_delete_path(PG_FUNCTION_ARGS)
4636
4636
if (path_len == 0 )
4637
4637
PG_RETURN_JSONB_P (in );
4638
4638
4639
- it = JsonbIteratorInit (& in -> root );
4639
+ it = JsonbIteratorInit (JsonbRoot ( in ) );
4640
4640
4641
4641
res = setPath (& it , path_elems , path_nulls , path_len , & st ,
4642
4642
0 , NULL , JB_PATH_DELETE );
@@ -4681,7 +4681,7 @@ jsonb_insert(PG_FUNCTION_ARGS)
4681
4681
if (path_len == 0 )
4682
4682
PG_RETURN_JSONB_P (in );
4683
4683
4684
- it = JsonbIteratorInit (& in -> root );
4684
+ it = JsonbIteratorInit (JsonbRoot ( in ) );
4685
4685
4686
4686
res = setPath (& it , path_elems , path_nulls , path_len , & st , 0 , & newval ,
4687
4687
after ? JB_PATH_INSERT_AFTER : JB_PATH_INSERT_BEFORE );
@@ -5168,7 +5168,7 @@ parse_jsonb_index_flags(Jsonb *jb)
5168
5168
JsonbIteratorToken type ;
5169
5169
uint32 flags = 0 ;
5170
5170
5171
- it = JsonbIteratorInit (& jb -> root );
5171
+ it = JsonbIteratorInit (JsonbRoot ( jb ) );
5172
5172
5173
5173
type = JsonbIteratorNext (& it , & v , false);
5174
5174
@@ -5236,7 +5236,7 @@ iterate_jsonb_values(Jsonb *jb, uint32 flags, void *state,
5236
5236
JsonbValue v ;
5237
5237
JsonbIteratorToken type ;
5238
5238
5239
- it = JsonbIteratorInit (& jb -> root );
5239
+ it = JsonbIteratorInit (JsonbRoot ( jb ) );
5240
5240
5241
5241
/*
5242
5242
* Just recursively iterating over jsonb and call callback on all
@@ -5376,7 +5376,7 @@ transform_jsonb_string_values(Jsonb *jsonb, void *action_state,
5376
5376
JsonbParseState * st = NULL ;
5377
5377
text * out ;
5378
5378
5379
- it = JsonbIteratorInit (& jsonb -> root );
5379
+ it = JsonbIteratorInit (JsonbRoot ( jsonb ) );
5380
5380
5381
5381
while ((type = JsonbIteratorNext (& it , & v , false)) != WJB_DONE )
5382
5382
{
0 commit comments