@@ -2850,15 +2850,13 @@ jsonbzIteratorInit(JsonContainer *jc)
28502850}
28512851
28522852static void
2853- jsonbzInit (JsonContainerData * jc , Datum value )
2853+ jsonbzInitFromCompresedDatum (JsonContainerData * jc , CompressedDatum * cd )
28542854{
28552855 CompressedJsonb * cjb = palloc (sizeof (* cjb ));
2856- CompressedDatum * cd = palloc (sizeof (* cd ));
28572856
28582857 cjb -> datum = cd ;
28592858 cjb -> offset = offsetof(Jsonb , root );
28602859
2861- CompressedDatumInit (cd , value );
28622860 if (!jsonb_partial_decompression )
28632861 CompressedDatumDecompressAll (cd );
28642862 else
@@ -2867,6 +2865,16 @@ jsonbzInit(JsonContainerData *jc, Datum value)
28672865 jsonbzInitContainer (jc , cjb , VARSIZE_ANY_EXHDR (cd -> data )); // cd->total_len - VARHDRSZ
28682866}
28692867
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+
28702878JsonContainerOps
28712879jsonbzContainerOps =
28722880{
@@ -2910,7 +2918,8 @@ DatumGetJsonbPC(Datum datum, Json *tmp, bool copy)
29102918
29112919 js = JsonExpand (tmp , (Datum ) 0 , false, & jsonbzContainerOps );
29122920
2913- jsonbzInit (& js -> root , datum );
2921+ jsonbzInitFromCompresedDatum (& js -> root ,
2922+ memcpy (palloc (sizeof (cd )), & cd , sizeof (cd )));
29142923
29152924 return js ;
29162925}
0 commit comments