mysql2 0.5.2 → 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 +145 -44
- data/ext/mysql2/client.c +236 -58
- data/ext/mysql2/client.h +9 -2
- data/ext/mysql2/extconf.rb +62 -7
- data/ext/mysql2/mysql2_ext.c +6 -1
- data/ext/mysql2/mysql2_ext.h +13 -0
- data/ext/mysql2/mysql_enc_name_to_ruby.h +60 -55
- data/ext/mysql2/mysql_enc_to_ruby.h +71 -5
- data/ext/mysql2/result.c +287 -22
- data/ext/mysql2/result.h +1 -0
- data/ext/mysql2/statement.c +63 -14
- data/lib/mysql2/client.rb +24 -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 +8 -3
- 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 +7 -1
- data/support/ruby_enc_to_mysql.rb +3 -0
- metadata +15 -59
- 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 -712
- 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/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
|