@@ -2913,15 +2913,13 @@ jsonbzIteratorInit(JsonContainer *jc)
2913
2913
}
2914
2914
2915
2915
static void
2916
- jsonbzInit (JsonContainerData * jc , Datum value )
2916
+ jsonbzInitFromCompresedDatum (JsonContainerData * jc , CompressedDatum * cd )
2917
2917
{
2918
2918
CompressedJsonb * cjb = palloc (sizeof (* cjb ));
2919
- CompressedDatum * cd = palloc (sizeof (* cd ));
2920
2919
2921
2920
cjb -> datum = cd ;
2922
2921
cjb -> offset = offsetof(Jsonb , root );
2923
2922
2924
- CompressedDatumInit (cd , value );
2925
2923
if (!jsonb_partial_decompression )
2926
2924
CompressedDatumDecompressAll (cd );
2927
2925
else
@@ -2930,6 +2928,16 @@ jsonbzInit(JsonContainerData *jc, Datum value)
2930
2928
jsonbzInitContainer (jc , cjb , VARSIZE_ANY_EXHDR (cd -> data )); // cd->total_len - VARHDRSZ
2931
2929
}
2932
2930
2931
+ static void
2932
+ jsonbzInit (JsonContainerData * jc , Datum value )
2933
+ {
2934
+ CompressedDatum * cd = palloc (sizeof (* cd ));
2935
+
2936
+ CompressedDatumInit (cd , value );
2937
+
2938
+ jsonbzInitFromCompresedDatum (jc , cd );
2939
+ }
2940
+
2933
2941
JsonContainerOps
2934
2942
jsonbzContainerOps =
2935
2943
{
@@ -2973,7 +2981,8 @@ DatumGetJsonbPC(Datum datum, Json *tmp, bool copy)
2973
2981
2974
2982
js = JsonExpand (tmp , (Datum ) 0 , false, & jsonbzContainerOps );
2975
2983
2976
- jsonbzInit (& js -> root , datum );
2984
+ jsonbzInitFromCompresedDatum (& js -> root ,
2985
+ memcpy (palloc (sizeof (cd )), & cd , sizeof (cd )));
2977
2986
2978
2987
return js ;
2979
2988
}
0 commit comments