[ANN] OCaml-MariaDB 0.9.0

Hi

I’ve released a new version of OCaml-MariaDB. The main change is that now library users are expected to call Mariadb.library_end explicitly when they are done using the library. Previously this function was called automatically after Mariadb.close. While this is fine when linking to libmysqlclient, it breaks the Connector/C (libmariadbclient) when multiple database connections are instantiated. This problem was reported by Donovan Mueller.

This release also includes contributions by Petter Urkedal and Jan Pöschko.

Cheers,
Andre

Thanks for a nice MySQL client library with Lwt/Async support! :+1:

What are the implications of forgetting to do this?

Some memory would never be freed by the C library. I guess in most situations this shouldn’t really be a problem, as it would be called just before the program exits anyway.

Do you provide a with_mariadb wrapper function that can call close and library_end on exit or plan to provide one?

For close this should be simple but for library_end I’m not so sure, because the point where it can be called depends on the application. You could put the call in some sort of at_exit function if you don’t want to worry about forgetting it, but it really depends on your code.

OCaml-MariaDB is intended to be mostly a low level wrapper around the C client libraries, which is why it doesn’t have a lot of utility functions. The idea is to provide something that higher level libraries such as Caqti can use as a driver.

1 Like

Can library_end be called more than once? If so, you could set up an at_exit by default. That would make usability much better. Alternatively you could place it in a GC finalizer.

It can only be called once (at least when using the MariaDB C/Connector).