From a50e08165e12f6b3fee5140c5cbb63119fea93c8 Mon Sep 17 00:00:00 2001 From: Aaron Stone Date: Sat, 25 Nov 2017 13:18:46 -0800 Subject: [PATCH] The server_status flags are enums in MySQL 8.0 --- ext/mysql2/client.c | 6 +++--- ext/mysql2/extconf.rb | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ext/mysql2/client.c b/ext/mysql2/client.c index cca56194a..7c51d1347 100644 --- a/ext/mysql2/client.c +++ b/ext/mysql2/client.c @@ -1589,19 +1589,19 @@ void init_mysql2_client() { void rb_mysql_set_server_query_flags(MYSQL *client, VALUE result) { VALUE server_flags = rb_hash_new(); -#ifdef SERVER_QUERY_NO_GOOD_INDEX_USED +#ifdef HAVE_CONST_SERVER_QUERY_NO_GOOD_INDEX_USED rb_hash_aset(server_flags, sym_no_good_index_used, flag_to_bool(SERVER_QUERY_NO_GOOD_INDEX_USED)); #else rb_hash_aset(server_flags, sym_no_good_index_used, Qnil); #endif -#ifdef SERVER_QUERY_NO_INDEX_USED +#ifdef HAVE_CONST_SERVER_QUERY_NO_INDEX_USED rb_hash_aset(server_flags, sym_no_index_used, flag_to_bool(SERVER_QUERY_NO_INDEX_USED)); #else rb_hash_aset(server_flags, sym_no_index_used, Qnil); #endif -#ifdef SERVER_QUERY_WAS_SLOW +#ifdef HAVE_CONST_SERVER_QUERY_WAS_SLOW rb_hash_aset(server_flags, sym_query_was_slow, flag_to_bool(SERVER_QUERY_WAS_SLOW)); #else rb_hash_aset(server_flags, sym_query_was_slow, Qnil); diff --git a/ext/mysql2/extconf.rb b/ext/mysql2/extconf.rb index 8c0020390..a0eb125b4 100644 --- a/ext/mysql2/extconf.rb +++ b/ext/mysql2/extconf.rb @@ -110,7 +110,11 @@ def add_ssl_defines(header) add_ssl_defines(mysql_h) have_struct_member('MYSQL', 'net.vio', mysql_h) have_struct_member('MYSQL', 'net.pvio', mysql_h) +# These constants are actually enums, so they cannot be detected by #ifdef in C code. have_const('MYSQL_ENABLE_CLEARTEXT_PLUGIN', mysql_h) +have_const('SERVER_QUERY_NO_GOOD_INDEX_USED', mysql_h) +have_const('SERVER_QUERY_NO_INDEX_USED', mysql_h) +have_const('SERVER_QUERY_WAS_SLOW', mysql_h) have_const('MYSQL_OPT_CONNECT_ATTR_ADD', mysql_h) # for mysql_options4 # This is our wishlist. We use whichever flags work on the host.