diff --git a/databases/ruby-mysql/Makefile b/databases/ruby-mysql/Makefile index 9e0326149d8..5f980684d63 100644 --- a/databases/ruby-mysql/Makefile +++ b/databases/ruby-mysql/Makefile @@ -1,9 +1,9 @@ -# $OpenBSD: Makefile,v 1.38 2019/07/12 20:44:01 sthen Exp $ +# $OpenBSD: Makefile,v 1.39 2020/11/11 02:39:12 jeremy Exp $ COMMENT= access a MySQL database from Ruby DISTNAME= mysql-2.9.1 -REVISION= 3 +REVISION= 4 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 19266e46805..226c1d1c594 100644 --- a/databases/ruby-mysql/patches/patch-ext_mysql_api_mysql_c +++ b/databases/ruby-mysql/patches/patch-ext_mysql_api_mysql_c @@ -1,89 +1,78 @@ -$OpenBSD: patch-ext_mysql_api_mysql_c,v 1.3 2019/05/08 22:33:32 jca Exp $ +$OpenBSD: patch-ext_mysql_api_mysql_c,v 1.4 2020/11/11 02:39:12 jeremy Exp $ Allow building with ruby 2.4+. -Allow building with recent mariadb releases. +Allow building with recent mariadb releases, which do not support automatic +reconnection. This makes the reconnect setting always false. Also, make +Mysql#close not cause a crash if called more than once. Index: ext/mysql_api/mysql.c --- ext/mysql_api/mysql.c.orig +++ ext/mysql_api/mysql.c -@@ -3,6 +3,11 @@ - */ - - #include -+#ifdef HAVE_RUBY_ENCODING_H -+#include -+#else -+#define RUBY_API_VERSION_CODE 10807 -+#endif - #ifndef RSTRING_PTR - #define RSTRING_PTR(str) RSTRING(str)->ptr - #endif -@@ -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 +@@ -273,7 +273,6 @@ 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 +@@ -347,7 +346,6 @@ 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 +@@ -477,8 +475,10 @@ static VALUE character_set_name(VALUE obj) + static VALUE my_close(VALUE obj) + { + MYSQL* m = GetHandler(obj); +- mysql_close(m); +- GetMysqlStruct(obj)->connection = Qfalse; ++ if (RTEST(GetMysqlStruct(obj)->connection)) { ++ mysql_close(m); ++ GetMysqlStruct(obj)->connection = Qfalse; ++ } + return obj; + } + +@@ -875,12 +875,12 @@ static VALUE stmt_init(VALUE obj) + MYSQL *m = GetHandler(obj); + MYSQL_STMT *s; + struct mysql_stmt* stmt; +- my_bool true = 1; ++ my_bool mtrue = 1; + VALUE st_obj; + + if ((s = mysql_stmt_init(m)) == NULL) + mysql_raise(m); +- if (mysql_stmt_attr_set(s, STMT_ATTR_UPDATE_MAX_LENGTH, &true)) ++ if (mysql_stmt_attr_set(s, STMT_ATTR_UPDATE_MAX_LENGTH, &mtrue)) + rb_raise(rb_eArgError, "mysql_stmt_attr_set() failed"); + st_obj = Data_Make_Struct(cMysqlStmt, struct mysql_stmt, 0, free_mysqlstmt, stmt); + memset(stmt, 0, sizeof(*stmt)); +@@ -917,13 +917,12 @@ 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; ++ return 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 +@@ -1317,7 +1316,7 @@ 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; - else if (argv[i] == rb_cNumeric || argv[i] == rb_cInteger || argv[i] == rb_cFixnum) -+ else if (argv[i] == rb_cNumeric || argv[i] == rb_cInteger -+#if (RUBY_API_VERSION_CODE < 20400) -+ || argv[i] == rb_cFixnum -+#endif -+ ) ++ else if (argv[i] == rb_cNumeric || argv[i] == rb_cInteger) s->result.bind[i].buffer_type = MYSQL_TYPE_LONGLONG; else if (argv[i] == rb_cFloat) s->result.bind[i].buffer_type = MYSQL_TYPE_DOUBLE;