File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -1735,15 +1735,27 @@ convertToJsonb(const JsonbValue *val, JsonValueEncoder encoder)
1735
1735
{
1736
1736
StringInfoData buffer ;
1737
1737
void * res ;
1738
+ MemoryContext tmpcxt ,
1739
+ oldcxt ;
1738
1740
1739
1741
/* Allocate an output buffer. It will be enlarged as needed */
1740
1742
initStringInfo (& buffer );
1741
1743
1742
1744
/* Make room for the varlena header */
1743
1745
reserveFromBuffer (& buffer , VARHDRSZ );
1744
1746
1747
+ tmpcxt = AllocSetContextCreate (CurrentMemoryContext ,
1748
+ "Json Encoding Context" ,
1749
+ ALLOCSET_DEFAULT_MINSIZE ,
1750
+ ALLOCSET_DEFAULT_INITSIZE ,
1751
+ ALLOCSET_DEFAULT_MAXSIZE );
1752
+ oldcxt = MemoryContextSwitchTo (tmpcxt );
1753
+
1745
1754
(* encoder )(& buffer , val );
1746
1755
1756
+ MemoryContextSwitchTo (oldcxt );
1757
+ MemoryContextDelete (tmpcxt );
1758
+
1747
1759
/*
1748
1760
* Note: the JEntry of the root is discarded. Therefore the root
1749
1761
* JsonbContainer struct must contain enough information to tell what kind
You can’t perform that action at this time.
0 commit comments