Skip to content

Commit a0ac612

Browse files
authored
Merge pull request #13 from infopark/v2.5.1-fix_undeclared_my_bool
V2.5.1 - fix undeclared my bool, mysql2 ">= 0.5.5" compatibility
2 parents d42aef4 + 3379b7f commit a0ac612

File tree

7 files changed

+45
-14
lines changed

7 files changed

+45
-14
lines changed

.travis.yml

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
language: ruby
22
rvm:
3+
- "3.1.2"
4+
- "3.0.4"
35
- "2.7.5"
46
- "2.6.9"
5-
7+
jobs:
8+
include:
9+
- name: Specs
10+
env: TASK='bundle exec rake'

CHANGELOG.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
All notable changes to this project will be documented in this file.
22

33
This gem lives here https://github.com/infopark/mysql_blob_streaming.
4+
5+
## v2.5.1 - 2023-05-10
6+
7+
### Reason to make changes
8+
9+
- Checking mysql.h for my_bool to retain compatibility with older mysql versions
10+
- mysql2 '>= 0.5.5' compatiblity
11+
412
## v2.5.0 - 2022-05-03
513

614
### Reason to make changes
@@ -21,7 +29,6 @@ This gem lives here https://github.com/infopark/mysql_blob_streaming.
2129
typedef bool my_bool;
2230
#endif
2331

24-
2532
## v2.4.0 - 2021-03-23
2633

2734
### Reason to make changes

Gemfile

+5-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ source 'https://rubygems.org'
44
gemspec
55

66
# Dependencies for test environment
7-
gem "rake"
8-
gem "test-unit"
9-
gem "activerecord", "~> 5.2"
7+
group :test do
8+
gem 'activerecord', '~> 6.0'
9+
gem 'rake'
10+
gem 'test-unit'
11+
end

ext/mysql_blob_streaming/extconf.rb

+12
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,18 @@
1111
find_header('errmsg.h', *additional_mysql_include_dirs)
1212
find_library('mysqlclient', nil, *additional_mysql_lib_dirs)
1313

14+
if have_header('mysql.h')
15+
prefix = nil
16+
elsif have_header('mysql/mysql.h')
17+
prefix = 'mysql'
18+
else
19+
asplode 'mysql.h'
20+
end
21+
mysql_h = [prefix, 'mysql.h'].compact.join('/')
22+
# my_bool is replaced by C99 bool in MySQL 8.0, but we want
23+
# to retain compatibility with the typedef in earlier MySQLs.
24+
have_type('my_bool', mysql_h)
25+
1426
# --no-undefined forces us to link against libruby
1527
def remove_no_undefined(ldflags)
1628
ldflags.gsub("-Wl,--no-undefined", "")

ext/mysql_blob_streaming/mysql_blob_streaming.c

+11-6
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,35 @@
44
#include <mysql.h>
55
#include <errmsg.h>
66

7-
#if MYSQL_VERSION_ID >=80000 && MYSQL_VERSION_ID <80030
7+
/* MySQL 8.0 replaces my_bool with C99 bool. Earlier versions of MySQL had
8+
* a typedef to char. Gem users reported failures on big endian systems when
9+
* using C99 bool types with older MySQLs due to mismatched behavior.
10+
*/
11+
#ifndef HAVE_TYPE_MY_BOOL
812
#include <stdbool.h>
913
typedef bool my_bool;
1014
#endif
1115

1216
typedef struct {
1317
VALUE encoding;
14-
VALUE active_thread;
18+
VALUE active_fiber; /* rb_fiber_current() or Qnil */
1519
long server_version;
1620
int reconnect_enabled;
17-
int connect_timeout;
21+
unsigned int connect_timeout;
1822
int active;
19-
int connected;
23+
int automatic_close;
2024
int initialized;
2125
int refcount;
22-
int freed;
26+
int closed;
2327
MYSQL *client;
2428
} mysql_client_wrapper;
2529

30+
extern const rb_data_type_t rb_mysql_client_type;
2631

2732
static MYSQL * mysql_connection(VALUE rb_mysql2_client)
2833
{
2934
mysql_client_wrapper *wrapper;
30-
Data_Get_Struct(rb_mysql2_client, mysql_client_wrapper, wrapper);
35+
TypedData_Get_Struct(rb_mysql2_client, mysql_client_wrapper, &rb_mysql_client_type, wrapper);
3136
return wrapper->client;
3237
}
3338

lib/mysql_blob_streaming/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
class MysqlBlobStreaming
2-
VERSION = "2.5.0"
2+
VERSION = '2.5.1'
33
end

mysql_blob_streaming.gemspec

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ Gem::Specification.new do |spec|
1313
EOF
1414
spec.license = 'MIT'
1515

16-
spec.add_dependency 'mysql2', ">= 0.4.4", "< 0.6.0"
17-
spec.required_ruby_version = '>=2.0.0'
16+
spec.add_dependency "mysql2", "~> 0.5", ">= 0.5.5"
17+
spec.required_ruby_version = ">= 2.0.0"
1818

1919
spec.files = Dir["lib/**/*.rb", "ext/**/*.{c,h,rb}", "README.markdown"]
2020
spec.extensions = ['ext/mysql_blob_streaming/extconf.rb']

0 commit comments

Comments
 (0)