ygrek / ocaml-mysql

OCaml bindings to libmysqlclient
https://ygrek.org.ua/p/ocaml-mysql
GNU Lesser General Public License v2.1
23 stars 11 forks source link

Multi-statement support #16

Open jamescheney opened 4 years ago

jamescheney commented 4 years ago

It is helpful for performance reasons to be able to send multiple statements (e.g. updates) for execution in a single request. MySQL 5.6 and above support multiple-statement execution.

However, ocaml-mysql does not provide a way to open a connection with the CLIENT_MULTI_STATEMENTS option. The lack of ability to do this is a blocking issue (effectively) for performance reasons for my use case. Allowing this should only involve changing a few lines of code similar to those relating to the CLIENT_FOUND_ROWS flag.

However, since CLIENT_MULTI_STATEMENTS automatically enables the CLIENT_MULTI_RESULTS option, a better solution might be to provide both options, since CLIENT_MULTI_RESULTS is also needed on its own for calling stored procedures that produce result sets. While my use case doesn't need multiple results, perhaps adding API calls to provide the needed access to the C API for retrieving multiple results would be worthwhile as well. (Indeed I can think of scenarios where sending multiple queries for execution simultaneously would be useful.)