This is an automated backport of #7088: Fix leaks with functions in DML.
The original issue is #7053.
This PR will be merged automatically after all the relevant CI checks pass. If this fix should not be backported, or will be backported manually, just close this PR. You can use the backport branch to add your changes, it won't be modified automatically anymore.
If plpgsql functions are used in DML queries then we were leaking 8KB for every invocation of that function. This can quickly add up.
The issue was that the "CurTransactionContext" was not getting cleaned up after every invocation. The reason was that we were inadvertantly allocating a temporary list in that context. Postgres then thought that this CurTransactionContext needs to be re-used further and kept it around. We now use a proper memory context to avoid this.
This is an automated backport of #7088: Fix leaks with functions in DML. The original issue is #7053. This PR will be merged automatically after all the relevant CI checks pass. If this fix should not be backported, or will be backported manually, just close this PR. You can use the backport branch to add your changes, it won't be modified automatically anymore.
For more details, please see the documentation
Original description
Fix leaks with functions in DML
If plpgsql functions are used in DML queries then we were leaking 8KB for every invocation of that function. This can quickly add up.
The issue was that the "CurTransactionContext" was not getting cleaned up after every invocation. The reason was that we were inadvertantly allocating a temporary list in that context. Postgres then thought that this CurTransactionContext needs to be re-used further and kept it around. We now use a proper memory context to avoid this.
Fixes
#7053