mysql2 0.4.10 → 0.5.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +167 -48
- data/ext/mysql2/client.c +335 -108
- data/ext/mysql2/client.h +10 -41
- data/ext/mysql2/extconf.rb +84 -26
- data/ext/mysql2/mysql2_ext.c +8 -2
- data/ext/mysql2/mysql2_ext.h +21 -4
- data/ext/mysql2/mysql_enc_name_to_ruby.h +60 -55
- data/ext/mysql2/mysql_enc_to_ruby.h +79 -3
- data/ext/mysql2/result.c +298 -92
- data/ext/mysql2/result.h +3 -3
- data/ext/mysql2/statement.c +137 -81
- data/ext/mysql2/statement.h +0 -2
- data/ext/mysql2/wait_for_single_fd.h +2 -1
- data/lib/mysql2/client.rb +55 -28
- data/lib/mysql2/em.rb +2 -4
- data/lib/mysql2/error.rb +52 -22
- data/lib/mysql2/result.rb +2 -0
- data/lib/mysql2/statement.rb +3 -11
- data/lib/mysql2/version.rb +1 -1
- data/lib/mysql2.rb +19 -15
- data/support/3A79BD29.asc +49 -0
- data/support/5072E1F5.asc +5 -5
- data/support/C74CD1D8.asc +104 -0
- data/support/mysql_enc_to_ruby.rb +9 -3
- data/support/ruby_enc_to_mysql.rb +8 -5
- metadata +19 -62
- data/examples/eventmachine.rb +0 -21
- data/examples/threaded.rb +0 -18
- data/spec/configuration.yml.example +0 -11
- data/spec/em/em_spec.rb +0 -136
- data/spec/my.cnf.example +0 -9
- data/spec/mysql2/client_spec.rb +0 -1039
- data/spec/mysql2/error_spec.rb +0 -82
- data/spec/mysql2/result_spec.rb +0 -545
- data/spec/mysql2/statement_spec.rb +0 -776
- data/spec/rcov.opts +0 -3
- data/spec/spec_helper.rb +0 -108
- 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/spec/em/em_spec.rb
DELETED
@@ -1,136 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
require 'spec_helper'
|
3
|
-
begin
|
4
|
-
require 'eventmachine'
|
5
|
-
require 'mysql2/em'
|
6
|
-
|
7
|
-
RSpec.describe Mysql2::EM::Client do
|
8
|
-
it "should support async queries" do
|
9
|
-
results = []
|
10
|
-
EM.run do
|
11
|
-
client1 = Mysql2::EM::Client.new DatabaseCredentials['root']
|
12
|
-
defer1 = client1.query "SELECT sleep(0.1) as first_query"
|
13
|
-
defer1.callback do |result|
|
14
|
-
results << result.first
|
15
|
-
client1.close
|
16
|
-
EM.stop_event_loop
|
17
|
-
end
|
18
|
-
|
19
|
-
client2 = Mysql2::EM::Client.new DatabaseCredentials['root']
|
20
|
-
defer2 = client2.query "SELECT sleep(0.025) second_query"
|
21
|
-
defer2.callback do |result|
|
22
|
-
results << result.first
|
23
|
-
client2.close
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
expect(results[0].keys).to include("second_query")
|
28
|
-
expect(results[1].keys).to include("first_query")
|
29
|
-
end
|
30
|
-
|
31
|
-
it "should support queries in callbacks" do
|
32
|
-
results = []
|
33
|
-
EM.run do
|
34
|
-
client = Mysql2::EM::Client.new DatabaseCredentials['root']
|
35
|
-
defer1 = client.query "SELECT sleep(0.025) as first_query"
|
36
|
-
defer1.callback do |result|
|
37
|
-
results << result.first
|
38
|
-
defer2 = client.query "SELECT sleep(0.025) as second_query"
|
39
|
-
defer2.callback do |r|
|
40
|
-
results << r.first
|
41
|
-
client.close
|
42
|
-
EM.stop_event_loop
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
expect(results[0].keys).to include("first_query")
|
48
|
-
expect(results[1].keys).to include("second_query")
|
49
|
-
end
|
50
|
-
|
51
|
-
it "should not swallow exceptions raised in callbacks" do
|
52
|
-
expect {
|
53
|
-
EM.run do
|
54
|
-
client = Mysql2::EM::Client.new DatabaseCredentials['root']
|
55
|
-
defer = client.query "SELECT sleep(0.1) as first_query"
|
56
|
-
defer.callback do
|
57
|
-
client.close
|
58
|
-
fail 'some error'
|
59
|
-
end
|
60
|
-
defer.errback do
|
61
|
-
# This _shouldn't_ be run, but it needed to prevent the specs from
|
62
|
-
# freezing if this test fails.
|
63
|
-
EM.stop_event_loop
|
64
|
-
end
|
65
|
-
end
|
66
|
-
}.to raise_error('some error')
|
67
|
-
end
|
68
|
-
|
69
|
-
context 'when an exception is raised by the client' do
|
70
|
-
let(:client) { Mysql2::EM::Client.new DatabaseCredentials['root'] }
|
71
|
-
let(:error) { StandardError.new('some error') }
|
72
|
-
before { allow(client).to receive(:async_result).and_raise(error) }
|
73
|
-
after { client.close }
|
74
|
-
|
75
|
-
it "should swallow exceptions raised in by the client" do
|
76
|
-
errors = []
|
77
|
-
EM.run do
|
78
|
-
defer = client.query "SELECT sleep(0.1) as first_query"
|
79
|
-
defer.callback do
|
80
|
-
# This _shouldn't_ be run, but it is needed to prevent the specs from
|
81
|
-
# freezing if this test fails.
|
82
|
-
EM.stop_event_loop
|
83
|
-
end
|
84
|
-
defer.errback do |err|
|
85
|
-
errors << err
|
86
|
-
EM.stop_event_loop
|
87
|
-
end
|
88
|
-
end
|
89
|
-
expect(errors).to eq([error])
|
90
|
-
end
|
91
|
-
|
92
|
-
it "should fail the deferrable" do
|
93
|
-
callbacks_run = []
|
94
|
-
EM.run do
|
95
|
-
defer = client.query "SELECT sleep(0.025) as first_query"
|
96
|
-
EM.add_timer(0.1) do
|
97
|
-
defer.callback do
|
98
|
-
callbacks_run << :callback
|
99
|
-
# This _shouldn't_ be run, but it is needed to prevent the specs from
|
100
|
-
# freezing if this test fails.
|
101
|
-
EM.stop_event_loop
|
102
|
-
end
|
103
|
-
defer.errback do
|
104
|
-
callbacks_run << :errback
|
105
|
-
EM.stop_event_loop
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
expect(callbacks_run).to eq([:errback])
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
it "should not raise error when closing client with no query running" do
|
114
|
-
callbacks_run = []
|
115
|
-
EM.run do
|
116
|
-
client = Mysql2::EM::Client.new DatabaseCredentials['root']
|
117
|
-
defer = client.query("select sleep(0.025)")
|
118
|
-
defer.callback do
|
119
|
-
callbacks_run << :callback
|
120
|
-
end
|
121
|
-
defer.errback do
|
122
|
-
callbacks_run << :errback
|
123
|
-
end
|
124
|
-
EM.add_timer(0.1) do
|
125
|
-
expect(callbacks_run).to eq([:callback])
|
126
|
-
expect {
|
127
|
-
client.close
|
128
|
-
}.not_to raise_error
|
129
|
-
EM.stop_event_loop
|
130
|
-
end
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|
134
|
-
rescue LoadError
|
135
|
-
puts "EventMachine not installed, skipping the specs that use it"
|
136
|
-
end
|