mysql2 0.5.0 → 0.5.3
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.
- checksums.yaml +5 -5
- data/README.md +49 -28
- data/ext/mysql2/client.c +25 -8
- data/ext/mysql2/extconf.rb +2 -1
- data/ext/mysql2/mysql_enc_name_to_ruby.h +60 -56
- data/ext/mysql2/mysql_enc_to_ruby.h +64 -3
- data/ext/mysql2/result.c +18 -11
- data/ext/mysql2/statement.c +36 -12
- data/lib/mysql2/client.rb +1 -1
- data/lib/mysql2/error.rb +3 -3
- data/lib/mysql2/version.rb +1 -1
- data/lib/mysql2.rb +6 -3
- data/support/5072E1F5.asc +5 -5
- data/support/mysql_enc_to_ruby.rb +6 -1
- data/support/ruby_enc_to_mysql.rb +2 -0
- metadata +4 -55
- data/examples/eventmachine.rb +0 -19
- data/examples/threaded.rb +0 -16
- data/spec/configuration.yml.example +0 -11
- data/spec/em/em_spec.rb +0 -135
- data/spec/my.cnf.example +0 -9
- data/spec/mysql2/client_spec.rb +0 -1072
- data/spec/mysql2/error_spec.rb +0 -78
- data/spec/mysql2/result_spec.rb +0 -485
- data/spec/mysql2/statement_spec.rb +0 -708
- data/spec/rcov.opts +0 -3
- data/spec/spec_helper.rb +0 -112
- data/spec/ssl/ca-cert.pem +0 -17
- data/spec/ssl/ca-key.pem +0 -27
- data/spec/ssl/ca.cnf +0 -22
- data/spec/ssl/cert.cnf +0 -22
- data/spec/ssl/client-cert.pem +0 -17
- data/spec/ssl/client-key.pem +0 -27
- data/spec/ssl/client-req.pem +0 -15
- data/spec/ssl/gen_certs.sh +0 -48
- data/spec/ssl/pkcs8-client-key.pem +0 -28
- data/spec/ssl/pkcs8-server-key.pem +0 -28
- data/spec/ssl/server-cert.pem +0 -17
- data/spec/ssl/server-key.pem +0 -27
- data/spec/ssl/server-req.pem +0 -15
- data/spec/test_data +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8be4e0f4afbea38c5460544e39c9e0d987dd040c9de5ebdbc4c1e200102ca8e4
|
4
|
+
data.tar.gz: 996e05358297b03bf8f06abffd37d83a590912246ec607d2c3ee53b325c43022
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: daf37441bcb29366453963529b5a144df0d599b79b7a0b9d90b2ae5ed3dee97c1945a58111d6fe6bc2f1c20f75c9960c3cc1cd988a0e5d1be5ce44b7dcdf3633
|
7
|
+
data.tar.gz: 421df08c45f4257c2f04f3dc0a0e1c1557c695598c4e1a80236d618d1a79510459b8919b753ad9af2d46d21fa19ba060d5b53da2f54a00ff90ca45a4534c9108
|
data/README.md
CHANGED
@@ -18,16 +18,18 @@ The API consists of three classes:
|
|
18
18
|
`Mysql2::Statement` - returned from issuing a #prepare on the connection. Execute the statement to get a Result.
|
19
19
|
|
20
20
|
## Installing
|
21
|
+
|
21
22
|
### General Instructions
|
23
|
+
|
22
24
|
``` sh
|
23
25
|
gem install mysql2
|
24
26
|
```
|
25
27
|
|
26
28
|
This gem links against MySQL's `libmysqlclient` library or `Connector/C`
|
27
29
|
library, and compatible alternatives such as MariaDB.
|
28
|
-
You may need to install a package such as `
|
29
|
-
or other appropriate package for your system. See below for
|
30
|
-
instructions.
|
30
|
+
You may need to install a package such as `libmariadb-dev`, `libmysqlclient-dev`,
|
31
|
+
`mysql-devel`, or other appropriate package for your system. See below for
|
32
|
+
system-specific instructions.
|
31
33
|
|
32
34
|
By default, the mysql2 gem will try to find a copy of MySQL in this order:
|
33
35
|
|
@@ -74,10 +76,11 @@ To see line numbers in backtraces, declare these environment variables
|
|
74
76
|
|
75
77
|
### Linux and other Unixes
|
76
78
|
|
77
|
-
You may need to install a package such as `
|
78
|
-
refer to your distribution's package guide to
|
79
|
-
The most common issue we see is a user who has
|
80
|
-
|
79
|
+
You may need to install a package such as `libmariadb-dev`, `libmysqlclient-dev`,
|
80
|
+
`mysql-devel`, or `default-libmysqlclient-dev`; refer to your distribution's package guide to
|
81
|
+
find the particular package. The most common issue we see is a user who has
|
82
|
+
the library file `libmysqlclient.so` but is missing the header file `mysql.h`
|
83
|
+
-- double check that you have the _-dev_ packages installed.
|
81
84
|
|
82
85
|
### Mac OS X
|
83
86
|
|
@@ -89,6 +92,7 @@ If you have not done so already, you will need to install the XCode select tools
|
|
89
92
|
`xcode-select --install`.
|
90
93
|
|
91
94
|
### Windows
|
95
|
+
|
92
96
|
Make sure that you have Ruby and the DevKit compilers installed. We recommend
|
93
97
|
the [Ruby Installer](http://rubyinstaller.org) distribution.
|
94
98
|
|
@@ -156,7 +160,7 @@ end
|
|
156
160
|
How about with symbolized keys?
|
157
161
|
|
158
162
|
``` ruby
|
159
|
-
client.query("SELECT * FROM users WHERE group='githubbers'", :symbolize_keys => true) do |row|
|
163
|
+
client.query("SELECT * FROM users WHERE group='githubbers'", :symbolize_keys => true).each do |row|
|
160
164
|
# do something with row, it's ready to rock
|
161
165
|
end
|
162
166
|
```
|
@@ -178,6 +182,9 @@ Pass your arguments to the execute method in the same number and order as the
|
|
178
182
|
question marks in the statement. Query options can be passed as keyword arguments
|
179
183
|
to the execute method.
|
180
184
|
|
185
|
+
Be sure to read about the known limitations of prepared statements at
|
186
|
+
[https://dev.mysql.com/doc/refman/5.6/en/c-api-prepared-statement-problems.html](https://dev.mysql.com/doc/refman/5.6/en/c-api-prepared-statement-problems.html)
|
187
|
+
|
181
188
|
``` ruby
|
182
189
|
statement = @client.prepare("SELECT * FROM users WHERE login_count = ?")
|
183
190
|
result1 = statement.execute(1)
|
@@ -214,6 +221,7 @@ Mysql2::Client.new(
|
|
214
221
|
:ssl_mode = :disabled / :preferred / :required / :verify_ca / :verify_identity,
|
215
222
|
:default_file = '/path/to/my.cfg',
|
216
223
|
:default_group = 'my.cfg section',
|
224
|
+
:default_auth = 'authentication_windows_client'
|
217
225
|
:init_command => sql
|
218
226
|
)
|
219
227
|
```
|
@@ -270,8 +278,10 @@ The string form will be split on whitespace and parsed as with the array form:
|
|
270
278
|
Plain flags are added to the default flags, while flags prefixed with `-`
|
271
279
|
(minus) are removed from the default flags.
|
272
280
|
|
273
|
-
|
274
|
-
|
281
|
+
### Using Active Record's database.yml
|
282
|
+
|
283
|
+
Active Record typically reads its configuration from a file named `database.yml` or an environment variable `DATABASE_URL`.
|
284
|
+
Use the value `mysql2` as the adapter name. For example:
|
275
285
|
|
276
286
|
``` yaml
|
277
287
|
development:
|
@@ -289,6 +299,15 @@ development:
|
|
289
299
|
secure_auth: false
|
290
300
|
```
|
291
301
|
|
302
|
+
### Using Active Record's DATABASE_URL
|
303
|
+
|
304
|
+
Active Record typically reads its configuration from a file named `database.yml` or an environment variable `DATABASE_URL`.
|
305
|
+
Use the value `mysql2` as the protocol name. For example:
|
306
|
+
|
307
|
+
``` shell
|
308
|
+
DATABASE_URL=mysql2://sql_user:sql_pass@sql_host_name:port/sql_db_name?option1=value1&option2=value2
|
309
|
+
```
|
310
|
+
|
292
311
|
### Reading a MySQL config file
|
293
312
|
|
294
313
|
You may read configuration options from a MySQL configuration file by passing
|
@@ -343,7 +362,8 @@ end
|
|
343
362
|
```
|
344
363
|
|
345
364
|
Yields:
|
346
|
-
|
365
|
+
|
366
|
+
```ruby
|
347
367
|
{"1"=>1}
|
348
368
|
{"2"=>2}
|
349
369
|
next_result: Unknown column 'A' in 'field list' (Mysql2::Error)
|
@@ -502,7 +522,7 @@ There are a few things that need to be kept in mind while using streaming:
|
|
502
522
|
* `:cache_rows` is ignored currently. (if you want to use `:cache_rows` you probably don't want to be using `:stream`)
|
503
523
|
* You must fetch all rows in the result set of your query before you can make new queries. (i.e. with `Mysql2::Result#each`)
|
504
524
|
|
505
|
-
Read more about the consequences of using `mysql_use_result` (what streaming is implemented with) here: http://dev.mysql.com/doc/refman/5.0/en/mysql-use-result.html.
|
525
|
+
Read more about the consequences of using `mysql_use_result` (what streaming is implemented with) here: [http://dev.mysql.com/doc/refman/5.0/en/mysql-use-result.html](http://dev.mysql.com/doc/refman/5.0/en/mysql-use-result.html).
|
506
526
|
|
507
527
|
### Lazy Everything
|
508
528
|
|
@@ -523,20 +543,21 @@ As for field values themselves, I'm workin on it - but expect that soon.
|
|
523
543
|
|
524
544
|
This gem is tested with the following Ruby versions on Linux and Mac OS X:
|
525
545
|
|
526
|
-
|
527
|
-
|
546
|
+
* Ruby MRI 2.0.0, 2.1.x, 2.2.x, 2.3.x, 2.4.x, 2.5.x, 2.6.x
|
547
|
+
* Rubinius 2.x and 3.x do work but may fail under some workloads
|
528
548
|
|
529
549
|
This gem is tested with the following MySQL and MariaDB versions:
|
530
550
|
|
531
|
-
|
532
|
-
|
533
|
-
|
551
|
+
* MySQL 5.5, 5.6, 5.7, 8.0
|
552
|
+
* MySQL Connector/C 6.0 and 6.1 (primarily on Windows)
|
553
|
+
* MariaDB 5.5, 10.0, 10.1, 10.2, 10.3
|
534
554
|
|
535
555
|
### Ruby on Rails / Active Record
|
536
556
|
|
537
|
-
|
538
|
-
|
539
|
-
|
557
|
+
* mysql2 0.5.x works with Rails / Active Record 5.0.7, 5.1.6, and higher.
|
558
|
+
* mysql2 0.4.x works with Rails / Active Record 4.2.5 - 5.0 and higher.
|
559
|
+
* mysql2 0.3.x works with Rails / Active Record 3.1, 3.2, 4.x, 5.0.
|
560
|
+
* mysql2 0.2.x works with Rails / Active Record 2.3 - 3.0.
|
540
561
|
|
541
562
|
### Asynchronous Active Record
|
542
563
|
|
@@ -619,11 +640,11 @@ though.
|
|
619
640
|
## Special Thanks
|
620
641
|
|
621
642
|
* Eric Wong - for the contribution (and the informative explanations) of some thread-safety, non-blocking I/O and cleanup patches. You rock dude
|
622
|
-
* Yury Korolev
|
623
|
-
* Aaron Patterson
|
624
|
-
* Mike Perham
|
625
|
-
* Aaron Stone
|
626
|
-
* Kouhei Ueno
|
627
|
-
* John Cant
|
628
|
-
* Justin Case
|
629
|
-
* Tamir Duberstein
|
643
|
+
* [Yury Korolev](http://github.com/yury) - for TONS of help testing the Active Record adapter
|
644
|
+
* [Aaron Patterson](http://github.com/tenderlove) - tons of contributions, suggestions and general badassness
|
645
|
+
* [Mike Perham](http://github.com/mperham) - Async Active Record adapter (uses Fibers and EventMachine)
|
646
|
+
* [Aaron Stone](http://github.com/sodabrew) - additional client settings, local files, microsecond time, maintenance support
|
647
|
+
* [Kouhei Ueno](https://github.com/nyaxt) - for the original work on Prepared Statements way back in 2012
|
648
|
+
* [John Cant](http://github.com/johncant) - polishing and updating Prepared Statements support
|
649
|
+
* [Justin Case](http://github.com/justincase) - polishing and updating Prepared Statements support and getting it merged
|
650
|
+
* [Tamir Duberstein](http://github.com/tamird) - for help with timeouts and all around updates and cleanups
|
data/ext/mysql2/client.c
CHANGED
@@ -18,7 +18,8 @@ VALUE cMysql2Client;
|
|
18
18
|
extern VALUE mMysql2, cMysql2Error, cMysql2TimeoutError;
|
19
19
|
static VALUE sym_id, sym_version, sym_header_version, sym_async, sym_symbolize_keys, sym_as, sym_array, sym_stream;
|
20
20
|
static VALUE sym_no_good_index_used, sym_no_index_used, sym_query_was_slow;
|
21
|
-
static ID intern_brackets, intern_merge, intern_merge_bang, intern_new_with_args
|
21
|
+
static ID intern_brackets, intern_merge, intern_merge_bang, intern_new_with_args,
|
22
|
+
intern_current_query_options, intern_read_timeout;
|
22
23
|
|
23
24
|
#define REQUIRE_INITIALIZED(wrapper) \
|
24
25
|
if (!wrapper->initialized) { \
|
@@ -112,7 +113,8 @@ static VALUE rb_set_ssl_mode_option(VALUE self, VALUE setting) {
|
|
112
113
|
#ifdef HAVE_CONST_MYSQL_OPT_SSL_ENFORCE
|
113
114
|
GET_CLIENT(self);
|
114
115
|
int val = NUM2INT( setting );
|
115
|
-
|
116
|
+
// Either MySQL 5.7.3 - 5.7.10, or Connector/C 6.1.3 - 6.1.x
|
117
|
+
if ((version >= 50703 && version < 50711) || (version >= 60103 && version < 60200)) {
|
116
118
|
if (val == SSL_MODE_DISABLED || val == SSL_MODE_REQUIRED) {
|
117
119
|
my_bool b = ( val == SSL_MODE_REQUIRED );
|
118
120
|
int result = mysql_options( wrapper->client, MYSQL_OPT_SSL_ENFORCE, &b );
|
@@ -121,6 +123,9 @@ static VALUE rb_set_ssl_mode_option(VALUE self, VALUE setting) {
|
|
121
123
|
rb_warn( "MySQL client libraries between 5.7.3 and 5.7.10 only support SSL_MODE_DISABLED and SSL_MODE_REQUIRED" );
|
122
124
|
return Qnil;
|
123
125
|
}
|
126
|
+
} else {
|
127
|
+
rb_warn( "Your mysql client library does not support ssl_mode as expected." );
|
128
|
+
return Qnil;
|
124
129
|
}
|
125
130
|
#endif
|
126
131
|
#ifdef FULL_SSL_MODE_SUPPORT
|
@@ -579,7 +584,7 @@ static VALUE rb_mysql_client_async_result(VALUE self) {
|
|
579
584
|
rb_raise_mysql2_error(wrapper);
|
580
585
|
}
|
581
586
|
|
582
|
-
is_streaming = rb_hash_aref(
|
587
|
+
is_streaming = rb_hash_aref(rb_ivar_get(self, intern_current_query_options), sym_stream);
|
583
588
|
if (is_streaming == Qtrue) {
|
584
589
|
result = (MYSQL_RES *)rb_thread_call_without_gvl(nogvl_use_result, wrapper, RUBY_UBF_IO, 0);
|
585
590
|
} else {
|
@@ -596,7 +601,7 @@ static VALUE rb_mysql_client_async_result(VALUE self) {
|
|
596
601
|
}
|
597
602
|
|
598
603
|
// Duplicate the options hash and put the copy in the Result object
|
599
|
-
current = rb_hash_dup(
|
604
|
+
current = rb_hash_dup(rb_ivar_get(self, intern_current_query_options));
|
600
605
|
(void)RB_GC_GUARD(current);
|
601
606
|
Check_Type(current, T_HASH);
|
602
607
|
resultObj = rb_mysql_result_to_obj(self, wrapper->encoding, current, result, Qnil);
|
@@ -639,7 +644,7 @@ static VALUE do_query(void *args) {
|
|
639
644
|
int retval;
|
640
645
|
VALUE read_timeout;
|
641
646
|
|
642
|
-
read_timeout =
|
647
|
+
read_timeout = rb_ivar_get(async_args->self, intern_read_timeout);
|
643
648
|
|
644
649
|
tvp = NULL;
|
645
650
|
if (!NIL_P(read_timeout)) {
|
@@ -767,7 +772,7 @@ static VALUE rb_mysql_query(VALUE self, VALUE sql, VALUE current) {
|
|
767
772
|
|
768
773
|
(void)RB_GC_GUARD(current);
|
769
774
|
Check_Type(current, T_HASH);
|
770
|
-
|
775
|
+
rb_ivar_set(self, intern_current_query_options, current);
|
771
776
|
|
772
777
|
Check_Type(sql, T_STRING);
|
773
778
|
/* ensure the string is in the encoding the connection is expecting */
|
@@ -903,6 +908,11 @@ static VALUE _mysql_client_options(VALUE self, int opt, VALUE value) {
|
|
903
908
|
retval = charval;
|
904
909
|
break;
|
905
910
|
|
911
|
+
case MYSQL_DEFAULT_AUTH:
|
912
|
+
charval = (const char *)StringValueCStr(value);
|
913
|
+
retval = charval;
|
914
|
+
break;
|
915
|
+
|
906
916
|
#ifdef HAVE_CONST_MYSQL_ENABLE_CLEARTEXT_PLUGIN
|
907
917
|
case MYSQL_ENABLE_CLEARTEXT_PLUGIN:
|
908
918
|
boolval = (value == Qfalse ? 0 : 1);
|
@@ -1174,7 +1184,7 @@ static VALUE rb_mysql_client_store_result(VALUE self)
|
|
1174
1184
|
}
|
1175
1185
|
|
1176
1186
|
// Duplicate the options hash and put the copy in the Result object
|
1177
|
-
current = rb_hash_dup(
|
1187
|
+
current = rb_hash_dup(rb_ivar_get(self, intern_current_query_options));
|
1178
1188
|
(void)RB_GC_GUARD(current);
|
1179
1189
|
Check_Type(current, T_HASH);
|
1180
1190
|
resultObj = rb_mysql_result_to_obj(self, wrapper->encoding, current, result, Qnil);
|
@@ -1260,7 +1270,7 @@ static VALUE set_read_timeout(VALUE self, VALUE value) {
|
|
1260
1270
|
/* Set the instance variable here even though _mysql_client_options
|
1261
1271
|
might not succeed, because the timeout is used in other ways
|
1262
1272
|
elsewhere */
|
1263
|
-
|
1273
|
+
rb_ivar_set(self, intern_read_timeout, value);
|
1264
1274
|
return _mysql_client_options(self, MYSQL_OPT_READ_TIMEOUT, value);
|
1265
1275
|
}
|
1266
1276
|
|
@@ -1336,6 +1346,10 @@ static VALUE set_init_command(VALUE self, VALUE value) {
|
|
1336
1346
|
return _mysql_client_options(self, MYSQL_INIT_COMMAND, value);
|
1337
1347
|
}
|
1338
1348
|
|
1349
|
+
static VALUE set_default_auth(VALUE self, VALUE value) {
|
1350
|
+
return _mysql_client_options(self, MYSQL_DEFAULT_AUTH, value);
|
1351
|
+
}
|
1352
|
+
|
1339
1353
|
static VALUE set_enable_cleartext_plugin(VALUE self, VALUE value) {
|
1340
1354
|
#ifdef HAVE_CONST_MYSQL_ENABLE_CLEARTEXT_PLUGIN
|
1341
1355
|
return _mysql_client_options(self, MYSQL_ENABLE_CLEARTEXT_PLUGIN, value);
|
@@ -1437,6 +1451,7 @@ void init_mysql2_client() {
|
|
1437
1451
|
rb_define_private_method(cMysql2Client, "default_file=", set_read_default_file, 1);
|
1438
1452
|
rb_define_private_method(cMysql2Client, "default_group=", set_read_default_group, 1);
|
1439
1453
|
rb_define_private_method(cMysql2Client, "init_command=", set_init_command, 1);
|
1454
|
+
rb_define_private_method(cMysql2Client, "default_auth=", set_default_auth, 1);
|
1440
1455
|
rb_define_private_method(cMysql2Client, "ssl_set", set_ssl_options, 5);
|
1441
1456
|
rb_define_private_method(cMysql2Client, "ssl_mode=", rb_set_ssl_mode_option, 1);
|
1442
1457
|
rb_define_private_method(cMysql2Client, "enable_cleartext_plugin=", set_enable_cleartext_plugin, 1);
|
@@ -1461,6 +1476,8 @@ void init_mysql2_client() {
|
|
1461
1476
|
intern_merge = rb_intern("merge");
|
1462
1477
|
intern_merge_bang = rb_intern("merge!");
|
1463
1478
|
intern_new_with_args = rb_intern("new_with_args");
|
1479
|
+
intern_current_query_options = rb_intern("@current_query_options");
|
1480
|
+
intern_read_timeout = rb_intern("@read_timeout");
|
1464
1481
|
|
1465
1482
|
#ifdef CLIENT_LONG_PASSWORD
|
1466
1483
|
rb_const_set(cMysql2Client, rb_intern("LONG_PASSWORD"),
|
data/ext/mysql2/extconf.rb
CHANGED
@@ -7,7 +7,7 @@ def asplode(lib)
|
|
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
|
|
@@ -63,6 +63,7 @@ if inc && lib
|
|
63
63
|
abort "-----\nCannot find library dir(s) #{lib}\n-----" unless lib && lib.split(File::PATH_SEPARATOR).any? { |dir| File.directory?(dir) }
|
64
64
|
warn "-----\nUsing --with-mysql-dir=#{File.dirname inc}\n-----"
|
65
65
|
rpath_dir = lib
|
66
|
+
have_library('mysqlclient')
|
66
67
|
elsif (mc = (with_config('mysql-config') || Dir[GLOB].first))
|
67
68
|
# If the user has provided a --with-mysql-config argument, we must respect it or fail.
|
68
69
|
# If the user gave --with-mysql-config with no argument means we should try to find it.
|
@@ -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 =
|
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
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
0,
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
10, 0,
|
60
|
-
0,
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
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
|
}
|
@@ -89,11 +89,11 @@ mysql2_mysql_enc_name_to_rb (str, len)
|
|
89
89
|
{
|
90
90
|
enum
|
91
91
|
{
|
92
|
-
TOTAL_KEYWORDS =
|
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 =
|
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
|
-
{"
|
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
|
-
{"
|
112
|
-
{""},
|
111
|
+
{"utf8mb4", "UTF-8"},
|
112
|
+
{"macroman", "macRoman"},
|
113
113
|
{"ujis", "eucJP-ms"},
|
114
|
-
{"
|
114
|
+
{"greek", "ISO-8859-7"},
|
115
115
|
{"cp1251", "Windows-1251"},
|
116
|
-
{"
|
116
|
+
{"utf16le", "UTF-16LE"},
|
117
117
|
{""},
|
118
118
|
{"sjis", "Shift_JIS"},
|
119
119
|
{"macce", "macCentEuro"},
|
120
|
-
{"
|
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
|
-
{"
|
135
|
+
{"latin2", "ISO-8859-2"},
|
131
136
|
{""}, {""},
|
132
|
-
{"
|
133
|
-
{"
|
134
|
-
{"
|
135
|
-
{""},
|
136
|
-
{"
|
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
|
-
{"
|
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
|
|
@@ -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
|
-
|
77
|
+
"UTF-8",
|
78
78
|
"ISO-8859-2",
|
79
79
|
"ISO-8859-9",
|
80
80
|
"ISO-8859-13",
|
@@ -245,5 +245,66 @@ 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",
|
248
309
|
"UTF-8"
|
249
310
|
};
|