@@ -2850,15 +2850,13 @@ jsonbzIteratorInit(JsonContainer *jc)
2850
2850
}
2851
2851
2852
2852
static void
2853
- jsonbzInit (JsonContainerData * jc , Datum value )
2853
+ jsonbzInitFromCompresedDatum (JsonContainerData * jc , CompressedDatum * cd )
2854
2854
{
2855
2855
CompressedJsonb * cjb = palloc (sizeof (* cjb ));
2856
- CompressedDatum * cd = palloc (sizeof (* cd ));
2857
2856
2858
2857
cjb -> datum = cd ;
2859
2858
cjb -> offset = offsetof(Jsonb , root );
2860
2859
2861
- CompressedDatumInit (cd , value );
2862
2860
if (!jsonb_partial_decompression )
2863
2861
CompressedDatumDecompressAll (cd );
2864
2862
else
@@ -2867,6 +2865,16 @@ jsonbzInit(JsonContainerData *jc, Datum value)
2867
2865
jsonbzInitContainer (jc , cjb , VARSIZE_ANY_EXHDR (cd -> data )); // cd->total_len - VARHDRSZ
2868
2866
}
2869
2867
2868
+ static void
2869
+ jsonbzInit (JsonContainerData * jc , Datum value )
2870
+ {
2871
+ CompressedDatum * cd = palloc (sizeof (* cd ));
2872
+
2873
+ CompressedDatumInit (cd , value );
2874
+
2875
+ jsonbzInitFromCompresedDatum (jc , cd );
2876
+ }
2877
+
2870
2878
JsonContainerOps
2871
2879
jsonbzContainerOps =
2872
2880
{
@@ -2910,7 +2918,8 @@ DatumGetJsonbPC(Datum datum, Json *tmp, bool copy)
2910
2918
2911
2919
js = JsonExpand (tmp , (Datum ) 0 , false, & jsonbzContainerOps );
2912
2920
2913
- jsonbzInit (& js -> root , datum );
2921
+ jsonbzInitFromCompresedDatum (& js -> root ,
2922
+ memcpy (palloc (sizeof (cd )), & cd , sizeof (cd )));
2914
2923
2915
2924
return js ;
2916
2925
}
0 commit comments