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

Support MySQL 8 #13

Open Leonidas-from-XIV opened 6 years ago

Leonidas-from-XIV commented 6 years ago

What I have found was that my_bool was replaced by bool from stdbool.h, and MYSQL_SECURE_AUTH is now default and can't be selected and the VERIFY_CERTIFICATE options changed.

Maybe more. I don't quite know what the policy on supporting older versions of MySQL with this library is.

ygrek commented 4 years ago

if you have a patch to make it work with oracle mysql I will be happy to integrate it

LocutusOfBorg commented 4 years ago

Hello, what we are using in Ubuntu is a couple of patches: (this one should probably be changed in "sed s/my_bool/bool/g -i mysql_stubs.c", since we have only 7 total references to that old my_bool variable type)

Description: Reintroduce my_bool to fix build with MySQL 8
 (patch inspired from the one in cppdb 0.3.1+dfsg-8ubuntu2)
Author: Gianfranco Costamagna <locutusofborg@debian.org>, Andreas Hasenack <andreas@canonical.com>
Bug-Ubuntu: https://bugs.launchpad.net/bugs/1863026
Forwarded: no
Last-Update: 2020-02-21

--- mysql-ocaml-1.2.1.orig/mysql_stubs.c
+++ mysql-ocaml-1.2.1/mysql_stubs.c
@@ -71,6 +71,7 @@
 #define STMTval(x) (*(MYSQL_STMT**)Data_custom_val(x))
 #define ROWval(x) (*(row_t**)Data_custom_val(x))

+typedef bool my_bool;
 static void mysqlfailwith(char *err) Noreturn;
 static void mysqlfailmsg(const char *fmt, ...) Noreturn;

and the second one is:

Description: Drop support for options removed in MySQL 8.0
 These are no longer available in MySQL 8.0. There is already an "unknown
 option" default case, so it should be safe security-wise: anything still
 requesting these options will correctly fail.
Author: Robie Basak <robie.basak@canonical.com>
Origin: vendor
Forwarded: no
X-Not-Forwarded-Reason: work still in progress
Last-Update: 2018-07-16

--- a/mysql_stubs.c
+++ b/mysql_stubs.c
@@ -227,9 +227,13 @@
         {
           case  0: SET_OPTION_BOOL(OPT_LOCAL_INFILE);
           case  1: SET_OPTION_BOOL(OPT_RECONNECT);
+#if defined(MARIADB_BASE_VERSION) || MYSQL_VERSION_ID < 80000
           case  2: SET_OPTION_BOOL(OPT_SSL_VERIFY_SERVER_CERT);
+#endif
           case  3: SET_OPTION_BOOL(REPORT_DATA_TRUNCATION);
+#if defined(MARIADB_BASE_VERSION) || MYSQL_VERSION_ID < 80000
           case  4: SET_OPTION_BOOL(SECURE_AUTH);
+#endif
           case  5: SET_OPTION(OPT_PROTOCOL, &ml_mysql_protocol_type[Int_val(v)]);
           case  6: SET_OPTION_INT(OPT_CONNECT_TIMEOUT);
           case  7: SET_OPTION_INT(OPT_READ_TIMEOUT);
kit-ty-kate commented 2 years ago

ping @ygrek (see also https://github.com/ocaml/opam-repository/issues/22402)

I don't want to add patches to opam-repository and would much prefer if upstream could do a release instead

kit-ty-kate commented 1 year ago

ping @ygrek

edwintorok commented 1 year ago

FWIW a workaround on Ubuntu 22.04 is to do this (instead of what opam recommends by default): apt install libmariadb-dev-compat. That will install a mysql library that is compatible with this.