mysql2 0.4.10 → 0.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +167 -48
  3. data/ext/mysql2/client.c +335 -108
  4. data/ext/mysql2/client.h +10 -41
  5. data/ext/mysql2/extconf.rb +84 -26
  6. data/ext/mysql2/mysql2_ext.c +8 -2
  7. data/ext/mysql2/mysql2_ext.h +21 -4
  8. data/ext/mysql2/mysql_enc_name_to_ruby.h +60 -55
  9. data/ext/mysql2/mysql_enc_to_ruby.h +79 -3
  10. data/ext/mysql2/result.c +298 -92
  11. data/ext/mysql2/result.h +3 -3
  12. data/ext/mysql2/statement.c +137 -81
  13. data/ext/mysql2/statement.h +0 -2
  14. data/ext/mysql2/wait_for_single_fd.h +2 -1
  15. data/lib/mysql2/client.rb +55 -28
  16. data/lib/mysql2/em.rb +2 -4
  17. data/lib/mysql2/error.rb +52 -22
  18. data/lib/mysql2/result.rb +2 -0
  19. data/lib/mysql2/statement.rb +3 -11
  20. data/lib/mysql2/version.rb +1 -1
  21. data/lib/mysql2.rb +19 -15
  22. data/support/3A79BD29.asc +49 -0
  23. data/support/5072E1F5.asc +5 -5
  24. data/support/C74CD1D8.asc +104 -0
  25. data/support/mysql_enc_to_ruby.rb +9 -3
  26. data/support/ruby_enc_to_mysql.rb +8 -5
  27. metadata +19 -62
  28. data/examples/eventmachine.rb +0 -21
  29. data/examples/threaded.rb +0 -18
  30. data/spec/configuration.yml.example +0 -11
  31. data/spec/em/em_spec.rb +0 -136
  32. data/spec/my.cnf.example +0 -9
  33. data/spec/mysql2/client_spec.rb +0 -1039
  34. data/spec/mysql2/error_spec.rb +0 -82
  35. data/spec/mysql2/result_spec.rb +0 -545
  36. data/spec/mysql2/statement_spec.rb +0 -776
  37. data/spec/rcov.opts +0 -3
  38. data/spec/spec_helper.rb +0 -108
  39. data/spec/ssl/ca-cert.pem +0 -17
  40. data/spec/ssl/ca-key.pem +0 -27
  41. data/spec/ssl/ca.cnf +0 -22
  42. data/spec/ssl/cert.cnf +0 -22
  43. data/spec/ssl/client-cert.pem +0 -17
  44. data/spec/ssl/client-key.pem +0 -27
  45. data/spec/ssl/client-req.pem +0 -15
  46. data/spec/ssl/gen_certs.sh +0 -48
  47. data/spec/ssl/pkcs8-client-key.pem +0 -28
  48. data/spec/ssl/pkcs8-server-key.pem +0 -28
  49. data/spec/ssl/server-cert.pem +0 -17
  50. data/spec/ssl/server-key.pem +0 -27
  51. data/spec/ssl/server-req.pem +0 -15
  52. data/spec/test_data +0 -1
data/ext/mysql2/client.h CHANGED
@@ -1,44 +1,9 @@
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
- VALUE active_thread; /* rb_thread_current() or Qnil */
6
+ VALUE active_fiber; /* rb_fiber_current() or Qnil */
42
7
  long server_version;
43
8
  int reconnect_enabled;
44
9
  unsigned int connect_timeout;
@@ -50,17 +15,21 @@ typedef struct {
50
15
  MYSQL *client;
51
16
  } mysql_client_wrapper;
52
17
 
53
- void rb_mysql_client_set_active_thread(VALUE self);
18
+ void rb_mysql_set_server_query_flags(MYSQL *client, VALUE result);
54
19
 
20
+ extern const rb_data_type_t rb_mysql_client_type;
21
+
22
+ #ifdef NEW_TYPEDDATA_WRAPPER
23
+ #define GET_CLIENT(self) \
24
+ mysql_client_wrapper *wrapper; \
25
+ TypedData_Get_Struct(self, mysql_client_wrapper, &rb_mysql_client_type, wrapper);
26
+ #else
55
27
  #define GET_CLIENT(self) \
56
28
  mysql_client_wrapper *wrapper; \
57
29
  Data_Get_Struct(self, mysql_client_wrapper, wrapper);
30
+ #endif
58
31
 
59
32
  void init_mysql2_client(void);
60
33
  void decr_mysql2_client(mysql_client_wrapper *wrapper);
61
34
 
62
35
  #endif
63
-
64
- #ifndef HAVE_RB_HASH_DUP
65
- VALUE rb_hash_dup(VALUE other);
66
- #endif
@@ -1,48 +1,81 @@
1
- # encoding: UTF-8
2
1
  require 'mkmf'
3
2
  require 'English'
4
3
 
4
+ ### Some helper functions
5
+
5
6
  def asplode(lib)
6
7
  if RUBY_PLATFORM =~ /mingw|mswin/
7
8
  abort "-----\n#{lib} is missing. Check your installation of MySQL or Connector/C, and try again.\n-----"
8
9
  elsif RUBY_PLATFORM =~ /darwin/
9
10
  abort "-----\n#{lib} is missing. You may need to 'brew install mysql' or 'port install mysql', and try again.\n-----"
10
11
  else
11
- abort "-----\n#{lib} is missing. You may need to 'apt-get install libmysqlclient-dev' or 'yum install mysql-devel', and try again.\n-----"
12
+ 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-----"
12
13
  end
13
14
  end
14
15
 
15
16
  def add_ssl_defines(header)
16
- 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|
17
+ 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|
17
18
  m && have_const(ssl_mode, header)
18
19
  end
19
- $CFLAGS << ' -DFULL_SSL_MODE_SUPPORT' if all_modes_found
20
- # if we only have ssl toggle (--ssl,--disable-ssl) from 5.7.3 to 5.7.10
21
- has_no_support = all_modes_found ? false : !have_const('MYSQL_OPT_SSL_ENFORCE', header)
22
- $CFLAGS << ' -DNO_SSL_MODE_SUPPORT' if has_no_support
20
+ if all_modes_found
21
+ $CFLAGS << ' -DFULL_SSL_MODE_SUPPORT'
22
+ else
23
+ # if we only have ssl toggle (--ssl,--disable-ssl) from 5.7.3 to 5.7.10
24
+ # and the verify server cert option. This is also the case for MariaDB.
25
+ has_verify_support = have_const('MYSQL_OPT_SSL_VERIFY_SERVER_CERT', header)
26
+ has_enforce_support = have_const('MYSQL_OPT_SSL_ENFORCE', header)
27
+ $CFLAGS << ' -DNO_SSL_MODE_SUPPORT' if !has_verify_support && !has_enforce_support
28
+ end
23
29
  end
24
30
 
31
+ ### Check for Ruby C extention interfaces
32
+
25
33
  # 2.1+
26
34
  have_func('rb_absint_size')
27
35
  have_func('rb_absint_singlebit_p')
28
36
 
29
- # 2.0-only
30
- have_header('ruby/thread.h') && have_func('rb_thread_call_without_gvl', 'ruby/thread.h')
37
+ # 2.7+
38
+ have_func('rb_gc_mark_movable')
31
39
 
32
- # 1.9-only
33
- have_func('rb_thread_blocking_region')
40
+ # Missing in RBX (https://github.com/rubinius/rubinius/issues/3771)
34
41
  have_func('rb_wait_for_single_fd')
35
- have_func('rb_hash_dup')
36
- have_func('rb_intern3')
37
- have_func('rb_big_cmp')
42
+
43
+ # 3.0+
44
+ have_func('rb_enc_interned_str', 'ruby.h')
45
+
46
+ ### Find OpenSSL library
47
+
48
+ # User-specified OpenSSL if explicitly specified
49
+ if with_config('openssl-dir')
50
+ _, lib = dir_config('openssl')
51
+ if lib
52
+ # Ruby versions below 2.0 on Unix and below 2.1 on Windows
53
+ # do not properly search for lib directories, and must be corrected:
54
+ # https://bugs.ruby-lang.org/projects/ruby-trunk/repository/revisions/39717
55
+ unless lib && lib[-3, 3] == 'lib'
56
+ @libdir_basename = 'lib'
57
+ _, lib = dir_config('openssl')
58
+ end
59
+ abort "-----\nCannot find library dir(s) #{lib}\n-----" unless lib && lib.split(File::PATH_SEPARATOR).any? { |dir| File.directory?(dir) }
60
+ warn "-----\nUsing --with-openssl-dir=#{File.dirname lib}\n-----"
61
+ $LDFLAGS << " -L#{lib}"
62
+ end
63
+ # Homebrew OpenSSL on MacOS
64
+ elsif RUBY_PLATFORM =~ /darwin/ && system('command -v brew')
65
+ openssl_location = `brew --prefix openssl`.strip
66
+ $LDFLAGS << " -L#{openssl_location}/lib" if openssl_location
67
+ end
68
+
69
+ ### Find MySQL client library
38
70
 
39
71
  # borrowed from mysqlplus
40
72
  # http://github.com/oldmoe/mysqlplus/blob/master/ext/extconf.rb
41
- dirs = ENV.fetch('PATH').split(File::PATH_SEPARATOR) + %w(
73
+ dirs = ENV.fetch('PATH').split(File::PATH_SEPARATOR) + %w[
42
74
  /opt
43
75
  /opt/local
44
76
  /opt/local/mysql
45
77
  /opt/local/lib/mysql5*
78
+ /opt/homebrew/opt/mysql*
46
79
  /usr
47
80
  /usr/mysql
48
81
  /usr/local
@@ -50,20 +83,22 @@ dirs = ENV.fetch('PATH').split(File::PATH_SEPARATOR) + %w(
50
83
  /usr/local/mysql-*
51
84
  /usr/local/lib/mysql5*
52
85
  /usr/local/opt/mysql5*
53
- ).map { |dir| dir << '/bin' }
86
+ /usr/local/opt/mysql@*
87
+ /usr/local/opt/mysql-client
88
+ /usr/local/opt/mysql-client@*
89
+ ].map { |dir| dir << '/bin' }
54
90
 
55
91
  # For those without HOMEBREW_ROOT in PATH
56
92
  dirs << "#{ENV['HOMEBREW_ROOT']}/bin" if ENV['HOMEBREW_ROOT']
57
93
 
58
- GLOB = "{#{dirs.join(',')}}/{mysql_config,mysql_config5,mariadb_config}"
94
+ GLOB = "{#{dirs.join(',')}}/{mysql_config,mysql_config5,mariadb_config}".freeze
59
95
 
60
96
  # If the user has provided a --with-mysql-dir argument, we must respect it or fail.
61
97
  inc, lib = dir_config('mysql')
62
98
  if inc && lib
63
- # TODO: Remove when 2.0.0 is the minimum supported version
64
- # Ruby versions not incorporating the mkmf fix at
99
+ # Ruby versions below 2.0 on Unix and below 2.1 on Windows
100
+ # do not properly search for lib directories, and must be corrected:
65
101
  # https://bugs.ruby-lang.org/projects/ruby-trunk/repository/revisions/39717
66
- # do not properly search for lib directories, and must be corrected
67
102
  unless lib && lib[-3, 3] == 'lib'
68
103
  @libdir_basename = 'lib'
69
104
  inc, lib = dir_config('mysql')
@@ -72,6 +107,7 @@ if inc && lib
72
107
  abort "-----\nCannot find library dir(s) #{lib}\n-----" unless lib && lib.split(File::PATH_SEPARATOR).any? { |dir| File.directory?(dir) }
73
108
  warn "-----\nUsing --with-mysql-dir=#{File.dirname inc}\n-----"
74
109
  rpath_dir = lib
110
+ have_library('mysqlclient')
75
111
  elsif (mc = (with_config('mysql-config') || Dir[GLOB].first))
76
112
  # If the user has provided a --with-mysql-config argument, we must respect it or fail.
77
113
  # If the user gave --with-mysql-config with no argument means we should try to find it.
@@ -92,7 +128,7 @@ elsif (mc = (with_config('mysql-config') || Dir[GLOB].first))
92
128
  else
93
129
  _, usr_local_lib = dir_config('mysql', '/usr/local')
94
130
 
95
- asplode("mysql client") unless find_library('mysqlclient', 'mysql_query', usr_local_lib, "#{usr_local_lib}/mysql")
131
+ asplode("mysql client") unless find_library('mysqlclient', nil, usr_local_lib, "#{usr_local_lib}/mysql")
96
132
 
97
133
  rpath_dir = usr_local_lib
98
134
  end
@@ -105,7 +141,7 @@ else
105
141
  asplode 'mysql.h'
106
142
  end
107
143
 
108
- %w(errmsg.h).each do |h|
144
+ %w[errmsg.h].each do |h|
109
145
  header = [prefix, h].compact.join('/')
110
146
  asplode h unless have_header header
111
147
  end
@@ -114,12 +150,30 @@ mysql_h = [prefix, 'mysql.h'].compact.join('/')
114
150
  add_ssl_defines(mysql_h)
115
151
  have_struct_member('MYSQL', 'net.vio', mysql_h)
116
152
  have_struct_member('MYSQL', 'net.pvio', mysql_h)
153
+
154
+ # These constants are actually enums, so they cannot be detected by #ifdef in C code.
155
+ have_const('MYSQL_DEFAULT_AUTH', mysql_h)
117
156
  have_const('MYSQL_ENABLE_CLEARTEXT_PLUGIN', mysql_h)
157
+ have_const('SERVER_QUERY_NO_GOOD_INDEX_USED', mysql_h)
158
+ have_const('SERVER_QUERY_NO_INDEX_USED', mysql_h)
159
+ have_const('SERVER_QUERY_WAS_SLOW', mysql_h)
160
+ have_const('MYSQL_OPTION_MULTI_STATEMENTS_ON', mysql_h)
161
+ have_const('MYSQL_OPTION_MULTI_STATEMENTS_OFF', mysql_h)
162
+
163
+ # my_bool is replaced by C99 bool in MySQL 8.0, but we want
164
+ # to retain compatibility with the typedef in earlier MySQLs.
165
+ have_type('my_bool', mysql_h)
166
+
167
+ # detect mysql functions
168
+ have_func('mysql_ssl_set', mysql_h)
169
+
170
+ ### Compiler flags to help catch errors
118
171
 
119
172
  # This is our wishlist. We use whichever flags work on the host.
120
173
  # -Wall and -Wextra are included by default.
121
174
  wishlist = [
122
175
  '-Weverything',
176
+ '-Wno-compound-token-split-by-macro', # Fixed in Ruby 2.7+ at https://bugs.ruby-lang.org/issues/17865
123
177
  '-Wno-bad-function-cast', # rb_thread_call_without_gvl returns void * that we cast to VALUE
124
178
  '-Wno-conditional-uninitialized', # false positive in client.c
125
179
  '-Wno-covered-switch-default', # result.c -- enum_field_types (when fully covered, e.g. mysql 5.5)
@@ -144,13 +198,15 @@ end
144
198
 
145
199
  $CFLAGS << ' ' << usable_flags.join(' ')
146
200
 
201
+ ### Sanitizers to help with debugging -- many are available on both Clang/LLVM and GCC
202
+
147
203
  enabled_sanitizers = disabled_sanitizers = []
148
- # Specify a commna-separated list of sanitizers, or try them all by default
204
+ # Specify a comma-separated list of sanitizers, or try them all by default
149
205
  sanitizers = with_config('sanitize')
150
206
  case sanitizers
151
207
  when true
152
208
  # Try them all, turn on whatever we can
153
- enabled_sanitizers = %w(address cfi integer memory thread undefined).select do |s|
209
+ enabled_sanitizers = %w[address cfi integer memory thread undefined].select do |s|
154
210
  try_link('int main() {return 0;}', "-Werror -fsanitize=#{s}")
155
211
  end
156
212
  abort "-----\nCould not enable any sanitizers!\n-----" if enabled_sanitizers.empty?
@@ -161,7 +217,7 @@ when String
161
217
  end
162
218
  end
163
219
 
164
- unless disabled_sanitizers.empty?
220
+ unless disabled_sanitizers.empty? # rubocop:disable Style/IfUnlessModifier
165
221
  abort "-----\nCould not enable requested sanitizers: #{disabled_sanitizers.join(',')}\n-----"
166
222
  end
167
223
 
@@ -178,7 +234,9 @@ unless enabled_sanitizers.empty?
178
234
  $CFLAGS << ' -g -fno-omit-frame-pointer'
179
235
  end
180
236
 
181
- if RUBY_PLATFORM =~ /mswin|mingw/
237
+ ### Find MySQL Client on Windows, set RPATH to find the library at runtime
238
+
239
+ if RUBY_PLATFORM =~ /mswin|mingw/ && !defined?(RubyInstaller)
182
240
  # Build libmysql.a interface link library
183
241
  require 'rake'
184
242
 
@@ -1,11 +1,17 @@
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
- mMysql2 = rb_define_module("Mysql2");
7
+ mMysql2 = rb_define_module("Mysql2");
8
+ rb_global_variable(&mMysql2);
9
+
8
10
  cMysql2Error = rb_const_get(mMysql2, rb_intern("Error"));
11
+ rb_global_variable(&cMysql2Error);
12
+
13
+ cMysql2TimeoutError = rb_const_get(cMysql2Error, rb_intern("TimeoutError"));
14
+ rb_global_variable(&cMysql2TimeoutError);
9
15
 
10
16
  init_mysql2_client();
11
17
  init_mysql2_result();
@@ -17,12 +17,8 @@ void Init_mysql2(void);
17
17
  #include <mysql/errmsg.h>
18
18
  #endif
19
19
 
20
- #ifdef HAVE_RUBY_ENCODING_H
21
20
  #include <ruby/encoding.h>
22
- #endif
23
- #ifdef HAVE_RUBY_THREAD_H
24
21
  #include <ruby/thread.h>
25
- #endif
26
22
 
27
23
  #if defined(__GNUC__) && (__GNUC__ >= 3)
28
24
  #define RB_MYSQL_NORETURN __attribute__ ((noreturn))
@@ -32,6 +28,27 @@ void Init_mysql2(void);
32
28
  #define RB_MYSQL_UNUSED
33
29
  #endif
34
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
+
39
+ // ruby 2.7+
40
+ #ifdef HAVE_RB_GC_MARK_MOVABLE
41
+ #define rb_mysql2_gc_location(ptr) ptr = rb_gc_location(ptr)
42
+ #else
43
+ #define rb_gc_mark_movable(ptr) rb_gc_mark(ptr)
44
+ #define rb_mysql2_gc_location(ptr)
45
+ #endif
46
+
47
+ // ruby 2.2+
48
+ #ifdef TypedData_Make_Struct
49
+ #define NEW_TYPEDDATA_WRAPPER 1
50
+ #endif
51
+
35
52
  #include <client.h>
36
53
  #include <statement.h>
37
54
  #include <result.h>
@@ -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,32 +46,32 @@ 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, 30, 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
  }
@@ -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 = 42,
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,59 @@ 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
+ {"cp1257", "Windows-1257"},
121
+ {"eucjpms", "eucJP-ms"},
122
+ {""},
123
+ {"utf8", "UTF-8"},
124
+ {"cp852", "CP852"},
125
+ {"cp1250", "Windows-1250"},
126
+ {"gb18030", "GB18030"},
127
+ {""},
128
+ {"swe7", NULL},
129
+ {"koi8r", "KOI8-R"},
130
+ {"tis620", "TIS-620"},
131
+ {"geostd8", NULL},
132
+ {""},
133
+ {"big5", "Big5"},
134
+ {"euckr", "EUC-KR"},
120
135
  {"latin2", "ISO-8859-2"},
136
+ {"utf8mb3", "UTF-8"},
121
137
  {""},
122
- {"macroman", "macRoman"},
123
138
  {"dec8", NULL},
124
- {"utf32", "UTF-32"},
139
+ {"cp850", "CP850"},
125
140
  {"latin1", "ISO-8859-1"},
126
- {"utf8mb4", "UTF-8"},
141
+ {""},
127
142
  {"hp8", NULL},
128
- {"swe7", NULL},
129
- {"euckr", "EUC-KR"},
130
- {"cp1257", "Windows-1257"},
131
- {""}, {""},
132
- {"utf8", "UTF-8"},
133
- {"koi8r", "KOI8-R"},
134
- {"cp1256", "Windows-1256"},
135
- {""}, {""}, {""},
136
- {"cp866", "IBM866"},
143
+ {""},
144
+ {"utf16", "UTF-16"},
137
145
  {"latin7", "ISO-8859-13"},
138
146
  {""}, {""}, {""},
139
147
  {"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"},
148
+ {"cp1256", "Windows-1256"},
148
149
  {""}, {""}, {""},
149
150
  {"cp932", "Windows-31J"},
151
+ {"hebrew", "ISO-8859-8"},
152
+ {""}, {""}, {""}, {""},
150
153
  {"latin5", "ISO-8859-9"},
151
- {""}, {""}, {""}, {""}, {""}, {""},
154
+ {""}, {""}, {""},
155
+ {"cp866", "IBM866"},
156
+ {""}, {""}, {""}, {""}, {""}, {""}, {""},
152
157
  {"armscii8", NULL}
153
158
  };
154
159
 
@@ -54,13 +54,13 @@ static const char *mysql2_mysql_enc_to_rb[] = {
54
54
  "macRoman",
55
55
  "UTF-16",
56
56
  "UTF-16",
57
- "",
57
+ "UTF-16LE",
58
58
  "Windows-1256",
59
59
  "Windows-1257",
60
60
  "Windows-1257",
61
61
  "UTF-32",
62
62
  "UTF-32",
63
- "",
63
+ "UTF-16LE",
64
64
  "ASCII-8BIT",
65
65
  NULL,
66
66
  "US-ASCII",
@@ -74,7 +74,7 @@ static const char *mysql2_mysql_enc_to_rb[] = {
74
74
  NULL,
75
75
  "KOI8-R",
76
76
  "KOI8-R",
77
- NULL,
77
+ "UTF-8",
78
78
  "ISO-8859-2",
79
79
  "ISO-8859-9",
80
80
  "ISO-8859-13",
@@ -245,5 +245,81 @@ static const char *mysql2_mysql_enc_to_rb[] = {
245
245
  "UTF-8",
246
246
  "UTF-8",
247
247
  "UTF-8",
248
+ "UTF-8",
249
+ "GB18030",
250
+ "GB18030",
251
+ "GB18030",
252
+ NULL,
253
+ NULL,
254
+ NULL,
255
+ NULL,
256
+ "UTF-8",
257
+ "UTF-8",
258
+ "UTF-8",
259
+ "UTF-8",
260
+ "UTF-8",
261
+ "UTF-8",
262
+ "UTF-8",
263
+ "UTF-8",
264
+ "UTF-8",
265
+ "UTF-8",
266
+ "UTF-8",
267
+ "UTF-8",
268
+ "UTF-8",
269
+ "UTF-8",
270
+ "UTF-8",
271
+ "UTF-8",
272
+ "UTF-8",
273
+ NULL,
274
+ "UTF-8",
275
+ "UTF-8",
276
+ "UTF-8",
277
+ NULL,
278
+ "UTF-8",
279
+ "UTF-8",
280
+ "UTF-8",
281
+ "UTF-8",
282
+ "UTF-8",
283
+ "UTF-8",
284
+ "UTF-8",
285
+ "UTF-8",
286
+ "UTF-8",
287
+ "UTF-8",
288
+ "UTF-8",
289
+ "UTF-8",
290
+ "UTF-8",
291
+ "UTF-8",
292
+ "UTF-8",
293
+ "UTF-8",
294
+ "UTF-8",
295
+ "UTF-8",
296
+ NULL,
297
+ "UTF-8",
298
+ "UTF-8",
299
+ "UTF-8",
300
+ NULL,
301
+ "UTF-8",
302
+ NULL,
303
+ NULL,
304
+ "UTF-8",
305
+ "UTF-8",
306
+ "UTF-8",
307
+ "UTF-8",
308
+ "UTF-8",
309
+ "UTF-8",
310
+ "UTF-8",
311
+ "UTF-8",
312
+ "UTF-8",
313
+ "UTF-8",
314
+ "UTF-8",
315
+ "UTF-8",
316
+ "UTF-8",
317
+ "UTF-8",
318
+ "UTF-8",
319
+ "UTF-8",
320
+ "UTF-8",
321
+ "UTF-8",
322
+ "UTF-8",
323
+ "UTF-8",
248
324
  "UTF-8"
249
325
  };