Skip to content

Commit

Permalink
Backport MySQL 8.0.1 my_bool fix from PR 919
Browse files Browse the repository at this point in the history
  • Loading branch information
felixbuenemann committed Apr 25, 2019
1 parent 9589643 commit 93d3240
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ext/mysql2/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ def asplode lib
asplode h unless have_header h
end

mysql_h = [prefix, 'mysql.h'].compact.join('/')

# my_bool is replaced by C99 bool in MySQL 8.0, but we want
# to retain compatibility with the typedef in earlier MySQLs.
have_type('my_bool', mysql_h)

# These gcc style flags are also supported by clang and xcode compilers,
# so we'll use a does-it-work test instead of an is-it-gcc test.
gcc_flags = ' -Wall -funroll-loops'
Expand Down
8 changes: 8 additions & 0 deletions ext/mysql2/mysql2_ext.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
#ifndef MYSQL2_EXT
#define MYSQL2_EXT

/* MySQL 8.0 replaces my_bool with C99 bool. Earlier versions of MySQL had
* a typedef to char. Gem users reported failures on big endian systems when
* using C99 bool types with older MySQLs due to mismatched behavior. */
#ifndef HAVE_TYPE_MY_BOOL
#include <stdbool.h>
typedef bool my_bool;
#endif

/* tell rbx not to use it's caching compat layer
by doing this we're making a promise to RBX that
we'll never modify the pointers we get back from RSTRING_PTR */
Expand Down

0 comments on commit 93d3240

Please sign in to comment.