mysql2 0.5.0 → 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +81 -34
- data/ext/mysql2/client.c +123 -25
- data/ext/mysql2/extconf.rb +24 -6
- data/ext/mysql2/mysql2_ext.c +6 -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 +231 -15
- data/ext/mysql2/result.h +1 -0
- data/ext/mysql2/statement.c +46 -14
- data/lib/mysql2/client.rb +20 -3
- data/lib/mysql2/error.rb +4 -3
- data/lib/mysql2/statement.rb +1 -3
- data/lib/mysql2/version.rb +1 -1
- data/lib/mysql2.rb +7 -3
- data/support/3A79BD29.asc +49 -0
- 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 +10 -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
data/support/5072E1F5.asc
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
2
|
-
Version: GnuPG v1
|
2
|
+
Version: GnuPG v1
|
3
3
|
|
4
4
|
mQGiBD4+owwRBAC14GIfUfCyEDSIePvEW3SAFUdJBtoQHH/nJKZyQT7h9bPlUWC3
|
5
5
|
RODjQReyCITRrdwyrKUGku2FmeVGwn2u2WmDMNABLnpprWPkBdCk96+OmSLN9brZ
|
@@ -11,9 +11,9 @@ kYpXBACmWpP8NJTkamEnPCia2ZoOHODANwpUkP43I7jsDmgtobZX9qnrAXw+uNDI
|
|
11
11
|
QJEXM6FSbi0LLtZciNlYsafwAPEOMDKpMqAK6IyisNtPvaLd8lH0bPAnWqcyefep
|
12
12
|
rv0sxxqUEMcM3o7wwgfN83POkDasDbs3pjwPhxvhz6//62zQJ7Q2TXlTUUwgUmVs
|
13
13
|
ZWFzZSBFbmdpbmVlcmluZyA8bXlzcWwtYnVpbGRAb3NzLm9yYWNsZS5jb20+iGwE
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
ExECACwCGyMCHgECF4ACGQEGCwkIBwMCBhUKCQgCAwUWAgMBAAUCXEBY+wUJI87e
|
15
|
+
5AAKCRCMcY07UHLh9RZPAJ9uvm0zlzfCN+DHxHVaoFLFjdVYTQCfborsC9tmEZYa
|
16
|
+
whhogjeBkZkorbyIaQQTEQIAKQIbIwYLCQgHAwIEFQIIAwQWAgMBAh4BAheAAhkB
|
17
17
|
BQJTAdRmBQkaZsvLAAoJEIxxjTtQcuH1X4MAoKNLWAbCBUj96637kv6Xa/fJuX5m
|
18
18
|
AJwPtmgDfjUe2iuhXdTrFEPT19SB6ohmBBMRAgAmAhsjBgsJCAcDAgQVAggDBBYC
|
19
19
|
AwECHgECF4AFAk53PioFCRP7AhUACgkQjHGNO1By4fUmzACeJdfqgc9gWTUhgmcM
|
@@ -428,5 +428,5 @@ GoaU9u41oyZTIiXPiFidJoIZCh7fdurP8pn3X+R5HUNXMr7M+ba8lSNxce/F3kmH
|
|
428
428
|
0L7rsKqdh9d/aVxhJINJ+inVDnrXWVoXu9GBjT8Nco1iU9SIVAQYEQIADAUCTnc9
|
429
429
|
7QUJE/sBuAASB2VHUEcAAQEJEIxxjTtQcuH1FJsAmwWK9vmwRJ/y9gTnJ8PWf0BV
|
430
430
|
roUTAKClYAhZuX2nUNwH4vlEJQHDqYa5yQ==
|
431
|
-
=
|
431
|
+
=ghXk
|
432
432
|
-----END PGP PUBLIC KEY BLOCK-----
|
@@ -43,6 +43,8 @@ mysql_to_rb = {
|
|
43
43
|
"geostd8" => "NULL",
|
44
44
|
"cp932" => "Windows-31J",
|
45
45
|
"eucjpms" => "eucJP-ms",
|
46
|
+
"utf16le" => "UTF-16LE",
|
47
|
+
"gb18030" => "GB18030",
|
46
48
|
}
|
47
49
|
|
48
50
|
client = Mysql2::Client.new(username: user, password: pass, host: host, port: port.to_i)
|
@@ -52,7 +54,10 @@ encodings_with_nil = Array.new(encodings.size)
|
|
52
54
|
|
53
55
|
collations.each do |collation|
|
54
56
|
mysql_col_idx = collation[2].to_i
|
55
|
-
rb_enc = mysql_to_rb
|
57
|
+
rb_enc = mysql_to_rb.fetch(collation[1]) do |mysql_enc|
|
58
|
+
$stderr.puts "WARNING: Missing mapping for collation \"#{collation[0]}\" with encoding \"#{mysql_enc}\" and id #{mysql_col_idx}, assuming NULL"
|
59
|
+
"NULL"
|
60
|
+
end
|
56
61
|
encodings[mysql_col_idx - 1] = [mysql_col_idx, rb_enc]
|
57
62
|
end
|
58
63
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mysql2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Lopez
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2022-05-03 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description:
|
15
15
|
email:
|
@@ -23,8 +23,6 @@ files:
|
|
23
23
|
- CHANGELOG.md
|
24
24
|
- LICENSE
|
25
25
|
- README.md
|
26
|
-
- examples/eventmachine.rb
|
27
|
-
- examples/threaded.rb
|
28
26
|
- ext/mysql2/client.c
|
29
27
|
- ext/mysql2/client.h
|
30
28
|
- ext/mysql2/extconf.rb
|
@@ -48,29 +46,7 @@ files:
|
|
48
46
|
- lib/mysql2/result.rb
|
49
47
|
- lib/mysql2/statement.rb
|
50
48
|
- lib/mysql2/version.rb
|
51
|
-
-
|
52
|
-
- spec/em/em_spec.rb
|
53
|
-
- spec/my.cnf.example
|
54
|
-
- spec/mysql2/client_spec.rb
|
55
|
-
- spec/mysql2/error_spec.rb
|
56
|
-
- spec/mysql2/result_spec.rb
|
57
|
-
- spec/mysql2/statement_spec.rb
|
58
|
-
- spec/rcov.opts
|
59
|
-
- spec/spec_helper.rb
|
60
|
-
- spec/ssl/ca-cert.pem
|
61
|
-
- spec/ssl/ca-key.pem
|
62
|
-
- spec/ssl/ca.cnf
|
63
|
-
- spec/ssl/cert.cnf
|
64
|
-
- spec/ssl/client-cert.pem
|
65
|
-
- spec/ssl/client-key.pem
|
66
|
-
- spec/ssl/client-req.pem
|
67
|
-
- spec/ssl/gen_certs.sh
|
68
|
-
- spec/ssl/pkcs8-client-key.pem
|
69
|
-
- spec/ssl/pkcs8-server-key.pem
|
70
|
-
- spec/ssl/server-cert.pem
|
71
|
-
- spec/ssl/server-key.pem
|
72
|
-
- spec/ssl/server-req.pem
|
73
|
-
- spec/test_data
|
49
|
+
- support/3A79BD29.asc
|
74
50
|
- support/5072E1F5.asc
|
75
51
|
- support/libmysql.def
|
76
52
|
- support/mysql_enc_to_ruby.rb
|
@@ -79,6 +55,11 @@ homepage: https://github.com/brianmario/mysql2
|
|
79
55
|
licenses:
|
80
56
|
- MIT
|
81
57
|
metadata:
|
58
|
+
bug_tracker_uri: https://github.com/brianmario/mysql2/issues
|
59
|
+
changelog_uri: https://github.com/brianmario/mysql2/releases/tag/0.5.4
|
60
|
+
documentation_uri: https://www.rubydoc.info/gems/mysql2/0.5.4
|
61
|
+
homepage_uri: https://github.com/brianmario/mysql2
|
62
|
+
source_code_uri: https://github.com/brianmario/mysql2/tree/0.5.4
|
82
63
|
msys2_mingw_dependencies: libmariadbclient
|
83
64
|
post_install_message:
|
84
65
|
rdoc_options:
|
@@ -96,34 +77,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
77
|
- !ruby/object:Gem::Version
|
97
78
|
version: '0'
|
98
79
|
requirements: []
|
99
|
-
|
100
|
-
rubygems_version: 2.5.2
|
80
|
+
rubygems_version: 3.0.3.1
|
101
81
|
signing_key:
|
102
82
|
specification_version: 4
|
103
83
|
summary: A simple, fast Mysql library for Ruby, binding to libmysql
|
104
|
-
test_files:
|
105
|
-
- examples/eventmachine.rb
|
106
|
-
- examples/threaded.rb
|
107
|
-
- spec/configuration.yml.example
|
108
|
-
- spec/em/em_spec.rb
|
109
|
-
- spec/my.cnf.example
|
110
|
-
- spec/mysql2/client_spec.rb
|
111
|
-
- spec/mysql2/error_spec.rb
|
112
|
-
- spec/mysql2/result_spec.rb
|
113
|
-
- spec/mysql2/statement_spec.rb
|
114
|
-
- spec/rcov.opts
|
115
|
-
- spec/spec_helper.rb
|
116
|
-
- spec/ssl/ca-cert.pem
|
117
|
-
- spec/ssl/ca-key.pem
|
118
|
-
- spec/ssl/ca.cnf
|
119
|
-
- spec/ssl/cert.cnf
|
120
|
-
- spec/ssl/client-cert.pem
|
121
|
-
- spec/ssl/client-key.pem
|
122
|
-
- spec/ssl/client-req.pem
|
123
|
-
- spec/ssl/gen_certs.sh
|
124
|
-
- spec/ssl/pkcs8-client-key.pem
|
125
|
-
- spec/ssl/pkcs8-server-key.pem
|
126
|
-
- spec/ssl/server-cert.pem
|
127
|
-
- spec/ssl/server-key.pem
|
128
|
-
- spec/ssl/server-req.pem
|
129
|
-
- spec/test_data
|
84
|
+
test_files: []
|
data/examples/eventmachine.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
$LOAD_PATH.unshift 'lib'
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require 'eventmachine'
|
5
|
-
require 'mysql2/em'
|
6
|
-
|
7
|
-
EM.run do
|
8
|
-
client1 = Mysql2::EM::Client.new
|
9
|
-
defer1 = client1.query "SELECT sleep(3) as first_query"
|
10
|
-
defer1.callback do |result|
|
11
|
-
puts "Result: #{result.to_a.inspect}"
|
12
|
-
end
|
13
|
-
|
14
|
-
client2 = Mysql2::EM::Client.new
|
15
|
-
defer2 = client2.query "SELECT sleep(1) second_query"
|
16
|
-
defer2.callback do |result|
|
17
|
-
puts "Result: #{result.to_a.inspect}"
|
18
|
-
end
|
19
|
-
end
|
data/examples/threaded.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
$LOAD_PATH.unshift 'lib'
|
2
|
-
require 'mysql2'
|
3
|
-
require 'timeout'
|
4
|
-
|
5
|
-
# Should never exceed worst case 3.5 secs across all 20 threads
|
6
|
-
Timeout.timeout(3.5) do
|
7
|
-
Array.new(20) do
|
8
|
-
Thread.new do
|
9
|
-
overhead = rand(3)
|
10
|
-
puts ">> thread #{Thread.current.object_id} query, #{overhead} sec overhead"
|
11
|
-
# 3 second overhead per query
|
12
|
-
Mysql2::Client.new(host: "localhost", username: "root").query("SELECT sleep(#{overhead}) as result")
|
13
|
-
puts "<< thread #{Thread.current.object_id} result, #{overhead} sec overhead"
|
14
|
-
end
|
15
|
-
end.each(&:join)
|
16
|
-
end
|
data/spec/em/em_spec.rb
DELETED
@@ -1,135 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
begin
|
3
|
-
require 'eventmachine'
|
4
|
-
require 'mysql2/em'
|
5
|
-
|
6
|
-
RSpec.describe Mysql2::EM::Client do
|
7
|
-
it "should support async queries" do
|
8
|
-
results = []
|
9
|
-
EM.run do
|
10
|
-
client1 = Mysql2::EM::Client.new DatabaseCredentials['root']
|
11
|
-
defer1 = client1.query "SELECT sleep(0.1) as first_query"
|
12
|
-
defer1.callback do |result|
|
13
|
-
results << result.first
|
14
|
-
client1.close
|
15
|
-
EM.stop_event_loop
|
16
|
-
end
|
17
|
-
|
18
|
-
client2 = Mysql2::EM::Client.new DatabaseCredentials['root']
|
19
|
-
defer2 = client2.query "SELECT sleep(0.025) second_query"
|
20
|
-
defer2.callback do |result|
|
21
|
-
results << result.first
|
22
|
-
client2.close
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
expect(results[0].keys).to include("second_query")
|
27
|
-
expect(results[1].keys).to include("first_query")
|
28
|
-
end
|
29
|
-
|
30
|
-
it "should support queries in callbacks" do
|
31
|
-
results = []
|
32
|
-
EM.run do
|
33
|
-
client = Mysql2::EM::Client.new DatabaseCredentials['root']
|
34
|
-
defer1 = client.query "SELECT sleep(0.025) as first_query"
|
35
|
-
defer1.callback do |result|
|
36
|
-
results << result.first
|
37
|
-
defer2 = client.query "SELECT sleep(0.025) as second_query"
|
38
|
-
defer2.callback do |r|
|
39
|
-
results << r.first
|
40
|
-
client.close
|
41
|
-
EM.stop_event_loop
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
expect(results[0].keys).to include("first_query")
|
47
|
-
expect(results[1].keys).to include("second_query")
|
48
|
-
end
|
49
|
-
|
50
|
-
it "should not swallow exceptions raised in callbacks" do
|
51
|
-
expect do
|
52
|
-
EM.run do
|
53
|
-
client = Mysql2::EM::Client.new DatabaseCredentials['root']
|
54
|
-
defer = client.query "SELECT sleep(0.1) as first_query"
|
55
|
-
defer.callback do
|
56
|
-
client.close
|
57
|
-
raise 'some error'
|
58
|
-
end
|
59
|
-
defer.errback do
|
60
|
-
# This _shouldn't_ be run, but it needed to prevent the specs from
|
61
|
-
# freezing if this test fails.
|
62
|
-
EM.stop_event_loop
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end.to raise_error('some error')
|
66
|
-
end
|
67
|
-
|
68
|
-
context 'when an exception is raised by the client' do
|
69
|
-
let(:client) { Mysql2::EM::Client.new DatabaseCredentials['root'] }
|
70
|
-
let(:error) { StandardError.new('some error') }
|
71
|
-
before { allow(client).to receive(:async_result).and_raise(error) }
|
72
|
-
after { client.close }
|
73
|
-
|
74
|
-
it "should swallow exceptions raised in by the client" do
|
75
|
-
errors = []
|
76
|
-
EM.run do
|
77
|
-
defer = client.query "SELECT sleep(0.1) as first_query"
|
78
|
-
defer.callback do
|
79
|
-
# This _shouldn't_ be run, but it is needed to prevent the specs from
|
80
|
-
# freezing if this test fails.
|
81
|
-
EM.stop_event_loop
|
82
|
-
end
|
83
|
-
defer.errback do |err|
|
84
|
-
errors << err
|
85
|
-
EM.stop_event_loop
|
86
|
-
end
|
87
|
-
end
|
88
|
-
expect(errors).to eq([error])
|
89
|
-
end
|
90
|
-
|
91
|
-
it "should fail the deferrable" do
|
92
|
-
callbacks_run = []
|
93
|
-
EM.run do
|
94
|
-
defer = client.query "SELECT sleep(0.025) as first_query"
|
95
|
-
EM.add_timer(0.1) do
|
96
|
-
defer.callback do
|
97
|
-
callbacks_run << :callback
|
98
|
-
# This _shouldn't_ be run, but it is needed to prevent the specs from
|
99
|
-
# freezing if this test fails.
|
100
|
-
EM.stop_event_loop
|
101
|
-
end
|
102
|
-
defer.errback do
|
103
|
-
callbacks_run << :errback
|
104
|
-
EM.stop_event_loop
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
expect(callbacks_run).to eq([:errback])
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
it "should not raise error when closing client with no query running" do
|
113
|
-
callbacks_run = []
|
114
|
-
EM.run do
|
115
|
-
client = Mysql2::EM::Client.new DatabaseCredentials['root']
|
116
|
-
defer = client.query("select sleep(0.025)")
|
117
|
-
defer.callback do
|
118
|
-
callbacks_run << :callback
|
119
|
-
end
|
120
|
-
defer.errback do
|
121
|
-
callbacks_run << :errback
|
122
|
-
end
|
123
|
-
EM.add_timer(0.1) do
|
124
|
-
expect(callbacks_run).to eq([:callback])
|
125
|
-
expect do
|
126
|
-
client.close
|
127
|
-
end.not_to raise_error
|
128
|
-
EM.stop_event_loop
|
129
|
-
end
|
130
|
-
end
|
131
|
-
end
|
132
|
-
end
|
133
|
-
rescue LoadError
|
134
|
-
puts "EventMachine not installed, skipping the specs that use it"
|
135
|
-
end
|