Skip to content

fix build with MariaDB 10.2 headers #1014

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: 0.3.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions ext/mysql2/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ static VALUE rb_hash_dup(VALUE other) {
* variable to use, but MYSQL_SERVER_VERSION gives the correct numbers when
* linking against the server itself
*/
#ifdef LIBMYSQL_VERSION
#if defined(MARIADB_CLIENT_VERSION_STR)
#define MYSQL_LINK_VERSION MARIADB_CLIENT_VERSION_STR
#elif defined(LIBMYSQL_VERSION)
#define MYSQL_LINK_VERSION LIBMYSQL_VERSION
#else
#define MYSQL_LINK_VERSION MYSQL_SERVER_VERSION
Expand Down Expand Up @@ -436,7 +438,7 @@ static VALUE do_send_query(void *args) {
*/
static void *nogvl_read_query_result(void *ptr) {
MYSQL * client = ptr;
my_bool res = mysql_read_query_result(client);
bool res = mysql_read_query_result(client);

return (void *)(res == 0 ? Qtrue : Qfalse);
}
Expand Down Expand Up @@ -759,7 +761,7 @@ static VALUE _mysql_client_options(VALUE self, int opt, VALUE value) {
const void *retval = NULL;
unsigned int intval = 0;
const char * charval = NULL;
my_bool boolval;
bool boolval;

GET_CLIENT(self);

Expand Down Expand Up @@ -794,10 +796,12 @@ static VALUE _mysql_client_options(VALUE self, int opt, VALUE value) {
retval = &boolval;
break;

#if defined(MYSQL_SECURE_AUTH)
case MYSQL_SECURE_AUTH:
boolval = (value == Qfalse ? 0 : 1);
retval = &boolval;
break;
#endif

case MYSQL_READ_DEFAULT_FILE:
charval = (const char *)StringValueCStr(value);
Expand Down Expand Up @@ -1182,7 +1186,9 @@ static VALUE set_ssl_options(VALUE self, VALUE key, VALUE cert, VALUE ca, VALUE
}

static VALUE set_secure_auth(VALUE self, VALUE value) {
#if defined(MYSQL_SECURE_AUTH)
return _mysql_client_options(self, MYSQL_SECURE_AUTH, value);
#endif
}

static VALUE set_read_default_file(VALUE self, VALUE value) {
Expand Down Expand Up @@ -1297,6 +1303,10 @@ void init_mysql2_client() {
#ifdef CLIENT_LONG_PASSWORD
rb_const_set(cMysql2Client, rb_intern("LONG_PASSWORD"),
LONG2NUM(CLIENT_LONG_PASSWORD));
#else
/* HACK because MariaDB 10.2 no longer defines this constant,
* but we're using it in our default connection flags. */
rb_const_set(cMysql2Client, rb_intern("LONG_PASSWORD"), INT2NUM(0));
#endif

#ifdef CLIENT_FOUND_ROWS
Expand Down
2 changes: 0 additions & 2 deletions ext/mysql2/mysql2_ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@ typedef unsigned int uint;

#ifdef HAVE_MYSQL_H
#include <mysql.h>
#include <mysql_com.h>
#include <errmsg.h>
#include <mysqld_error.h>
#else
#include <mysql/mysql.h>
#include <mysql/mysql_com.h>
#include <mysql/errmsg.h>
#include <mysql/mysqld_error.h>
#endif
Expand Down