PyMySQL/mysqlclient

mysqlclient fails to build for MySQL >= 8.3.0

etripier opened this issue · 7 comments

Hi! I love your driver. It's fast and reliable.

Unfortunately, the MySQL team finally killed a couple of the APIs they've been threatening to remove for a while now - mysql_kill, mysql_shutdown, and mysql_ssl_set.

I fixed the issue here: etripier@ee1882e. I'd be more than happy to submit a PR to your repo.

diff --git a/src/MySQLdb/_mysql.c b/src/MySQLdb/_mysql.c
index 0612be2..4282ab3 100644
--- a/src/MySQLdb/_mysql.c
+++ b/src/MySQLdb/_mysql.c
@@ -524,7 +524,11 @@ _mysql_ConnectionObject_Initialize(
         mysql_options(&(self->connection), MYSQL_OPT_LOCAL_INFILE, (char *) &local_infile);

     if (ssl) {
-        mysql_ssl_set(&(self->connection), key, cert, ca, capath, cipher);
+        mysql_options(&(self->connection), MYSQL_OPT_SSL_KEY, key);
+        mysql_options(&(self->connection), MYSQL_OPT_SSL_CERT, cert);
+        mysql_options(&(self->connection), MYSQL_OPT_SSL_CA, ca);
+        mysql_options(&(self->connection), MYSQL_OPT_SSL_CAPATH, capath);
+        mysql_options(&(self->connection), MYSQL_OPT_SSL_CIPHER, cipher);
     }
     if (ssl_mode) {
 #ifdef HAVE_ENUM_MYSQL_OPT_SSL_MODE
@@ -1789,10 +1793,11 @@ _mysql_ConnectionObject_kill(
 {
     unsigned long pid;
     int r;
+    char query[50];
     if (!PyArg_ParseTuple(args, "k:kill", &pid)) return NULL;
     check_connection(self);
     Py_BEGIN_ALLOW_THREADS
-    r = mysql_kill(&(self->connection), pid);
+    r = mysql_query(&(self->connection), snprintf(query, 50, "KILL %d", pid));
     Py_END_ALLOW_THREADS
     if (r) return _mysql_Exception(self);
     Py_RETURN_NONE;
@@ -2008,7 +2013,7 @@ _mysql_ConnectionObject_shutdown(
     int r;
     check_connection(self);
     Py_BEGIN_ALLOW_THREADS
-    r = mysql_shutdown(&(self->connection), SHUTDOWN_DEFAULT);
+    r = mysql_query(&(self->connection), "SHUTDOWN");
     Py_END_ALLOW_THREADS
     if (r) return _mysql_Exception(self);
     Py_RETURN_NONE;

thanks.

Thanks!!! It worked for me!! :)

To install from etripier's commit:
pip install -e git+https://github.com/etripier/mysqlclient.git@ee1882e02e3c73910b1d6df86bbdce784edbb881#egg=mysqlclient

And don't trust me - make sure the commit id ee1...881 is what etripier links to above.

Deeply thanks!!

Question: How far back will your changes work? Will it work back for myself 5.6* series? MariaDB 5.5? We are slowly transitioning from Centos 7 - which reaches EOL this year. Will your changes break things?

mysql 5.6 series does define MYSQL_OPT_SSL *

I don't know. They are not supported version.
If you are interested in it, take your time to check them.

If you're using Homebrew, upgraded to 8.3.0 already, and aren't ready to upgrade your client library to 2.2.4, I put some simple instructions to get your dev environment working again: https://i-am-j.ag/blog/posts/python-mysql-8.3.0-homebrew/