Skip to content

Commit 64f07e1

Browse files
committed
Merge pull request #392 from monban/connector-compatability
Per #390 use LIBMYSQL_VERSION where available
2 parents 266b7af + add9678 commit 64f07e1

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

ext/mysql2/client.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,17 @@ static VALUE rb_hash_dup(VALUE other) {
4444
mysql_client_wrapper *wrapper; \
4545
Data_Get_Struct(self, mysql_client_wrapper, wrapper)
4646

47+
/*
48+
* compatability with mysql-connector-c, where LIBMYSQL_VERSION is the correct
49+
* variable to use, but MYSQL_SERVER_VERSION gives the correct numbers when
50+
* linking against the server itself
51+
*/
52+
#ifdef LIBMYSQL_VERSION
53+
#define MYSQL_LINK_VERSION LIBMYSQL_VERSION
54+
#else
55+
#define MYSQL_LINK_VERSION MYSQL_SERVER_VERSION
56+
#endif
57+
4758
/*
4859
* used to pass all arguments to mysql_real_connect while inside
4960
* rb_thread_blocking_region
@@ -1079,14 +1090,15 @@ void init_mysql2_client() {
10791090
int i;
10801091
int dots = 0;
10811092
const char *lib = mysql_get_client_info();
1082-
for (i = 0; lib[i] != 0 && MYSQL_SERVER_VERSION[i] != 0; i++) {
1093+
1094+
for (i = 0; lib[i] != 0 && MYSQL_LINK_VERSION[i] != 0; i++) {
10831095
if (lib[i] == '.') {
10841096
dots++;
10851097
/* we only compare MAJOR and MINOR */
10861098
if (dots == 2) break;
10871099
}
1088-
if (lib[i] != MYSQL_SERVER_VERSION[i]) {
1089-
rb_raise(rb_eRuntimeError, "Incorrect MySQL client library version! This gem was compiled for %s but the client library is %s.", MYSQL_SERVER_VERSION, lib);
1100+
if (lib[i] != MYSQL_LINK_VERSION[i]) {
1101+
rb_raise(rb_eRuntimeError, "Incorrect MySQL client library version! This gem was compiled for %s but the client library is %s.", MYSQL_LINK_VERSION, lib);
10901102
return;
10911103
}
10921104
}

0 commit comments

Comments
 (0)