mwild1 / luadbi

Multi-backend SQL database library for Lua
MIT License
41 stars 14 forks source link

Postgres backend leaks prepared statements #51

Closed mwild1 closed 5 years ago

mwild1 commented 5 years ago

To reproduce: prepare, execute and close multiple SQL statements. Then, on the same connection, SELECT * FROM pg_prepared_statements - all the previously closed statements are still listed, even though they should have been DEALLOCATEd.

A bisect suggests the problem started with commit b47c4b8338ef093e7b4af8bac693553560d454f1.

mwild1 commented 5 years ago

@sparked435 I'm unable to reproduce the segfault that that commit aims to fix. Any tips?

If I revert the change (e.g. remove that if() guard) then all tests still pass ok.

mwild1 commented 5 years ago

Looking at the commit, is the logic not inverted? Is the logic meant to be "if the connection is not null, deallocate"? It looks like it's checking for a null connection instead?

sparked435 commented 5 years ago

To be completely honest, I can't remember making that commit. I had a lot going on March 2016...

I agree it looks like a case of inverted logic. Ok with me to merge the fix.

mwild1 commented 5 years ago

@sparked435 thanks!