File tree 1 file changed +12
-0
lines changed
1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -1672,15 +1672,27 @@ convertToJsonb(const JsonbValue *val, JsonValueEncoder encoder)
1672
1672
{
1673
1673
StringInfoData buffer ;
1674
1674
void * res ;
1675
+ MemoryContext tmpcxt ,
1676
+ oldcxt ;
1675
1677
1676
1678
/* Allocate an output buffer. It will be enlarged as needed */
1677
1679
initStringInfo (& buffer );
1678
1680
1679
1681
/* Make room for the varlena header */
1680
1682
reserveFromBuffer (& buffer , VARHDRSZ );
1681
1683
1684
+ tmpcxt = AllocSetContextCreate (CurrentMemoryContext ,
1685
+ "Json Encoding Context" ,
1686
+ ALLOCSET_DEFAULT_MINSIZE ,
1687
+ ALLOCSET_DEFAULT_INITSIZE ,
1688
+ ALLOCSET_DEFAULT_MAXSIZE );
1689
+ oldcxt = MemoryContextSwitchTo (tmpcxt );
1690
+
1682
1691
(* encoder )(& buffer , val );
1683
1692
1693
+ MemoryContextSwitchTo (oldcxt );
1694
+ MemoryContextDelete (tmpcxt );
1695
+
1684
1696
/*
1685
1697
* Note: the JEntry of the root is discarded. Therefore the root
1686
1698
* JsonbContainer struct must contain enough information to tell what kind
You can’t perform that action at this time.
0 commit comments