mysql2 0.3.20 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
data/ext/mysql2/client.h CHANGED
@@ -1,41 +1,6 @@
1
1
  #ifndef MYSQL2_CLIENT_H
2
2
  #define MYSQL2_CLIENT_H
3
3
 
4
- #ifndef HAVE_RB_THREAD_CALL_WITHOUT_GVL
5
- #ifdef HAVE_RB_THREAD_BLOCKING_REGION
6
-
7
- /* emulate rb_thread_call_without_gvl with rb_thread_blocking_region */
8
- #define rb_thread_call_without_gvl(func, data1, ubf, data2) \
9
- rb_thread_blocking_region((rb_blocking_function_t *)func, data1, ubf, data2)
10
-
11
- #else /* ! HAVE_RB_THREAD_BLOCKING_REGION */
12
- /*
13
- * partial emulation of the 2.0 rb_thread_call_without_gvl under 1.8,
14
- * this is enough for dealing with blocking I/O functions in the
15
- * presence of threads.
16
- */
17
-
18
- #include <rubysig.h>
19
- #define RUBY_UBF_IO ((rb_unblock_function_t *)-1)
20
- typedef void rb_unblock_function_t(void *);
21
- static void *
22
- rb_thread_call_without_gvl(
23
- void *(*func)(void *), void *data1,
24
- RB_MYSQL_UNUSED rb_unblock_function_t *ubf,
25
- RB_MYSQL_UNUSED void *data2)
26
- {
27
- void *rv;
28
-
29
- TRAP_BEG;
30
- rv = func(data1);
31
- TRAP_END;
32
-
33
- return rv;
34
- }
35
-
36
- #endif /* ! HAVE_RB_THREAD_BLOCKING_REGION */
37
- #endif /* ! HAVE_RB_THREAD_CALL_WITHOUT_GVL */
38
-
39
4
  typedef struct {
40
5
  VALUE encoding;
41
6
  VALUE active_thread; /* rb_thread_current() or Qnil */
@@ -43,14 +8,21 @@ typedef struct {
43
8
  int reconnect_enabled;
44
9
  unsigned int connect_timeout;
45
10
  int active;
46
- int connected;
11
+ int automatic_close;
47
12
  int initialized;
48
13
  int refcount;
49
- int freed;
14
+ int closed;
50
15
  MYSQL *client;
51
16
  } mysql_client_wrapper;
52
17
 
53
- void init_mysql2_client();
18
+ void rb_mysql_client_set_active_thread(VALUE self);
19
+ void rb_mysql_set_server_query_flags(MYSQL *client, VALUE result);
20
+
21
+ #define GET_CLIENT(self) \
22
+ mysql_client_wrapper *wrapper; \
23
+ Data_Get_Struct(self, mysql_client_wrapper, wrapper);
24
+
25
+ void init_mysql2_client(void);
54
26
  void decr_mysql2_client(mysql_client_wrapper *wrapper);
55
27
 
56
28
  #endif
@@ -1,28 +1,36 @@
1
- # encoding: UTF-8
2
1
  require 'mkmf'
2
+ require 'English'
3
3
 
4
- def asplode lib
4
+ def asplode(lib)
5
5
  if RUBY_PLATFORM =~ /mingw|mswin/
6
6
  abort "-----\n#{lib} is missing. Check your installation of MySQL or Connector/C, and try again.\n-----"
7
7
  elsif RUBY_PLATFORM =~ /darwin/
8
8
  abort "-----\n#{lib} is missing. You may need to 'brew install mysql' or 'port install mysql', and try again.\n-----"
9
9
  else
10
- abort "-----\n#{lib} is missing. You may need to 'apt-get install libmysqlclient-dev' or 'yum install mysql-devel', and try again.\n-----"
10
+ abort "-----\n#{lib} is missing. You may need to 'sudo apt-get install libmariadb-dev', 'sudo apt-get install libmysqlclient-dev' or 'sudo yum install mysql-devel', and try again.\n-----"
11
11
  end
12
12
  end
13
13
 
14
- # 2.0-only
15
- have_header('ruby/thread.h') && have_func('rb_thread_call_without_gvl', 'ruby/thread.h')
14
+ def add_ssl_defines(header)
15
+ all_modes_found = %w[SSL_MODE_DISABLED SSL_MODE_PREFERRED SSL_MODE_REQUIRED SSL_MODE_VERIFY_CA SSL_MODE_VERIFY_IDENTITY].inject(true) do |m, ssl_mode|
16
+ m && have_const(ssl_mode, header)
17
+ end
18
+ $CFLAGS << ' -DFULL_SSL_MODE_SUPPORT' if all_modes_found
19
+ # if we only have ssl toggle (--ssl,--disable-ssl) from 5.7.3 to 5.7.10
20
+ has_no_support = all_modes_found ? false : !have_const('MYSQL_OPT_SSL_ENFORCE', header)
21
+ $CFLAGS << ' -DNO_SSL_MODE_SUPPORT' if has_no_support
22
+ end
16
23
 
17
- # 1.9-only
18
- have_func('rb_thread_blocking_region')
24
+ # 2.1+
25
+ have_func('rb_absint_size')
26
+ have_func('rb_absint_singlebit_p')
27
+
28
+ # Missing in RBX (https://github.com/rubinius/rubinius/issues/3771)
19
29
  have_func('rb_wait_for_single_fd')
20
- have_func('rb_hash_dup')
21
- have_func('rb_intern3')
22
30
 
23
31
  # borrowed from mysqlplus
24
32
  # http://github.com/oldmoe/mysqlplus/blob/master/ext/extconf.rb
25
- dirs = ENV['PATH'].split(File::PATH_SEPARATOR) + %w[
33
+ dirs = ENV.fetch('PATH').split(File::PATH_SEPARATOR) + %w[
26
34
  /opt
27
35
  /opt/local
28
36
  /opt/local/mysql
@@ -33,62 +41,52 @@ dirs = ENV['PATH'].split(File::PATH_SEPARATOR) + %w[
33
41
  /usr/local/mysql
34
42
  /usr/local/mysql-*
35
43
  /usr/local/lib/mysql5*
36
- ].map{|dir| "#{dir}/bin" }
44
+ /usr/local/opt/mysql5*
45
+ ].map { |dir| dir << '/bin' }
46
+
47
+ # For those without HOMEBREW_ROOT in PATH
48
+ dirs << "#{ENV['HOMEBREW_ROOT']}/bin" if ENV['HOMEBREW_ROOT']
37
49
 
38
- GLOB = "{#{dirs.join(',')}}/{mysql_config,mysql_config5,mariadb_config}"
50
+ GLOB = "{#{dirs.join(',')}}/{mysql_config,mysql_config5,mariadb_config}".freeze
39
51
 
40
52
  # If the user has provided a --with-mysql-dir argument, we must respect it or fail.
41
53
  inc, lib = dir_config('mysql')
42
54
  if inc && lib
43
- # Ruby versions not incorporating the mkmf fix at
55
+ # Ruby versions below 2.0 on Unix and below 2.1 on Windows
56
+ # do not properly search for lib directories, and must be corrected:
44
57
  # https://bugs.ruby-lang.org/projects/ruby-trunk/repository/revisions/39717
45
- # do not properly search for lib directories, and must be corrected
46
58
  unless lib && lib[-3, 3] == 'lib'
47
59
  @libdir_basename = 'lib'
48
60
  inc, lib = dir_config('mysql')
49
61
  end
50
- abort "-----\nCannot find include dir(s) #{inc}\n-----" unless inc && inc.split(File::PATH_SEPARATOR).any?{|dir| File.directory?(dir)}
51
- abort "-----\nCannot find library dir(s) #{lib}\n-----" unless lib && lib.split(File::PATH_SEPARATOR).any?{|dir| File.directory?(dir)}
52
- warn "-----\nUsing --with-mysql-dir=#{File.dirname inc}\n-----"
62
+ abort "-----\nCannot find include dir(s) #{inc}\n-----" unless inc && inc.split(File::PATH_SEPARATOR).any? { |dir| File.directory?(dir) }
63
+ abort "-----\nCannot find library dir(s) #{lib}\n-----" unless lib && lib.split(File::PATH_SEPARATOR).any? { |dir| File.directory?(dir) }
64
+ warn "-----\nUsing --with-mysql-dir=#{File.dirname inc}\n-----"
53
65
  rpath_dir = lib
54
- elsif mc = (with_config('mysql-config') || Dir[GLOB].first)
66
+ have_library('mysqlclient')
67
+ elsif (mc = (with_config('mysql-config') || Dir[GLOB].first))
55
68
  # If the user has provided a --with-mysql-config argument, we must respect it or fail.
56
69
  # If the user gave --with-mysql-config with no argument means we should try to find it.
57
70
  mc = Dir[GLOB].first if mc == true
58
- abort "-----\nCannot find mysql_config at #{mc}\n-----" unless mc && File.exists?(mc)
71
+ abort "-----\nCannot find mysql_config at #{mc}\n-----" unless mc && File.exist?(mc)
59
72
  abort "-----\nCannot execute mysql_config at #{mc}\n-----" unless File.executable?(mc)
60
- warn "-----\nUsing mysql_config at #{mc}\n-----"
73
+ warn "-----\nUsing mysql_config at #{mc}\n-----"
61
74
  ver = `#{mc} --version`.chomp.to_f
62
75
  includes = `#{mc} --include`.chomp
63
- exit 1 if $? != 0
76
+ abort unless $CHILD_STATUS.success?
64
77
  libs = `#{mc} --libs_r`.chomp
65
78
  # MySQL 5.5 and above already have re-entrant code in libmysqlclient (no _r).
66
- if ver >= 5.5 || libs.empty?
67
- libs = `#{mc} --libs`.chomp
68
- end
69
- exit 1 if $? != 0
79
+ libs = `#{mc} --libs`.chomp if ver >= 5.5 || libs.empty?
80
+ abort unless $CHILD_STATUS.success?
70
81
  $INCFLAGS += ' ' + includes
71
82
  $libs = libs + " " + $libs
72
83
  rpath_dir = libs
73
84
  else
74
- inc, lib = dir_config('mysql', '/usr/local')
75
- unless find_library('mysqlclient', 'mysql_query', lib, "#{lib}/mysql")
76
- found = false
77
- # For some systems and some versions of libmysqlclient, there were extra
78
- # libraries needed to link. Try each typical extra library, add it to the
79
- # global compile flags, and see if that allows us to link libmysqlclient.
80
- warn "-----\nlibmysqlclient is missing. Trying again with extra runtime libraries...\n-----"
81
-
82
- %w{ m z socket nsl mygcc }.each do |extra_lib|
83
- if have_library(extra_lib) && find_library('mysqlclient', 'mysql_query', lib, "#{lib}/mysql")
84
- found = true
85
- break
86
- end
87
- end
88
- asplode('libmysqlclient') unless found
89
- end
85
+ _, usr_local_lib = dir_config('mysql', '/usr/local')
90
86
 
91
- rpath_dir = lib
87
+ asplode("mysql client") unless find_library('mysqlclient', nil, usr_local_lib, "#{usr_local_lib}/mysql")
88
+
89
+ rpath_dir = usr_local_lib
92
90
  end
93
91
 
94
92
  if have_header('mysql.h')
@@ -99,19 +97,91 @@ else
99
97
  asplode 'mysql.h'
100
98
  end
101
99
 
102
- %w{ errmsg.h mysqld_error.h }.each do |h|
103
- header = [prefix, h].compact.join '/'
104
- asplode h unless have_header h
100
+ %w[errmsg.h].each do |h|
101
+ header = [prefix, h].compact.join('/')
102
+ asplode h unless have_header header
105
103
  end
106
104
 
107
- # These gcc style flags are also supported by clang and xcode compilers,
108
- # so we'll use a does-it-work test instead of an is-it-gcc test.
109
- gcc_flags = ' -Wall -funroll-loops'
110
- if try_link('int main() {return 0;}', gcc_flags)
111
- $CFLAGS << gcc_flags
105
+ mysql_h = [prefix, 'mysql.h'].compact.join('/')
106
+ add_ssl_defines(mysql_h)
107
+ have_struct_member('MYSQL', 'net.vio', mysql_h)
108
+ have_struct_member('MYSQL', 'net.pvio', mysql_h)
109
+
110
+ # These constants are actually enums, so they cannot be detected by #ifdef in C code.
111
+ have_const('MYSQL_ENABLE_CLEARTEXT_PLUGIN', mysql_h)
112
+ have_const('SERVER_QUERY_NO_GOOD_INDEX_USED', mysql_h)
113
+ have_const('SERVER_QUERY_NO_INDEX_USED', mysql_h)
114
+ have_const('SERVER_QUERY_WAS_SLOW', mysql_h)
115
+ have_const('MYSQL_OPTION_MULTI_STATEMENTS_ON', mysql_h)
116
+ have_const('MYSQL_OPTION_MULTI_STATEMENTS_OFF', mysql_h)
117
+
118
+ # my_bool is replaced by C99 bool in MySQL 8.0, but we want
119
+ # to retain compatibility with the typedef in earlier MySQLs.
120
+ have_type('my_bool', mysql_h)
121
+
122
+ # This is our wishlist. We use whichever flags work on the host.
123
+ # -Wall and -Wextra are included by default.
124
+ wishlist = [
125
+ '-Weverything',
126
+ '-Wno-bad-function-cast', # rb_thread_call_without_gvl returns void * that we cast to VALUE
127
+ '-Wno-conditional-uninitialized', # false positive in client.c
128
+ '-Wno-covered-switch-default', # result.c -- enum_field_types (when fully covered, e.g. mysql 5.5)
129
+ '-Wno-declaration-after-statement', # GET_CLIENT followed by GET_STATEMENT in statement.c
130
+ '-Wno-disabled-macro-expansion', # rubby :(
131
+ '-Wno-documentation-unknown-command', # rubby :(
132
+ '-Wno-missing-field-initializers', # gperf generates bad code
133
+ '-Wno-missing-variable-declarations', # missing symbols due to ruby native ext initialization
134
+ '-Wno-padded', # mysql :(
135
+ '-Wno-reserved-id-macro', # rubby :(
136
+ '-Wno-sign-conversion', # gperf generates bad code
137
+ '-Wno-static-in-inline', # gperf generates bad code
138
+ '-Wno-switch-enum', # result.c -- enum_field_types (when not fully covered, e.g. mysql 5.6+)
139
+ '-Wno-undef', # rubinius :(
140
+ '-Wno-unreachable-code', # rubby :(
141
+ '-Wno-used-but-marked-unused', # rubby :(
142
+ ]
143
+
144
+ usable_flags = wishlist.select do |flag|
145
+ try_link('int main() {return 0;}', "-Werror #{flag}")
146
+ end
147
+
148
+ $CFLAGS << ' ' << usable_flags.join(' ')
149
+
150
+ enabled_sanitizers = disabled_sanitizers = []
151
+ # Specify a commna-separated list of sanitizers, or try them all by default
152
+ sanitizers = with_config('sanitize')
153
+ case sanitizers
154
+ when true
155
+ # Try them all, turn on whatever we can
156
+ enabled_sanitizers = %w[address cfi integer memory thread undefined].select do |s|
157
+ try_link('int main() {return 0;}', "-Werror -fsanitize=#{s}")
158
+ end
159
+ abort "-----\nCould not enable any sanitizers!\n-----" if enabled_sanitizers.empty?
160
+ when String
161
+ # Figure out which sanitizers are supported
162
+ enabled_sanitizers, disabled_sanitizers = sanitizers.split(',').partition do |s|
163
+ try_link('int main() {return 0;}', "-Werror -fsanitize=#{s}")
164
+ end
165
+ end
166
+
167
+ unless disabled_sanitizers.empty?
168
+ abort "-----\nCould not enable requested sanitizers: #{disabled_sanitizers.join(',')}\n-----"
169
+ end
170
+
171
+ unless enabled_sanitizers.empty?
172
+ warn "-----\nEnabling sanitizers: #{enabled_sanitizers.join(',')}\n-----"
173
+ enabled_sanitizers.each do |s|
174
+ # address sanitizer requires runtime support
175
+ if s == 'address' # rubocop:disable Style/IfUnlessModifier
176
+ have_library('asan') || $LDFLAGS << ' -fsanitize=address'
177
+ end
178
+ $CFLAGS << " -fsanitize=#{s}"
179
+ end
180
+ # Options for line numbers in backtraces
181
+ $CFLAGS << ' -g -fno-omit-frame-pointer'
112
182
  end
113
183
 
114
- if RUBY_PLATFORM =~ /mswin|mingw/
184
+ if RUBY_PLATFORM =~ /mswin|mingw/ && !defined?(RubyInstaller)
115
185
  # Build libmysql.a interface link library
116
186
  require 'rake'
117
187
 
@@ -119,7 +189,7 @@ if RUBY_PLATFORM =~ /mswin|mingw/
119
189
  # Use rake to rebuild only if these files change
120
190
  deffile = File.expand_path('../../../support/libmysql.def', __FILE__)
121
191
  libfile = File.expand_path(File.join(rpath_dir, 'libmysql.lib'))
122
- file 'libmysql.a' => [deffile, libfile] do |t|
192
+ file 'libmysql.a' => [deffile, libfile] do
123
193
  when_writing 'building libmysql.a' do
124
194
  # Ruby kindly shows us where dllwrap is, but that tool does more than we want.
125
195
  # Maybe in the future Ruby could provide RbConfig::CONFIG['DLLTOOL'] directly.
@@ -136,8 +206,8 @@ if RUBY_PLATFORM =~ /mswin|mingw/
136
206
 
137
207
  # Make sure the generated interface library works (if cross-compiling, trust without verifying)
138
208
  unless RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
139
- abort "-----\nCannot find libmysql.a\n----" unless have_library('libmysql')
140
- abort "-----\nCannot link to libmysql.a (my_init)\n----" unless have_func('my_init')
209
+ abort "-----\nCannot find libmysql.a\n-----" unless have_library('libmysql')
210
+ abort "-----\nCannot link to libmysql.a (my_init)\n-----" unless have_func('my_init')
141
211
  end
142
212
 
143
213
  # Vendor libmysql.dll
@@ -146,7 +216,7 @@ if RUBY_PLATFORM =~ /mswin|mingw/
146
216
 
147
217
  vendordll = File.join(vendordir, 'libmysql.dll')
148
218
  dllfile = File.expand_path(File.join(rpath_dir, 'libmysql.dll'))
149
- file vendordll => [dllfile, vendordir] do |t|
219
+ file vendordll => [dllfile, vendordir] do
150
220
  when_writing 'copying libmysql.dll' do
151
221
  cp dllfile, vendordll
152
222
  end
@@ -172,7 +242,7 @@ else
172
242
  warn "-----\nSetting mysql rpath to #{explicit_rpath}\n-----"
173
243
  $LDFLAGS << rpath_flags
174
244
  else
175
- if libdir = rpath_dir[%r{(-L)?(/[^ ]+)}, 2]
245
+ if (libdir = rpath_dir[%r{(-L)?(/[^ ]+)}, 2])
176
246
  rpath_flags = " -Wl,-rpath,#{libdir}"
177
247
  if RbConfig::CONFIG["RPATHFLAG"].to_s.empty? && try_link('int main() {return 0;}', rpath_flags)
178
248
  # Usually Ruby sets RPATHFLAG the right way for each system, but not on OS X.
data/ext/mysql2/infile.c CHANGED
@@ -56,7 +56,7 @@ mysql2_local_infile_init(void **ptr, const char *filename, void *userdata)
56
56
  * < 0 error
57
57
  */
58
58
  static int
59
- mysql2_local_infile_read(void *ptr, char *buf, uint buf_len)
59
+ mysql2_local_infile_read(void *ptr, char *buf, unsigned int buf_len)
60
60
  {
61
61
  int count;
62
62
  mysql2_local_infile_data *data = (mysql2_local_infile_data *)ptr;
@@ -95,7 +95,7 @@ mysql2_local_infile_end(void *ptr)
95
95
  * Error message number (see http://dev.mysql.com/doc/refman/5.0/en/error-messages-client.html)
96
96
  */
97
97
  static int
98
- mysql2_local_infile_error(void *ptr, char *error_msg, uint error_msg_len)
98
+ mysql2_local_infile_error(void *ptr, char *error_msg, unsigned int error_msg_len)
99
99
  {
100
100
  mysql2_local_infile_data *data = (mysql2_local_infile_data *) ptr;
101
101
 
@@ -1,12 +1,14 @@
1
1
  #include <mysql2_ext.h>
2
2
 
3
- VALUE mMysql2, cMysql2Error;
3
+ VALUE mMysql2, cMysql2Error, cMysql2TimeoutError;
4
4
 
5
5
  /* Ruby Extension initializer */
6
6
  void Init_mysql2() {
7
7
  mMysql2 = rb_define_module("Mysql2");
8
8
  cMysql2Error = rb_const_get(mMysql2, rb_intern("Error"));
9
+ cMysql2TimeoutError = rb_const_get(cMysql2Error, rb_intern("TimeoutError"));
9
10
 
10
11
  init_mysql2_client();
11
12
  init_mysql2_result();
13
+ init_mysql2_statement();
12
14
  }
@@ -1,44 +1,43 @@
1
1
  #ifndef MYSQL2_EXT
2
2
  #define MYSQL2_EXT
3
3
 
4
+ void Init_mysql2(void);
5
+
4
6
  /* tell rbx not to use it's caching compat layer
5
7
  by doing this we're making a promise to RBX that
6
8
  we'll never modify the pointers we get back from RSTRING_PTR */
7
9
  #define RSTRING_NOT_MODIFIED
8
10
  #include <ruby.h>
9
11
 
10
- #ifndef HAVE_UINT
11
- #define HAVE_UINT
12
- typedef unsigned short ushort;
13
- typedef unsigned int uint;
14
- #endif
15
-
16
12
  #ifdef HAVE_MYSQL_H
17
13
  #include <mysql.h>
18
- #include <mysql_com.h>
19
14
  #include <errmsg.h>
20
- #include <mysqld_error.h>
21
15
  #else
22
16
  #include <mysql/mysql.h>
23
- #include <mysql/mysql_com.h>
24
17
  #include <mysql/errmsg.h>
25
- #include <mysql/mysqld_error.h>
26
18
  #endif
27
19
 
28
- #ifdef HAVE_RUBY_ENCODING_H
29
20
  #include <ruby/encoding.h>
30
- #endif
31
- #ifdef HAVE_RUBY_THREAD_H
32
21
  #include <ruby/thread.h>
33
- #endif
34
22
 
35
23
  #if defined(__GNUC__) && (__GNUC__ >= 3)
24
+ #define RB_MYSQL_NORETURN __attribute__ ((noreturn))
36
25
  #define RB_MYSQL_UNUSED __attribute__ ((unused))
37
26
  #else
27
+ #define RB_MYSQL_NORETURN
38
28
  #define RB_MYSQL_UNUSED
39
29
  #endif
40
30
 
31
+ /* MySQL 8.0 replaces my_bool with C99 bool. Earlier versions of MySQL had
32
+ * a typedef to char. Gem users reported failures on big endian systems when
33
+ * using C99 bool types with older MySQLs due to mismatched behavior. */
34
+ #ifndef HAVE_TYPE_MY_BOOL
35
+ #include <stdbool.h>
36
+ typedef bool my_bool;
37
+ #endif
38
+
41
39
  #include <client.h>
40
+ #include <statement.h>
42
41
  #include <result.h>
43
42
  #include <infile.h>
44
43
 
@@ -1,4 +1,4 @@
1
- /* C code produced by gperf version 3.0.3 */
1
+ /* C code produced by gperf version 3.0.4 */
2
2
  /* Command-line: gperf */
3
3
  /* Computed positions: -k'1,3,$' */
4
4
 
@@ -30,7 +30,7 @@ error "gperf generated tables don't work with this execution character set. Plea
30
30
  #endif
31
31
 
32
32
  struct mysql2_mysql_enc_name_to_rb_map { const char *name; const char *rb_name; };
33
- /* maximum key range = 66, duplicates = 0 */
33
+ /* maximum key range = 71, duplicates = 0 */
34
34
 
35
35
  #ifdef __GNUC__
36
36
  __inline
@@ -46,39 +46,39 @@ mysql2_mysql_enc_name_to_rb_hash (str, len)
46
46
  {
47
47
  static const unsigned char asso_values[] =
48
48
  {
49
- 69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
50
- 69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
51
- 69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
52
- 69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
53
- 69, 69, 69, 69, 69, 69, 69, 69, 40, 5,
54
- 0, 69, 0, 40, 25, 20, 10, 55, 69, 69,
55
- 69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
56
- 69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
57
- 69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
58
- 69, 69, 69, 69, 69, 69, 69, 35, 5, 0,
59
- 10, 0, 20, 0, 5, 5, 69, 0, 10, 15,
60
- 0, 0, 69, 69, 25, 5, 5, 0, 69, 30,
61
- 69, 0, 69, 69, 69, 69, 69, 69, 69, 69,
62
- 69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
63
- 69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
64
- 69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
65
- 69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
66
- 69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
67
- 69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
68
- 69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
69
- 69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
70
- 69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
71
- 69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
72
- 69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
73
- 69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
74
- 69, 69, 69, 69, 69, 69
49
+ 74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
50
+ 74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
51
+ 74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
52
+ 74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
53
+ 74, 74, 74, 74, 74, 74, 74, 74, 15, 5,
54
+ 0, 74, 5, 25, 40, 10, 20, 50, 74, 74,
55
+ 74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
56
+ 74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
57
+ 74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
58
+ 74, 74, 74, 74, 74, 74, 74, 40, 5, 0,
59
+ 15, 10, 0, 0, 0, 5, 74, 0, 25, 5,
60
+ 0, 5, 74, 74, 20, 5, 5, 0, 74, 45,
61
+ 74, 0, 74, 74, 74, 74, 74, 74, 74, 74,
62
+ 74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
63
+ 74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
64
+ 74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
65
+ 74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
66
+ 74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
67
+ 74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
68
+ 74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
69
+ 74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
70
+ 74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
71
+ 74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
72
+ 74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
73
+ 74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
74
+ 74, 74, 74, 74, 74, 74
75
75
  };
76
76
  return len + asso_values[(unsigned char)str[2]] + asso_values[(unsigned char)str[0]] + asso_values[(unsigned char)str[len - 1]];
77
77
  }
78
78
 
79
79
  #ifdef __GNUC__
80
80
  __inline
81
- #ifdef __GNUC_STDC_INLINE__
81
+ #if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__
82
82
  __attribute__ ((__gnu_inline__))
83
83
  #endif
84
84
  #endif
@@ -89,11 +89,11 @@ mysql2_mysql_enc_name_to_rb (str, len)
89
89
  {
90
90
  enum
91
91
  {
92
- TOTAL_KEYWORDS = 39,
92
+ TOTAL_KEYWORDS = 41,
93
93
  MIN_WORD_LENGTH = 3,
94
94
  MAX_WORD_LENGTH = 8,
95
95
  MIN_HASH_VALUE = 3,
96
- MAX_HASH_VALUE = 68
96
+ MAX_HASH_VALUE = 73
97
97
  };
98
98
 
99
99
  static const struct mysql2_mysql_enc_name_to_rb_map wordlist[] =
@@ -101,54 +101,58 @@ mysql2_mysql_enc_name_to_rb (str, len)
101
101
  {""}, {""}, {""},
102
102
  {"gbk", "GBK"},
103
103
  {""},
104
- {"greek", "ISO-8859-7"},
104
+ {"utf32", "UTF-32"},
105
105
  {"gb2312", "GB2312"},
106
106
  {"keybcs2", NULL},
107
107
  {""},
108
108
  {"ucs2", "UTF-16BE"},
109
109
  {"koi8u", "KOI8-R"},
110
110
  {"binary", "ASCII-8BIT"},
111
- {"eucjpms", "eucJP-ms"},
112
- {""},
111
+ {"utf8mb4", "UTF-8"},
112
+ {"macroman", "macRoman"},
113
113
  {"ujis", "eucJP-ms"},
114
- {"cp852", "CP852"},
114
+ {"greek", "ISO-8859-7"},
115
115
  {"cp1251", "Windows-1251"},
116
- {"geostd8", NULL},
116
+ {"utf16le", "UTF-16LE"},
117
117
  {""},
118
118
  {"sjis", "Shift_JIS"},
119
119
  {"macce", "macCentEuro"},
120
- {"latin2", "ISO-8859-2"},
120
+ {"cp1257", "Windows-1257"},
121
+ {"eucjpms", "eucJP-ms"},
122
+ {""},
123
+ {"utf8", "UTF-8"},
124
+ {"cp852", "CP852"},
125
+ {"cp1250", "Windows-1250"},
126
+ {"gb18030", "GB18030"},
121
127
  {""},
122
- {"macroman", "macRoman"},
123
- {"dec8", NULL},
124
- {"utf32", "UTF-32"},
125
- {"latin1", "ISO-8859-1"},
126
- {"utf8mb4", "UTF-8"},
127
- {"hp8", NULL},
128
128
  {"swe7", NULL},
129
+ {"koi8r", "KOI8-R"},
130
+ {"tis620", "TIS-620"},
131
+ {"geostd8", NULL},
132
+ {""},
133
+ {"big5", "Big5"},
129
134
  {"euckr", "EUC-KR"},
130
- {"cp1257", "Windows-1257"},
135
+ {"latin2", "ISO-8859-2"},
131
136
  {""}, {""},
132
- {"utf8", "UTF-8"},
133
- {"koi8r", "KOI8-R"},
134
- {"cp1256", "Windows-1256"},
135
- {""}, {""}, {""},
136
- {"cp866", "IBM866"},
137
+ {"dec8", NULL},
138
+ {"cp850", "CP850"},
139
+ {"latin1", "ISO-8859-1"},
140
+ {""},
141
+ {"hp8", NULL},
142
+ {""},
143
+ {"utf16", "UTF-16"},
137
144
  {"latin7", "ISO-8859-13"},
138
145
  {""}, {""}, {""},
139
146
  {"ascii", "US-ASCII"},
140
- {"hebrew", "ISO-8859-8"},
141
- {""}, {""},
142
- {"big5", "Big5"},
143
- {"utf16", "UTF-16"},
144
- {"cp1250", "Windows-1250"},
145
- {""}, {""}, {""},
146
- {"cp850", "CP850"},
147
- {"tis620", "TIS-620"},
147
+ {"cp1256", "Windows-1256"},
148
148
  {""}, {""}, {""},
149
149
  {"cp932", "Windows-31J"},
150
+ {"hebrew", "ISO-8859-8"},
151
+ {""}, {""}, {""}, {""},
150
152
  {"latin5", "ISO-8859-9"},
151
- {""}, {""}, {""}, {""}, {""}, {""},
153
+ {""}, {""}, {""},
154
+ {"cp866", "IBM866"},
155
+ {""}, {""}, {""}, {""}, {""}, {""}, {""},
152
156
  {"armscii8", NULL}
153
157
  };
154
158