sqlx icon indicating copy to clipboard operation
sqlx copied to clipboard

[Row] Fix: db connection leakage in Err method

Open Chhekur opened this issue 2 years ago • 1 comments

Issue Outline: there is db connection leakage happening here, if someone makes a DB calls and doesn't really call any of the Scan methods where rows generally being closed via calling rows.Close() method and directly calls the Err() method over Row instance just to check the err in that case rows cursor connection is still alive and hence it leaks the db connection.

Proposed Solution: explicitly close the rows in the Err() method too so that it can be made sure that if someone directly calls this method without using any scanning method, still connection would be closed.

Chhekur avatar Jan 22 '23 14:01 Chhekur

Hello, @ardan-bkennedy, and I recently stepped in to help maintain this project. We are sorting the opened issues and pull requests and would like to know if you still NEED this merged. Thank you for your contribution.

I'm tempted to say that this is not a proper solution to the problem, as calling the method would always close the connection. This will break code that does a check using the method.

I think the solution for this would be to add a mention in the method documentation and mention that Close needs to be called when the error is not nil. What do you think?

dlsniper avatar Feb 01 '24 13:02 dlsniper