-
Notifications
You must be signed in to change notification settings - Fork 18
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
Retrieve statement metadata after statement execution #41
Conversation
dc7acea
to
6f44585
Compare
I've rebased this on master, and taken into account the comments on #39. Specifically mysql_free_result is replaced by mysql_free_result_start and mysql_free_result_cont in the non-blocking implementation. |
6f44585
to
d17dd4c
Compare
I realised this is not needed since freeing the metadata should never block. I've restored the original changes rebased on master. For the "non-blocking" version (which isn't needed), see: master...apeschar:insert-returning-new This PR should also fix #29 (at least if leaking the metadata is all) and supplant #39 without causing segfaults. |
I did some testing with the tweaks to the tests from #29. This fixes the memory leak for |
ocaml-community#41 * apeschar/insert-returning: Free statement metadata in blocking implementation Restore mysql_free_result binding Use free_meta in nonblocking Reload meta after each execute Delay mysql_stmt_result_metadata until after execute
verified it fixes memory leak |
Awesome, thanks! |
CHANGES: - Added `Stmt.start_txn` (ocaml-community/ocaml-mariadb#59 by Corentin Leruth). - Added `Res.insert_id` as binding for `mysql_stmt_insert_id` (ocaml-community/ocaml-mariadb#58 by Corentin Leruth). - Updated to support recent OCaml versions (ocaml-community/ocaml-mariadb#45 by @kit-ty-kate). - Fixed too-early retrieval of statement metadata (ocaml-community/ocaml-mariadb#41 by Albert Peschar). - Fixed decoding bug for the integer type (ocaml-community/ocaml-mariadb#54 by Raman Varabets, tested by ocaml-community/ocaml-mariadb#61 by Corentin Leruth). - Fixed a memory leaks related to result metadata (ocaml-community/ocaml-mariadb#39 by Albert Peschar). - The build system is now dune and dune-configurator (ocaml-community/ocaml-mariadb#52 by Petter A. Urkedal) and some of the examples have been converted to a test suite (ocaml-community/ocaml-mariadb#60 by Petter A. Urkedal). - The project has been transferred to ocaml-community with Petter A. Urkedal as the new maintainer.
CHANGES: - Added `Stmt.start_txn` (ocaml-community/ocaml-mariadb#59 by Corentin Leruth). - Added `Res.insert_id` as binding for `mysql_stmt_insert_id` (ocaml-community/ocaml-mariadb#58 by Corentin Leruth). - Updated to support recent OCaml versions (ocaml-community/ocaml-mariadb#45 by @kit-ty-kate). - Fixed too-early retrieval of statement metadata (ocaml-community/ocaml-mariadb#41 by Albert Peschar). - Fixed decoding bug for the integer type (ocaml-community/ocaml-mariadb#54 by Raman Varabets, tested by ocaml-community/ocaml-mariadb#61 by Corentin Leruth). - Fixed a memory leaks related to result metadata (ocaml-community/ocaml-mariadb#39 by Albert Peschar). - The build system is now dune and dune-configurator (ocaml-community/ocaml-mariadb#52 by Petter A. Urkedal) and some of the examples have been converted to a test suite (ocaml-community/ocaml-mariadb#60 by Petter A. Urkedal). - The project has been transferred to ocaml-community with Petter A. Urkedal as the new maintainer.
CHANGES: - Added `Stmt.start_txn` (ocaml-community/ocaml-mariadb#59 by Corentin Leruth). - Added `Res.insert_id` as binding for `mysql_stmt_insert_id` (ocaml-community/ocaml-mariadb#58 by Corentin Leruth). - Updated to support recent OCaml versions (ocaml-community/ocaml-mariadb#45 by @kit-ty-kate). - Fixed too-early retrieval of statement metadata (ocaml-community/ocaml-mariadb#41 by Albert Peschar). - Fixed decoding bug for the integer type (ocaml-community/ocaml-mariadb#54 by Raman Varabets, tested by ocaml-community/ocaml-mariadb#61 by Corentin Leruth). - Fixed a memory leaks related to result metadata (ocaml-community/ocaml-mariadb#39 by Albert Peschar). - The build system is now dune and dune-configurator (ocaml-community/ocaml-mariadb#52 by Petter A. Urkedal) and some of the examples have been converted to a test suite (ocaml-community/ocaml-mariadb#60 by Petter A. Urkedal). - The project has been transferred to ocaml-community with Petter A. Urkedal as the new maintainer.
Currently, we get the result metadata immediately after preparing the statement. But this metadata is not guaranteed to match the actual result. And in case of
INSERT ... RETURNING
, it does not.MySQL documentation mentions (emphasis mine):
And most ≠ all.
So this PR reloads the result metadata after each statement execution.
This fixes #33, and also ensures correctness of the row structure if table or view definitions change after statement preparation. Also see that issue for reproduction steps.