From e3176e0bffc11730f85db9e7e829456a7f2a7489 Mon Sep 17 00:00:00 2001 From: jca Date: Wed, 8 May 2019 22:33:32 +0000 Subject: [PATCH] Fix build with recent mariadb releases. No more 'reconnect' member in struct MYSQL, use mysql_options() and mysql_get_options() to set/get the autoreconnect setting. Same approach as in databases/py-mysqlclient. --- databases/py-mysql/Makefile | 4 +- databases/py-mysql/patches/patch-_mysql_c | 21 ++++-- databases/ruby-mysql/Makefile | 4 +- .../patches/patch-ext_mysql_api_mysql_c | 66 +++++++++++++++++-- 4 files changed, 83 insertions(+), 12 deletions(-) diff --git a/databases/py-mysql/Makefile b/databases/py-mysql/Makefile index d558a205c5d..33a96d83bd7 100644 --- a/databases/py-mysql/Makefile +++ b/databases/py-mysql/Makefile @@ -1,11 +1,11 @@ -# $OpenBSD: Makefile,v 1.52 2016/04/16 16:35:59 shadchin Exp $ +# $OpenBSD: Makefile,v 1.53 2019/05/08 22:33:32 jca Exp $ COMMENT = Python interface to MySQL MODPY_EGG_VERSION = 1.2.5 DISTNAME = MySQL-python-${MODPY_EGG_VERSION} PKGNAME = py-mysql-${MODPY_EGG_VERSION} -REVISION = 4 +REVISION = 5 CATEGORIES = databases diff --git a/databases/py-mysql/patches/patch-_mysql_c b/databases/py-mysql/patches/patch-_mysql_c index 8366631a7c6..ed73f2ae06d 100644 --- a/databases/py-mysql/patches/patch-_mysql_c +++ b/databases/py-mysql/patches/patch-_mysql_c @@ -1,7 +1,20 @@ -$OpenBSD: patch-_mysql_c,v 1.4 2014/09/03 13:43:39 benoit Exp $ ---- _mysql.c.orig Thu Jan 2 13:52:50 2014 -+++ _mysql.c Wed Sep 3 13:57:17 2014 -@@ -2079,7 +2079,7 @@ +$OpenBSD: patch-_mysql_c,v 1.5 2019/05/08 22:33:32 jca Exp $ +Index: _mysql.c +--- _mysql.c.orig ++++ _mysql.c +@@ -2002,7 +2002,10 @@ _mysql_ConnectionObject_ping( + int r, reconnect = -1; + if (!PyArg_ParseTuple(args, "|I", &reconnect)) return NULL; + check_connection(self); +- if ( reconnect != -1 ) self->connection.reconnect = reconnect; ++ if (reconnect != -1) { ++ my_bool recon = reconnect; ++ mysql_options(&self->connection, MYSQL_OPT_RECONNECT, &recon); ++ } + Py_BEGIN_ALLOW_THREADS + r = mysql_ping(&(self->connection)); + Py_END_ALLOW_THREADS +@@ -2079,7 +2082,7 @@ _mysql_ConnectionObject_shutdown( check_connection(self); Py_BEGIN_ALLOW_THREADS r = mysql_shutdown(&(self->connection) diff --git a/databases/ruby-mysql/Makefile b/databases/ruby-mysql/Makefile index eb75a718e45..6823a7e6652 100644 --- a/databases/ruby-mysql/Makefile +++ b/databases/ruby-mysql/Makefile @@ -1,9 +1,9 @@ -# $OpenBSD: Makefile,v 1.36 2018/06/13 22:26:52 jeremy Exp $ +# $OpenBSD: Makefile,v 1.37 2019/05/08 22:33:32 jca Exp $ COMMENT= access a MySQL database from Ruby DISTNAME= mysql-2.9.1 -REVISION= 2 +REVISION= 3 CATEGORIES= databases HOMEPAGE= http://tmtm.org/mysql/ruby/ diff --git a/databases/ruby-mysql/patches/patch-ext_mysql_api_mysql_c b/databases/ruby-mysql/patches/patch-ext_mysql_api_mysql_c index c00722588ea..19266e46805 100644 --- a/databases/ruby-mysql/patches/patch-ext_mysql_api_mysql_c +++ b/databases/ruby-mysql/patches/patch-ext_mysql_api_mysql_c @@ -1,9 +1,11 @@ -$OpenBSD: patch-ext_mysql_api_mysql_c,v 1.2 2017/01/07 18:09:28 jeremy Exp $ +$OpenBSD: patch-ext_mysql_api_mysql_c,v 1.3 2019/05/08 22:33:32 jca Exp $ Allow building with ruby 2.4+. +Allow building with recent mariadb releases. ---- ext/mysql_api/mysql.c.orig Wed Dec 31 16:00:00 1969 -+++ ext/mysql_api/mysql.c Sat Jan 7 10:06:36 2017 +Index: ext/mysql_api/mysql.c +--- ext/mysql_api/mysql.c.orig ++++ ext/mysql_api/mysql.c @@ -3,6 +3,11 @@ */ @@ -16,7 +18,63 @@ Allow building with ruby 2.4+. #ifndef RSTRING_PTR #define RSTRING_PTR(str) RSTRING(str)->ptr #endif -@@ -1317,7 +1322,11 @@ static VALUE stmt_bind_result(int argc, VALUE *argv, V +@@ -234,6 +239,7 @@ static VALUE real_connect(int argc, VALUE* argv, VALUE + unsigned int pp, f; + struct mysql* myp; + VALUE obj; ++ my_bool reconnect; + + #if MYSQL_VERSION_ID >= 32200 + rb_scan_args(argc, argv, "07", &host, &user, &passwd, &db, &port, &sock, &flag); +@@ -273,7 +279,8 @@ static VALUE real_connect(int argc, VALUE* argv, VALUE + rb_thread_start_timer(); + #endif + +- myp->handler.reconnect = 0; ++ reconnect = 0; ++ mysql_options(&myp->handler, MYSQL_OPT_RECONNECT, &reconnect); + myp->connection = Qtrue; + myp->query_with_result = Qtrue; + rb_obj_call_init(obj, argc, argv); +@@ -326,6 +333,7 @@ static VALUE real_connect2(int argc, VALUE* argv, VALU + char *h, *u, *p, *d, *s; + unsigned int pp, f; + MYSQL* m = GetHandler(obj); ++ my_bool reconnect; + rb_scan_args(argc, argv, "07", &host, &user, &passwd, &db, &port, &sock, &flag); + d = NILorSTRING(db); + f = NILorINT(flag); +@@ -347,7 +355,8 @@ static VALUE real_connect2(int argc, VALUE* argv, VALU + #ifdef HAVE_RB_THREAD_START_TIMER + rb_thread_start_timer(); + #endif +- m->reconnect = 0; ++ reconnect = 0; ++ mysql_options(&m, MYSQL_OPT_RECONNECT, &reconnect); + GetMysqlStruct(obj)->connection = Qtrue; + + return obj; +@@ -917,13 +926,17 @@ static VALUE query_with_result_set(VALUE obj, VALUE fl + /* reconnect() */ + static VALUE reconnect(VALUE obj) + { +- return GetHandler(obj)->reconnect ? Qtrue : Qfalse; ++ my_bool reconnect; ++ if (mysql_get_option(GetHandler(obj), MYSQL_OPT_RECONNECT, &reconnect)) ++ reconnect = 0; ++ return reconnect ? Qtrue : Qfalse; + } + + /* reconnect=(flag) */ + static VALUE reconnect_set(VALUE obj, VALUE flag) + { +- GetHandler(obj)->reconnect = (flag == Qnil || flag == Qfalse) ? 0 : 1; ++ my_bool reconnect = (flag == Qnil || flag == Qfalse) ? 0 : 1; ++ mysql_options(GetHandler(obj), MYSQL_OPT_RECONNECT, &reconnect); + return flag; + } + +@@ -1317,7 +1330,11 @@ static VALUE stmt_bind_result(int argc, VALUE *argv, V } else if (argv[i] == rb_cString) s->result.bind[i].buffer_type = MYSQL_TYPE_STRING;