model-writtenrun 7784 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Jeff Janes reported that logging every nested statement with auto_explain caused memory to accumulate in a SQL function context until the OOM killer intervened #1, and confirmed the problem on both HEAD and PostgreSQL 12.5 #2.
- Japin Li traced the leak to EXPLAIN allocations in the caller's long-lived context and supplied a working patch that temporarily switches to the executor's per-query context #3.
- Tom Lane explained that the hook runs before standard_ExecutorEnd switches contexts and requested moving the switch outward to cover InstrEndLoop as well, even though that function did not currently allocate memory #4.
- Tom Lane committed Japin Li's patch with the broader context-switch scope, an explanatory comment, and removal of the now-unnecessary explicit output-string free as 5c0f7cc544, with backports to all supported branches.
- Japin Li thanked Tom Lane for the review and clarification in the final message #5; the fix had landed and no further work remained pending in the thread.