@@ -2913,15 +2913,13 @@ jsonbzIteratorInit(JsonContainer *jc)
29132913}
29142914
29152915static void
2916- jsonbzInit (JsonContainerData * jc , Datum value )
2916+ jsonbzInitFromCompresedDatum (JsonContainerData * jc , CompressedDatum * cd )
29172917{
29182918 CompressedJsonb * cjb = palloc (sizeof (* cjb ));
2919- CompressedDatum * cd = palloc (sizeof (* cd ));
29202919
29212920 cjb -> datum = cd ;
29222921 cjb -> offset = offsetof(Jsonb , root );
29232922
2924- CompressedDatumInit (cd , value );
29252923 if (!jsonb_partial_decompression )
29262924 CompressedDatumDecompressAll (cd );
29272925 else
@@ -2930,6 +2928,16 @@ jsonbzInit(JsonContainerData *jc, Datum value)
29302928 jsonbzInitContainer (jc , cjb , VARSIZE_ANY_EXHDR (cd -> data )); // cd->total_len - VARHDRSZ
29312929}
29322930
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+
29332941JsonContainerOps
29342942jsonbzContainerOps =
29352943{
@@ -2973,7 +2981,8 @@ DatumGetJsonbPC(Datum datum, Json *tmp, bool copy)
29732981
29742982 js = JsonExpand (tmp , (Datum ) 0 , false, & jsonbzContainerOps );
29752983
2976- jsonbzInit (& js -> root , datum );
2984+ jsonbzInitFromCompresedDatum (& js -> root ,
2985+ memcpy (palloc (sizeof (cd )), & cd , sizeof (cd )));
29772986
29782987 return js ;
29792988}
0 commit comments