Skip to content

Commit 81c7f81

Browse files
committed
databases/rubygem-mysql2: adopt modern mysql fix
brianmario/mysql2#1014
1 parent 9f0aa0b commit 81c7f81

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
diff --git ext/mysql2/client.c ext/mysql2/client.c
2+
index 5d75304b4..6861a45e1 100644
3+
--- ext/mysql2/client.c
4+
+++ ext/mysql2/client.c
5+
@@ -54,7 +54,9 @@ static VALUE rb_hash_dup(VALUE other) {
6+
* variable to use, but MYSQL_SERVER_VERSION gives the correct numbers when
7+
* linking against the server itself
8+
*/
9+
-#ifdef LIBMYSQL_VERSION
10+
+#if defined(MARIADB_CLIENT_VERSION_STR)
11+
+ #define MYSQL_LINK_VERSION MARIADB_CLIENT_VERSION_STR
12+
+#elif defined(LIBMYSQL_VERSION)
13+
#define MYSQL_LINK_VERSION LIBMYSQL_VERSION
14+
#else
15+
#define MYSQL_LINK_VERSION MYSQL_SERVER_VERSION
16+
@@ -436,7 +438,7 @@ static VALUE do_send_query(void *args) {
17+
*/
18+
static void *nogvl_read_query_result(void *ptr) {
19+
MYSQL * client = ptr;
20+
- my_bool res = mysql_read_query_result(client);
21+
+ bool res = mysql_read_query_result(client);
22+
23+
return (void *)(res == 0 ? Qtrue : Qfalse);
24+
}
25+
@@ -759,7 +761,7 @@ static VALUE _mysql_client_options(VALUE self, int opt, VALUE value) {
26+
const void *retval = NULL;
27+
unsigned int intval = 0;
28+
const char * charval = NULL;
29+
- my_bool boolval;
30+
+ bool boolval;
31+
32+
GET_CLIENT(self);
33+
34+
@@ -794,10 +796,12 @@ static VALUE _mysql_client_options(VALUE self, int opt, VALUE value) {
35+
retval = &boolval;
36+
break;
37+
38+
+#if defined(MYSQL_SECURE_AUTH)
39+
case MYSQL_SECURE_AUTH:
40+
boolval = (value == Qfalse ? 0 : 1);
41+
retval = &boolval;
42+
break;
43+
+#endif
44+
45+
case MYSQL_READ_DEFAULT_FILE:
46+
charval = (const char *)StringValueCStr(value);
47+
@@ -1182,7 +1186,9 @@ static VALUE set_ssl_options(VALUE self, VALUE key, VALUE cert, VALUE ca, VALUE
48+
}
49+
50+
static VALUE set_secure_auth(VALUE self, VALUE value) {
51+
+#if defined(MYSQL_SECURE_AUTH)
52+
return _mysql_client_options(self, MYSQL_SECURE_AUTH, value);
53+
+#endif
54+
}
55+
56+
static VALUE set_read_default_file(VALUE self, VALUE value) {
57+
@@ -1297,6 +1303,10 @@ void init_mysql2_client() {
58+
#ifdef CLIENT_LONG_PASSWORD
59+
rb_const_set(cMysql2Client, rb_intern("LONG_PASSWORD"),
60+
LONG2NUM(CLIENT_LONG_PASSWORD));
61+
+#else
62+
+ /* HACK because MariaDB 10.2 no longer defines this constant,
63+
+ * but we're using it in our default connection flags. */
64+
+ rb_const_set(cMysql2Client, rb_intern("LONG_PASSWORD"), INT2NUM(0));
65+
#endif
66+
67+
#ifdef CLIENT_FOUND_ROWS
68+
diff --git ext/mysql2/mysql2_ext.h ext/mysql2/mysql2_ext.h
69+
index d6d5fd626..b3f1ebe8d 100644
70+
--- ext/mysql2/mysql2_ext.h
71+
+++ ext/mysql2/mysql2_ext.h
72+
@@ -15,12 +15,10 @@ typedef unsigned int uint;
73+
74+
#ifdef HAVE_MYSQL_H
75+
#include <mysql.h>
76+
-#include <mysql_com.h>
77+
#include <errmsg.h>
78+
#include <mysqld_error.h>
79+
#else
80+
#include <mysql/mysql.h>
81+
-#include <mysql/mysql_com.h>
82+
#include <mysql/errmsg.h>
83+
#include <mysql/mysqld_error.h>
84+
#endif

0 commit comments

Comments
 (0)