@@ -2864,15 +2864,13 @@ jsonbzIteratorInit(JsonContainer *jc)
28642864}
28652865
28662866static void
2867- jsonbzInit (JsonContainerData * jc , Datum value )
2867+ jsonbzInitFromCompresedDatum (JsonContainerData * jc , CompressedDatum * cd )
28682868{
28692869 CompressedJsonb * cjb = palloc (sizeof (* cjb ));
2870- CompressedDatum * cd = palloc (sizeof (* cd ));
28712870
28722871 cjb -> datum = cd ;
28732872 cjb -> offset = offsetof(Jsonb , root );
28742873
2875- CompressedDatumInit (cd , value );
28762874 if (!jsonb_partial_decompression )
28772875 CompressedDatumDecompressAll (cd );
28782876 else
@@ -2881,6 +2879,16 @@ jsonbzInit(JsonContainerData *jc, Datum value)
28812879 jsonbzInitContainer (jc , cjb , VARSIZE_ANY_EXHDR (cd -> data )); // cd->total_len - VARHDRSZ
28822880}
28832881
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+
28842892JsonContainerOps
28852893jsonbzContainerOps =
28862894{
@@ -2927,7 +2935,8 @@ DatumGetJsonbPC(Datum datum, Json *tmp, bool copy)
29272935
29282936 js = JsonExpand (tmp , (Datum ) 0 , false, & jsonbzContainerOps );
29292937
2930- jsonbzInit (& js -> root , datum );
2938+ jsonbzInitFromCompresedDatum (& js -> root ,
2939+ memcpy (palloc (sizeof (cd )), & cd , sizeof (cd )));
29312940
29322941 return js ;
29332942}
0 commit comments