mysql2 0.4.2 → 0.5.5

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 +231 -86
  3. data/ext/mysql2/client.c +527 -128
  4. data/ext/mysql2/client.h +11 -52
  5. data/ext/mysql2/extconf.rb +100 -21
  6. data/ext/mysql2/mysql2_ext.c +8 -2
  7. data/ext/mysql2/mysql2_ext.h +21 -8
  8. data/ext/mysql2/mysql_enc_name_to_ruby.h +60 -56
  9. data/ext/mysql2/mysql_enc_to_ruby.h +64 -3
  10. data/ext/mysql2/result.c +333 -109
  11. data/ext/mysql2/result.h +1 -0
  12. data/ext/mysql2/statement.c +247 -90
  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 +71 -31
  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 +432 -0
  24. data/support/C74CD1D8.asc +104 -0
  25. data/support/mysql_enc_to_ruby.rb +8 -3
  26. data/support/ruby_enc_to_mysql.rb +7 -5
  27. metadata +19 -61
  28. data/examples/eventmachine.rb +0 -21
  29. data/examples/threaded.rb +0 -18
  30. data/spec/configuration.yml.example +0 -17
  31. data/spec/em/em_spec.rb +0 -135
  32. data/spec/my.cnf.example +0 -9
  33. data/spec/mysql2/client_spec.rb +0 -939
  34. data/spec/mysql2/error_spec.rb +0 -84
  35. data/spec/mysql2/result_spec.rb +0 -510
  36. data/spec/mysql2/statement_spec.rb +0 -684
  37. data/spec/rcov.opts +0 -3
  38. data/spec/spec_helper.rb +0 -94
  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
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.4.2
4
+ version: 0.5.5
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: 2015-11-25 00:00:00.000000000 Z
12
+ date: 2023-01-22 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description:
15
15
  email:
@@ -46,82 +46,40 @@ files:
46
46
  - lib/mysql2/result.rb
47
47
  - lib/mysql2/statement.rb
48
48
  - lib/mysql2/version.rb
49
+ - support/3A79BD29.asc
50
+ - support/5072E1F5.asc
51
+ - support/C74CD1D8.asc
49
52
  - support/libmysql.def
50
53
  - support/mysql_enc_to_ruby.rb
51
54
  - support/ruby_enc_to_mysql.rb
52
- - examples/eventmachine.rb
53
- - examples/threaded.rb
54
- - spec/configuration.yml.example
55
- - spec/em/em_spec.rb
56
- - spec/my.cnf.example
57
- - spec/mysql2/client_spec.rb
58
- - spec/mysql2/error_spec.rb
59
- - spec/mysql2/result_spec.rb
60
- - spec/mysql2/statement_spec.rb
61
- - spec/rcov.opts
62
- - spec/spec_helper.rb
63
- - spec/ssl/ca-cert.pem
64
- - spec/ssl/ca-key.pem
65
- - spec/ssl/ca.cnf
66
- - spec/ssl/cert.cnf
67
- - spec/ssl/client-cert.pem
68
- - spec/ssl/client-key.pem
69
- - spec/ssl/client-req.pem
70
- - spec/ssl/gen_certs.sh
71
- - spec/ssl/pkcs8-client-key.pem
72
- - spec/ssl/pkcs8-server-key.pem
73
- - spec/ssl/server-cert.pem
74
- - spec/ssl/server-key.pem
75
- - spec/ssl/server-req.pem
76
- - spec/test_data
77
- homepage: http://github.com/brianmario/mysql2
55
+ homepage: https://github.com/brianmario/mysql2
78
56
  licenses:
79
57
  - MIT
80
- metadata: {}
58
+ metadata:
59
+ bug_tracker_uri: https://github.com/brianmario/mysql2/issues
60
+ changelog_uri: https://github.com/brianmario/mysql2/releases/tag/0.5.5
61
+ documentation_uri: https://www.rubydoc.info/gems/mysql2/0.5.5
62
+ homepage_uri: https://github.com/brianmario/mysql2
63
+ source_code_uri: https://github.com/brianmario/mysql2/tree/0.5.5
64
+ msys2_mingw_dependencies: libmariadbclient
81
65
  post_install_message:
82
66
  rdoc_options:
83
- - --charset=UTF-8
67
+ - "--charset=UTF-8"
84
68
  require_paths:
85
69
  - lib
86
70
  required_ruby_version: !ruby/object:Gem::Requirement
87
71
  requirements:
88
- - - '>='
72
+ - - ">="
89
73
  - !ruby/object:Gem::Version
90
- version: '0'
74
+ version: 2.0.0
91
75
  required_rubygems_version: !ruby/object:Gem::Requirement
92
76
  requirements:
93
- - - '>='
77
+ - - ">="
94
78
  - !ruby/object:Gem::Version
95
79
  version: '0'
96
80
  requirements: []
97
- rubyforge_project:
98
- rubygems_version: 2.0.14
81
+ rubygems_version: 3.0.3.1
99
82
  signing_key:
100
83
  specification_version: 4
101
84
  summary: A simple, fast Mysql library for Ruby, binding to libmysql
102
- test_files:
103
- - examples/eventmachine.rb
104
- - examples/threaded.rb
105
- - spec/configuration.yml.example
106
- - spec/em/em_spec.rb
107
- - spec/my.cnf.example
108
- - spec/mysql2/client_spec.rb
109
- - spec/mysql2/error_spec.rb
110
- - spec/mysql2/result_spec.rb
111
- - spec/mysql2/statement_spec.rb
112
- - spec/rcov.opts
113
- - spec/spec_helper.rb
114
- - spec/ssl/ca-cert.pem
115
- - spec/ssl/ca-key.pem
116
- - spec/ssl/ca.cnf
117
- - spec/ssl/cert.cnf
118
- - spec/ssl/client-cert.pem
119
- - spec/ssl/client-key.pem
120
- - spec/ssl/client-req.pem
121
- - spec/ssl/gen_certs.sh
122
- - spec/ssl/pkcs8-client-key.pem
123
- - spec/ssl/pkcs8-server-key.pem
124
- - spec/ssl/server-cert.pem
125
- - spec/ssl/server-key.pem
126
- - spec/ssl/server-req.pem
127
- - spec/test_data
85
+ test_files: []
@@ -1,21 +0,0 @@
1
- # encoding: utf-8
2
-
3
- $LOAD_PATH.unshift 'lib'
4
-
5
- require 'rubygems'
6
- require 'eventmachine'
7
- require 'mysql2/em'
8
-
9
- EM.run do
10
- client1 = Mysql2::EM::Client.new
11
- defer1 = client1.query "SELECT sleep(3) as first_query"
12
- defer1.callback do |result|
13
- puts "Result: #{result.to_a.inspect}"
14
- end
15
-
16
- client2 = Mysql2::EM::Client.new
17
- defer2 = client2.query "SELECT sleep(1) second_query"
18
- defer2.callback do |result|
19
- puts "Result: #{result.to_a.inspect}"
20
- end
21
- end
data/examples/threaded.rb DELETED
@@ -1,18 +0,0 @@
1
- # encoding: utf-8
2
-
3
- $LOAD_PATH.unshift 'lib'
4
- require 'mysql2'
5
- require 'timeout'
6
-
7
- # Should never exceed worst case 3.5 secs across all 20 threads
8
- Timeout.timeout(3.5) do
9
- 20.times.map do
10
- Thread.new do
11
- overhead = rand(3)
12
- puts ">> thread #{Thread.current.object_id} query, #{overhead} sec overhead"
13
- # 3 second overhead per query
14
- Mysql2::Client.new(:host => "localhost", :username => "root").query("SELECT sleep(#{overhead}) as result")
15
- puts "<< thread #{Thread.current.object_id} result, #{overhead} sec overhead"
16
- end
17
- end.each(&:join)
18
- end
@@ -1,17 +0,0 @@
1
- root:
2
- host: localhost
3
- username: root
4
- password:
5
- database: test
6
-
7
- user:
8
- host: localhost
9
- username: LOCALUSERNAME
10
- password:
11
- database: mysql2_test
12
-
13
- numericuser:
14
- host: localhost
15
- username: LOCALUSERNAME
16
- password:
17
- database: 12345
data/spec/em/em_spec.rb DELETED
@@ -1,135 +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
-
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 {
126
- client.close
127
- }.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
data/spec/my.cnf.example DELETED
@@ -1,9 +0,0 @@
1
- [root]
2
- host=localhost
3
- user=LOCALUSERNAME
4
- password=
5
-
6
- [client]
7
- host=localhost
8
- user=LOCALUSERNAME
9
- password=