Skip to content

Commit 93d3240

Browse files
Backport MySQL 8.0.1 my_bool fix from PR 919
1 parent 9589643 commit 93d3240

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

ext/mysql2/extconf.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ def asplode lib
104104
asplode h unless have_header h
105105
end
106106

107+
mysql_h = [prefix, 'mysql.h'].compact.join('/')
108+
109+
# my_bool is replaced by C99 bool in MySQL 8.0, but we want
110+
# to retain compatibility with the typedef in earlier MySQLs.
111+
have_type('my_bool', mysql_h)
112+
107113
# These gcc style flags are also supported by clang and xcode compilers,
108114
# so we'll use a does-it-work test instead of an is-it-gcc test.
109115
gcc_flags = ' -Wall -funroll-loops'

ext/mysql2/mysql2_ext.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
#ifndef MYSQL2_EXT
22
#define MYSQL2_EXT
33

4+
/* MySQL 8.0 replaces my_bool with C99 bool. Earlier versions of MySQL had
5+
* a typedef to char. Gem users reported failures on big endian systems when
6+
* using C99 bool types with older MySQLs due to mismatched behavior. */
7+
#ifndef HAVE_TYPE_MY_BOOL
8+
#include <stdbool.h>
9+
typedef bool my_bool;
10+
#endif
11+
412
/* tell rbx not to use it's caching compat layer
513
by doing this we're making a promise to RBX that
614
we'll never modify the pointers we get back from RSTRING_PTR */

0 commit comments

Comments
 (0)