mysql2 0.2.24 → 0.5.4

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 (46) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +1 -0
  3. data/LICENSE +21 -0
  4. data/README.md +237 -85
  5. data/ext/mysql2/client.c +582 -249
  6. data/ext/mysql2/client.h +10 -38
  7. data/ext/mysql2/extconf.rb +217 -66
  8. data/ext/mysql2/infile.c +2 -2
  9. data/ext/mysql2/mysql2_ext.c +9 -2
  10. data/ext/mysql2/mysql2_ext.h +13 -14
  11. data/ext/mysql2/mysql_enc_name_to_ruby.h +62 -58
  12. data/ext/mysql2/mysql_enc_to_ruby.h +82 -18
  13. data/ext/mysql2/result.c +736 -200
  14. data/ext/mysql2/result.h +13 -6
  15. data/ext/mysql2/statement.c +612 -0
  16. data/ext/mysql2/statement.h +17 -0
  17. data/ext/mysql2/wait_for_single_fd.h +2 -1
  18. data/lib/mysql2/client.rb +110 -28
  19. data/lib/mysql2/console.rb +1 -1
  20. data/lib/mysql2/em.rb +15 -9
  21. data/lib/mysql2/error.rb +57 -36
  22. data/lib/mysql2/field.rb +3 -0
  23. data/lib/mysql2/result.rb +2 -0
  24. data/lib/mysql2/statement.rb +9 -0
  25. data/lib/mysql2/version.rb +1 -1
  26. data/lib/mysql2.rb +66 -15
  27. data/support/3A79BD29.asc +49 -0
  28. data/support/5072E1F5.asc +432 -0
  29. data/support/libmysql.def +219 -0
  30. data/support/mysql_enc_to_ruby.rb +15 -11
  31. data/support/ruby_enc_to_mysql.rb +8 -6
  32. metadata +30 -94
  33. data/MIT-LICENSE +0 -20
  34. data/examples/eventmachine.rb +0 -21
  35. data/examples/threaded.rb +0 -20
  36. data/lib/active_record/connection_adapters/mysql2_adapter.rb +0 -635
  37. data/lib/arel/engines/sql/compilers/mysql2_compiler.rb +0 -11
  38. data/spec/configuration.yml.example +0 -17
  39. data/spec/em/em_spec.rb +0 -114
  40. data/spec/my.cnf.example +0 -9
  41. data/spec/mysql2/client_spec.rb +0 -897
  42. data/spec/mysql2/error_spec.rb +0 -83
  43. data/spec/mysql2/result_spec.rb +0 -505
  44. data/spec/rcov.opts +0 -3
  45. data/spec/spec_helper.rb +0 -87
  46. data/spec/test_data +0 -1
@@ -42,18 +42,23 @@ mysql_to_rb = {
42
42
  "binary" => "ASCII-8BIT",
43
43
  "geostd8" => "NULL",
44
44
  "cp932" => "Windows-31J",
45
- "eucjpms" => "eucJP-ms"
45
+ "eucjpms" => "eucJP-ms",
46
+ "utf16le" => "UTF-16LE",
47
+ "gb18030" => "GB18030",
46
48
  }
47
49
 
48
- client = Mysql2::Client.new(:username => user, :password => pass, :host => host, :port => port.to_i)
49
- collations = client.query "SHOW COLLATION", :as => :array
50
+ client = Mysql2::Client.new(username: user, password: pass, host: host, port: port.to_i)
51
+ collations = client.query "SHOW COLLATION", as: :array
50
52
  encodings = Array.new(collations.to_a.last[2].to_i)
51
53
  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[collation[1]]
56
- encodings[mysql_col_idx-1] = [mysql_col_idx, rb_enc]
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
61
+ encodings[mysql_col_idx - 1] = [mysql_col_idx, rb_enc]
57
62
  end
58
63
 
59
64
  encodings.each_with_index do |encoding, idx|
@@ -65,10 +70,10 @@ encodings_with_nil.sort! do |a, b|
65
70
  end
66
71
 
67
72
  encodings_with_nil = encodings_with_nil.map do |encoding|
68
- name = "NULL"
69
-
70
- if !encoding.nil? && encoding[1] != "NULL"
71
- name = "\"#{encoding[1]}\""
73
+ name = if encoding.nil? || encoding[1] == 'NULL'
74
+ 'NULL'
75
+ else
76
+ "\"#{encoding[1]}\""
72
77
  end
73
78
 
74
79
  " #{name}"
@@ -76,7 +81,6 @@ end
76
81
 
77
82
  # start printing output
78
83
 
79
- puts "const char *mysql2_mysql_enc_to_rb[] = {"
84
+ puts "static const char *mysql2_mysql_enc_to_rb[] = {"
80
85
  puts encodings_with_nil.join(",\n")
81
86
  puts "};"
82
- puts
@@ -37,10 +37,12 @@ mysql_to_rb = {
37
37
  "binary" => "ASCII-8BIT",
38
38
  "geostd8" => nil,
39
39
  "cp932" => "Windows-31J",
40
- "eucjpms" => "eucJP-ms"
40
+ "eucjpms" => "eucJP-ms",
41
+ "utf16le" => "UTF-16LE",
42
+ "gb18030" => "GB18030",
41
43
  }
42
44
 
43
- puts <<-header
45
+ puts <<-HEADER
44
46
  %readonly-tables
45
47
  %enum
46
48
  %define lookup-function-name mysql2_mysql_enc_name_to_rb
@@ -48,13 +50,13 @@ puts <<-header
48
50
  %struct-type
49
51
  struct mysql2_mysql_enc_name_to_rb_map { const char *name; const char *rb_name; }
50
52
  %%
51
- header
53
+ HEADER
52
54
 
53
55
  mysql_to_rb.each do |mysql, ruby|
54
- if ruby.nil?
55
- name = "NULL"
56
+ name = if ruby.nil?
57
+ "NULL"
56
58
  else
57
- name = "\"#{ruby}\""
59
+ "\"#{ruby}\""
58
60
  end
59
61
 
60
62
  puts "#{mysql}, #{name}"
metadata CHANGED
@@ -1,79 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mysql2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.24
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Lopez
8
+ - Aaron Stone
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-11-11 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: eventmachine
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - '>='
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - '>='
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: rake-compiler
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ~>
32
- - !ruby/object:Gem::Version
33
- version: 0.8.1
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ~>
39
- - !ruby/object:Gem::Version
40
- version: 0.8.1
41
- - !ruby/object:Gem::Dependency
42
- name: rake
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ~>
46
- - !ruby/object:Gem::Version
47
- version: 0.9.3
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ~>
53
- - !ruby/object:Gem::Version
54
- version: 0.9.3
55
- - !ruby/object:Gem::Dependency
56
- name: rspec
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ~>
60
- - !ruby/object:Gem::Version
61
- version: 2.8.0
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ~>
67
- - !ruby/object:Gem::Version
68
- version: 2.8.0
12
+ date: 2022-05-03 00:00:00.000000000 Z
13
+ dependencies: []
69
14
  description:
70
- email: seniorlopez@gmail.com
15
+ email:
16
+ - seniorlopez@gmail.com
17
+ - aaron@serendipity.cx
71
18
  executables: []
72
19
  extensions:
73
20
  - ext/mysql2/extconf.rb
74
21
  extra_rdoc_files: []
75
22
  files:
76
- - MIT-LICENSE
23
+ - CHANGELOG.md
24
+ - LICENSE
77
25
  - README.md
78
26
  - ext/mysql2/client.c
79
27
  - ext/mysql2/client.h
@@ -86,63 +34,51 @@ files:
86
34
  - ext/mysql2/mysql_enc_to_ruby.h
87
35
  - ext/mysql2/result.c
88
36
  - ext/mysql2/result.h
37
+ - ext/mysql2/statement.c
38
+ - ext/mysql2/statement.h
89
39
  - ext/mysql2/wait_for_single_fd.h
90
- - lib/active_record/connection_adapters/mysql2_adapter.rb
91
- - lib/arel/engines/sql/compilers/mysql2_compiler.rb
92
40
  - lib/mysql2.rb
93
41
  - lib/mysql2/client.rb
94
42
  - lib/mysql2/console.rb
95
43
  - lib/mysql2/em.rb
96
44
  - lib/mysql2/error.rb
45
+ - lib/mysql2/field.rb
97
46
  - lib/mysql2/result.rb
47
+ - lib/mysql2/statement.rb
98
48
  - lib/mysql2/version.rb
49
+ - support/3A79BD29.asc
50
+ - support/5072E1F5.asc
51
+ - support/libmysql.def
99
52
  - support/mysql_enc_to_ruby.rb
100
53
  - support/ruby_enc_to_mysql.rb
101
- - examples/eventmachine.rb
102
- - examples/threaded.rb
103
- - spec/configuration.yml.example
104
- - spec/em/em_spec.rb
105
- - spec/my.cnf.example
106
- - spec/mysql2/client_spec.rb
107
- - spec/mysql2/error_spec.rb
108
- - spec/mysql2/result_spec.rb
109
- - spec/rcov.opts
110
- - spec/spec_helper.rb
111
- - spec/test_data
112
- homepage: http://github.com/brianmario/mysql2
54
+ homepage: https://github.com/brianmario/mysql2
113
55
  licenses:
114
56
  - MIT
115
- metadata: {}
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
63
+ msys2_mingw_dependencies: libmariadbclient
116
64
  post_install_message:
117
65
  rdoc_options:
118
- - --charset=UTF-8
66
+ - "--charset=UTF-8"
119
67
  require_paths:
120
68
  - lib
121
69
  required_ruby_version: !ruby/object:Gem::Requirement
122
70
  requirements:
123
- - - '>='
71
+ - - ">="
124
72
  - !ruby/object:Gem::Version
125
- version: '0'
73
+ version: 2.0.0
126
74
  required_rubygems_version: !ruby/object:Gem::Requirement
127
75
  requirements:
128
- - - '>='
76
+ - - ">="
129
77
  - !ruby/object:Gem::Version
130
78
  version: '0'
131
79
  requirements: []
132
- rubyforge_project:
133
- rubygems_version: 2.0.14
80
+ rubygems_version: 3.0.3.1
134
81
  signing_key:
135
82
  specification_version: 4
136
83
  summary: A simple, fast Mysql library for Ruby, binding to libmysql
137
- test_files:
138
- - examples/eventmachine.rb
139
- - examples/threaded.rb
140
- - spec/configuration.yml.example
141
- - spec/em/em_spec.rb
142
- - spec/my.cnf.example
143
- - spec/mysql2/client_spec.rb
144
- - spec/mysql2/error_spec.rb
145
- - spec/mysql2/result_spec.rb
146
- - spec/rcov.opts
147
- - spec/spec_helper.rb
148
- - spec/test_data
84
+ test_files: []
data/MIT-LICENSE DELETED
@@ -1,20 +0,0 @@
1
- Copyright (c) 2010-2011 Brian Lopez - http://github.com/brianmario
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -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,20 +0,0 @@
1
- # encoding: utf-8
2
-
3
- $LOAD_PATH.unshift 'lib'
4
- require 'mysql2'
5
- require 'timeout'
6
-
7
- threads = []
8
- # Should never exceed worst case 3.5 secs across all 20 threads
9
- Timeout.timeout(3.5) do
10
- 20.times do
11
- threads << Thread.new do
12
- overhead = rand(3)
13
- puts ">> thread #{Thread.current.object_id} query, #{overhead} sec overhead"
14
- # 3 second overhead per query
15
- Mysql2::Client.new(:host => "localhost", :username => "root").query("SELECT sleep(#{overhead}) as result")
16
- puts "<< thread #{Thread.current.object_id} result, #{overhead} sec overhead"
17
- end
18
- end
19
- threads.each{|t| t.join }
20
- end