@@ -196,6 +196,7 @@ static JsonbValue *fillCompressedJsonbValue(CompressedJsonx *cjb,
196196 JsonFieldPtr * ptr );
197197static JsonbContainerHeader * jsonxzDecompress (JsonContainer * jc );
198198static void jsonxzDecompressTo (CompressedJsonx * cjb , Size offset );
199+ static void jsonxzDecompressSlice (CompressedJsonx * cjb , Size offset , Size length );
199200static bool JsonContainerIsToasted (JsonContainer * jc ,
200201 JsonbToastedContainerPointerData * jbcptr );
201202static bool JsonContainerIsCompressed (JsonContainer * jc ,
@@ -796,7 +797,7 @@ JsonxIteratorInit(JsonContainer *cont, const JsonbContainerHeader *container,
796797
797798 /* decompress container header */
798799 if (cjb )
799- jsonxzDecompressTo (cjb , cjb -> offset + offsetof(JsonbContainerHeader , children ));
800+ jsonxzDecompressSlice (cjb , cjb -> offset , offsetof(JsonbContainerHeader , children ));
800801
801802 type = container -> header & JBC_TMASK ;
802803
@@ -843,7 +844,7 @@ JsonxIteratorInit(JsonContainer *cont, const JsonbContainerHeader *container,
843844 }
844845
845846 if (it -> dataProper && cjb )
846- jsonxzDecompressTo (cjb , cjb -> offset + ( it -> dataProper - (char * ) container ) );
847+ jsonxzDecompressSlice (cjb , cjb -> offset , it -> dataProper - (char * ) container );
847848
848849 return (JsonIterator * ) it ;
849850}
@@ -1785,7 +1786,7 @@ jsonxzDecompress(JsonContainer *jc)
17851786 JsonbDatum * jb = (JsonbDatum * ) cjb -> iter -> buf -> buf ;
17861787 JsonbContainerHeader * container = (JsonbContainerHeader * )((char * ) jb + cjb -> offset );
17871788
1788- jsonxzDecompressTo (cjb , cjb -> offset + jc -> len );
1789+ jsonxzDecompressSlice (cjb , cjb -> offset , jc -> len );
17891790
17901791 return container ;
17911792}
@@ -1826,7 +1827,7 @@ fillCompressedJsonbValue(CompressedJsonx *cjb,
18261827
18271828 cjb2 .offset = base_offset + offset ;
18281829
1829- jsonxzDecompressTo (cjb , cjb2 .offset + offsetof(JsonbContainerHeader , children ));
1830+ jsonxzDecompressSlice (cjb , cjb2 .offset , offsetof(JsonbContainerHeader , children ));
18301831 jsonxzInitContainer (cont , & cjb2 , NULL , length );
18311832 JsonValueInitBinary (result , cont );
18321833
@@ -1877,7 +1878,7 @@ findValueInCompressedJsonbObject(CompressedJsonx *cjb, Oid toasterid,
18771878 key .val .string .val = keystr ;
18781879 key .val .string .len = keylen ;
18791880
1880- jsonxzDecompressTo (cjb , base_offset );
1881+ jsonxzDecompressSlice (cjb , cjb -> offset , base_offset - cjb -> offset );
18811882
18821883 /* Binary search on object/pair keys *only* */
18831884 while (stopLow < stopHigh )
@@ -1944,7 +1945,7 @@ jsonxzFindKeyInObject(JsonContainer *jc, const char *key, int len,
19441945
19451946 CompressedDatumDecompress (cjb -> datum , cjb -> offset + offsetof(JsonbContainerHeader , header ));
19461947#else
1947- jsonxzDecompressTo (cjb , cjb -> offset + offsetof(JsonbContainerHeader , children ));
1948+ jsonxzDecompressSlice (cjb , cjb -> offset , offsetof(JsonbContainerHeader , children ));
19481949#endif
19491950
19501951 return findValueInCompressedJsonbObject (cjb , jc -> toasterid , key , len , res , ptr );
@@ -1968,11 +1969,11 @@ JsonbzArrayIteratorInit(JsonbzArrayIterator *it, CompressedJsonx *cjb,
19681969 JsonbDatum * jb = (JsonbDatum * ) cjb -> iter -> buf -> buf ;
19691970 const JsonbContainerHeader * jbc = (const JsonbContainerHeader * )((char * ) jb + cjb -> offset );
19701971
1971- //jsonxzDecompressTo (cjb, cjb->offset + ((char *) &jbc->children - (char *) jbc));
1972+ //jsonxzDecompressSlice (cjb, cjb->offset, ((char *) &jbc->children - (char *) jbc));
19721973
19731974 it -> count = (cjb -> header & JBC_CMASK );
19741975
1975- //jsonxzDecompressTo (cjb, cjb->offset + ((char *) &jbc->children[it->count] - (char *) jbc));
1976+ //jsonxzDecompressSlice (cjb, cjb->offset, ((char *) &jbc->children[it->count] - (char *) jbc));
19761977
19771978 it -> cjb = cjb ;
19781979 it -> container = jbc ;
@@ -1991,7 +1992,7 @@ JsonbzArrayIteratorNext(JsonbzArrayIterator *it, JsonValue *result)
19911992 if (it -> index >= it -> count )
19921993 return false;
19931994
1994- jsonxzDecompressTo (it -> cjb , (char * ) & jbc -> children [it -> count ] - (char * ) jb );
1995+ jsonxzDecompressSlice (it -> cjb , it -> cjb -> offset , (char * ) & jbc -> children [it -> count ] - (char * ) jb - it -> cjb -> offset );
19951996 fillCompressedJsonbValue (it -> cjb , it -> container , it -> toasterid , it -> index , it -> base_addr ,
19961997 it -> offset , result , NULL );
19971998
0 commit comments