Fix memory management for postgres in edge cases#89
Fix memory management for postgres in edge cases#89liuzicheng1987 merged 1 commit intogetml:mainfrom mcraveiro:main
Conversation
Copy commandFor what it's worth, here is the Gemini advice on the COPY command:
|
|
@mcraveiro , cool, thank you so much. I will merge this and over the next couple of days I will implement a more robust RAII-based strategy for all database connectors, to make sure sure we cover all potential edge cases that we might see in the future. But thank you so much for raising this and for providing a fix. |
Hi sqlgen developers,
As discussed in [1], I encountered some issues with memory management for Postgres in v0.3.0 and v0.4.0. If you recall, I had created a patch [2] to fix those problems. When I tried to raise a PR I noticed
mainhas moved on a fair bit since then, so some parts of the patch are no longer needed and those that still apply needed some changes. At any rate, I updated the patch to fix the current state ofmain, which this PR contains for your perusal.With regards to RAII: the code is a tad complex and I am by no means an expert in libpq, so I'm afraid I was not brave enough to attempt implementing this as you had suggested in the discussion (a-la [3]). At any rate, even if you embark on such a clean up, I think it's still best to apply some version of this patch since it at least solves the immediate problems and makes the "correct fix" slightly less urgent.
One final point: You may find the
ROLLBACKa bit puzzling. I added it on the advice of Gemini, as follows (verbatim):[1] #88
[2] Proposed fix to this round of leaks
[3] DuckDBResult.hpp