@@ -2864,15 +2864,13 @@ jsonbzIteratorInit(JsonContainer *jc)
2864
2864
}
2865
2865
2866
2866
static void
2867
- jsonbzInit (JsonContainerData * jc , Datum value )
2867
+ jsonbzInitFromCompresedDatum (JsonContainerData * jc , CompressedDatum * cd )
2868
2868
{
2869
2869
CompressedJsonb * cjb = palloc (sizeof (* cjb ));
2870
- CompressedDatum * cd = palloc (sizeof (* cd ));
2871
2870
2872
2871
cjb -> datum = cd ;
2873
2872
cjb -> offset = offsetof(Jsonb , root );
2874
2873
2875
- CompressedDatumInit (cd , value );
2876
2874
if (!jsonb_partial_decompression )
2877
2875
CompressedDatumDecompressAll (cd );
2878
2876
else
@@ -2881,6 +2879,16 @@ jsonbzInit(JsonContainerData *jc, Datum value)
2881
2879
jsonbzInitContainer (jc , cjb , VARSIZE_ANY_EXHDR (cd -> data )); // cd->total_len - VARHDRSZ
2882
2880
}
2883
2881
2882
+ static void
2883
+ jsonbzInit (JsonContainerData * jc , Datum value )
2884
+ {
2885
+ CompressedDatum * cd = palloc (sizeof (* cd ));
2886
+
2887
+ CompressedDatumInit (cd , value );
2888
+
2889
+ jsonbzInitFromCompresedDatum (jc , cd );
2890
+ }
2891
+
2884
2892
JsonContainerOps
2885
2893
jsonbzContainerOps =
2886
2894
{
@@ -2927,7 +2935,8 @@ DatumGetJsonbPC(Datum datum, Json *tmp, bool copy)
2927
2935
2928
2936
js = JsonExpand (tmp , (Datum ) 0 , false, & jsonbzContainerOps );
2929
2937
2930
- jsonbzInit (& js -> root , datum );
2938
+ jsonbzInitFromCompresedDatum (& js -> root ,
2939
+ memcpy (palloc (sizeof (cd )), & cd , sizeof (cd )));
2931
2940
2932
2941
return js ;
2933
2942
}
0 commit comments