Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 87f2ad1

Browse files
committed
Fix plpgsql to release SPI plans when a function or DO block is freed.
This fixes the gripe I made a few months ago about DO blocks getting slower with repeated use. At least, it fixes it for the case where the DO block isn't aborted by an error. We could try running plpgsql_free_function_memory() even during error exit, but that seems a bit scary since it makes a lot of presumptions about the data structures being in good shape. It's probably reasonable to assume that repeated failures of DO blocks isn't a performance-critical case.
1 parent de592e2 commit 87f2ad1

File tree

4 files changed

+411
-5
lines changed

4 files changed

+411
-5
lines changed

src/pl/plpgsql/src/pl_comp.c

+2-5
Original file line numberDiff line numberDiff line change
@@ -2417,11 +2417,8 @@ delete_function(PLpgSQL_function *func)
24172417
plpgsql_HashTableDelete(func);
24182418

24192419
/* release the function's storage if safe and not done already */
2420-
if (func->use_count == 0 && func->fn_cxt)
2421-
{
2422-
MemoryContextDelete(func->fn_cxt);
2423-
func->fn_cxt = NULL;
2424-
}
2420+
if (func->use_count == 0)
2421+
plpgsql_free_function_memory(func);
24252422
}
24262423

24272424
/* exported so we can call it from plpgsql_init() */

0 commit comments

Comments
 (0)