Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why PreparedStatement.deinit() isn't public? #17

Open
chung-leong opened this issue Jan 7, 2025 · 1 comment
Open

Why PreparedStatement.deinit() isn't public? #17

chung-leong opened this issue Jan 7, 2025 · 1 comment

Comments

@chung-leong
Copy link

Right now, if you keep a PreparedStatement around, you have no way of deinitializing it. Is there a reason why you can only deinit it through PrepareResult?

@speed2exe
Copy link
Owner

@chung-leong Thanks for feedback. It is common for users to instinctively call deinit on PrepareResult after initialization. Having deinit in PreparedStatement as public method may likely result in users trying to call it as well, resulting in double free, as PrepareResult.deinit will attempt to free PreparedStatement.

Admittedly, I have not considered the case of lingering PreparedStatement.
As a workaround (without code change), you can keep PrepareResult around, and use PerpareResult.stmt to get PreparedStatement.

Suggestions and PRs are welcomed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants