mysql2 0.3.12b4 → 0.3.12b5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +32 -0
- data/README.md +15 -9
- data/ext/mysql2/client.c +146 -74
- data/ext/mysql2/extconf.rb +1 -0
- data/ext/mysql2/mysql2_ext.h +3 -3
- data/ext/mysql2/mysql_enc_name_to_ruby.h +168 -0
- data/ext/mysql2/mysql_enc_to_ruby.h +246 -0
- data/ext/mysql2/result.c +64 -59
- data/lib/mysql2.rb +2 -2
- data/lib/mysql2/client.rb +9 -210
- data/lib/mysql2/version.rb +1 -1
- data/spec/mysql2/client_spec.rb +123 -14
- data/spec/mysql2/error_spec.rb +1 -1
- data/spec/mysql2/result_spec.rb +2 -2
- data/support/mysql_enc_to_ruby.rb +82 -0
- data/support/ruby_enc_to_mysql.rb +61 -0
- metadata +19 -116
- data/.gitignore +0 -14
- data/.rbenv-version +0 -1
- data/.rspec +0 -3
- data/.rvmrc +0 -1
- data/.travis.yml +0 -7
- data/Gemfile +0 -3
- data/Gemfile.lock +0 -61
- data/Rakefile +0 -5
- data/benchmark/active_record.rb +0 -51
- data/benchmark/active_record_threaded.rb +0 -42
- data/benchmark/allocations.rb +0 -33
- data/benchmark/escape.rb +0 -36
- data/benchmark/query_with_mysql_casting.rb +0 -80
- data/benchmark/query_without_mysql_casting.rb +0 -56
- data/benchmark/sequel.rb +0 -37
- data/benchmark/setup_db.rb +0 -119
- data/benchmark/threaded.rb +0 -44
- data/mysql2.gemspec +0 -29
- data/tasks/benchmarks.rake +0 -20
- data/tasks/compile.rake +0 -71
- data/tasks/rspec.rake +0 -26
- data/tasks/vendor_mysql.rake +0 -40
data/spec/mysql2/error_spec.rb
CHANGED
@@ -35,7 +35,7 @@ describe Mysql2::Error do
|
|
35
35
|
@error.should respond_to(:error)
|
36
36
|
end
|
37
37
|
|
38
|
-
|
38
|
+
unless RUBY_VERSION =~ /1.8/
|
39
39
|
it "#message encoding should match the connection's encoding, or Encoding.default_internal if set" do
|
40
40
|
if Encoding.default_internal.nil?
|
41
41
|
@error.message.encoding.should eql(@client.encoding)
|
data/spec/mysql2/result_spec.rb
CHANGED
@@ -234,7 +234,7 @@ describe Mysql2::Result do
|
|
234
234
|
end
|
235
235
|
|
236
236
|
if 1.size == 4 # 32bit
|
237
|
-
|
237
|
+
unless RUBY_VERSION =~ /1.8/
|
238
238
|
klass = Time
|
239
239
|
else
|
240
240
|
klass = DateTime
|
@@ -252,7 +252,7 @@ describe Mysql2::Result do
|
|
252
252
|
r.first['test'].class.should eql(klass)
|
253
253
|
end
|
254
254
|
elsif 1.size == 8 # 64bit
|
255
|
-
|
255
|
+
unless RUBY_VERSION =~ /1.8/
|
256
256
|
it "should return Time when timestamp is < 1901-12-13 20:45:52" do
|
257
257
|
r = @client.query("SELECT CAST('1901-12-13 20:45:51' AS DATETIME) as test")
|
258
258
|
r.first['test'].class.should eql(Time)
|
@@ -0,0 +1,82 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
2
|
+
require 'mysql2'
|
3
|
+
|
4
|
+
user, pass, host, port = ENV.values_at('user', 'pass', 'host', 'port')
|
5
|
+
|
6
|
+
mysql_to_rb = {
|
7
|
+
"big5" => "Big5",
|
8
|
+
"dec8" => "NULL",
|
9
|
+
"cp850" => "CP850",
|
10
|
+
"hp8" => "NULL",
|
11
|
+
"koi8r" => "KOI8-R",
|
12
|
+
"latin1" => "ISO-8859-1",
|
13
|
+
"latin2" => "ISO-8859-2",
|
14
|
+
"swe7" => "NULL",
|
15
|
+
"ascii" => "US-ASCII",
|
16
|
+
"ujis" => "eucJP-ms",
|
17
|
+
"sjis" => "Shift_JIS",
|
18
|
+
"hebrew" => "ISO-8859-8",
|
19
|
+
"tis620" => "TIS-620",
|
20
|
+
"euckr" => "EUC-KR",
|
21
|
+
"koi8u" => "KOI8-R",
|
22
|
+
"gb2312" => "GB2312",
|
23
|
+
"greek" => "ISO-8859-7",
|
24
|
+
"cp1250" => "Windows-1250",
|
25
|
+
"gbk" => "GBK",
|
26
|
+
"latin5" => "ISO-8859-9",
|
27
|
+
"armscii8" => "NULL",
|
28
|
+
"utf8" => "UTF-8",
|
29
|
+
"ucs2" => "UTF-16BE",
|
30
|
+
"cp866" => "IBM866",
|
31
|
+
"keybcs2" => "NULL",
|
32
|
+
"macce" => "macCentEuro",
|
33
|
+
"macroman" => "macRoman",
|
34
|
+
"cp852" => "CP852",
|
35
|
+
"latin7" => "ISO-8859-13",
|
36
|
+
"utf8mb4" => "UTF-8",
|
37
|
+
"cp1251" => "Windows-1251",
|
38
|
+
"utf16" => "UTF-16",
|
39
|
+
"cp1256" => "Windows-1256",
|
40
|
+
"cp1257" => "Windows-1257",
|
41
|
+
"utf32" => "UTF-32",
|
42
|
+
"binary" => "ASCII-8BIT",
|
43
|
+
"geostd8" => "NULL",
|
44
|
+
"cp932" => "Windows-31J",
|
45
|
+
"eucjpms" => "eucJP-ms"
|
46
|
+
}
|
47
|
+
|
48
|
+
client = Mysql2::Client.new(:username => user, :password => pass, :host => host, :port => port.to_i)
|
49
|
+
collations = client.query "SHOW COLLATION", :as => :array
|
50
|
+
encodings = Array.new(collations.to_a.last[2].to_i)
|
51
|
+
encodings_with_nil = Array.new(encodings.size)
|
52
|
+
|
53
|
+
collations.each do |collation|
|
54
|
+
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
|
+
end
|
58
|
+
|
59
|
+
encodings.each_with_index do |encoding, idx|
|
60
|
+
encodings_with_nil[idx] = (encoding || [idx, "NULL"])
|
61
|
+
end
|
62
|
+
|
63
|
+
encodings_with_nil.sort! do |a, b|
|
64
|
+
a[0] <=> b[0]
|
65
|
+
end
|
66
|
+
|
67
|
+
encodings_with_nil = encodings_with_nil.map do |encoding|
|
68
|
+
name = "NULL"
|
69
|
+
|
70
|
+
if !encoding.nil? && encoding[1] != "NULL"
|
71
|
+
name = "\"#{encoding[1]}\""
|
72
|
+
end
|
73
|
+
|
74
|
+
" #{name}"
|
75
|
+
end
|
76
|
+
|
77
|
+
# start printing output
|
78
|
+
|
79
|
+
puts "const char *mysql2_mysql_enc_to_rb[] = {"
|
80
|
+
puts encodings_with_nil.join(",\n")
|
81
|
+
puts "};"
|
82
|
+
puts
|
@@ -0,0 +1,61 @@
|
|
1
|
+
mysql_to_rb = {
|
2
|
+
"big5" => "Big5",
|
3
|
+
"dec8" => nil,
|
4
|
+
"cp850" => "CP850",
|
5
|
+
"hp8" => nil,
|
6
|
+
"koi8r" => "KOI8-R",
|
7
|
+
"latin1" => "ISO-8859-1",
|
8
|
+
"latin2" => "ISO-8859-2",
|
9
|
+
"swe7" => nil,
|
10
|
+
"ascii" => "US-ASCII",
|
11
|
+
"ujis" => "eucJP-ms",
|
12
|
+
"sjis" => "Shift_JIS",
|
13
|
+
"hebrew" => "ISO-8859-8",
|
14
|
+
"tis620" => "TIS-620",
|
15
|
+
"euckr" => "EUC-KR",
|
16
|
+
"koi8u" => "KOI8-R",
|
17
|
+
"gb2312" => "GB2312",
|
18
|
+
"greek" => "ISO-8859-7",
|
19
|
+
"cp1250" => "Windows-1250",
|
20
|
+
"gbk" => "GBK",
|
21
|
+
"latin5" => "ISO-8859-9",
|
22
|
+
"armscii8" => nil,
|
23
|
+
"utf8" => "UTF-8",
|
24
|
+
"ucs2" => "UTF-16BE",
|
25
|
+
"cp866" => "IBM866",
|
26
|
+
"keybcs2" => nil,
|
27
|
+
"macce" => "macCentEuro",
|
28
|
+
"macroman" => "macRoman",
|
29
|
+
"cp852" => "CP852",
|
30
|
+
"latin7" => "ISO-8859-13",
|
31
|
+
"utf8mb4" => "UTF-8",
|
32
|
+
"cp1251" => "Windows-1251",
|
33
|
+
"utf16" => "UTF-16",
|
34
|
+
"cp1256" => "Windows-1256",
|
35
|
+
"cp1257" => "Windows-1257",
|
36
|
+
"utf32" => "UTF-32",
|
37
|
+
"binary" => "ASCII-8BIT",
|
38
|
+
"geostd8" => nil,
|
39
|
+
"cp932" => "Windows-31J",
|
40
|
+
"eucjpms" => "eucJP-ms"
|
41
|
+
}
|
42
|
+
|
43
|
+
puts <<-header
|
44
|
+
%readonly-tables
|
45
|
+
%enum
|
46
|
+
%define lookup-function-name mysql2_mysql_enc_name_to_rb
|
47
|
+
%define hash-function-name mysql2_mysql_enc_name_to_rb_hash
|
48
|
+
%struct-type
|
49
|
+
struct mysql2_mysql_enc_name_to_rb_map { const char *name; const char *rb_name; }
|
50
|
+
%%
|
51
|
+
header
|
52
|
+
|
53
|
+
mysql_to_rb.each do |mysql, ruby|
|
54
|
+
if ruby.nil?
|
55
|
+
name = "NULL"
|
56
|
+
else
|
57
|
+
name = "\"#{ruby}\""
|
58
|
+
end
|
59
|
+
|
60
|
+
puts "#{mysql}, #{name}"
|
61
|
+
end
|
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.3.
|
4
|
+
version: 0.3.12b5
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-12-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: eventmachine
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
requirements:
|
35
35
|
- - ~>
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: 0.
|
37
|
+
version: 0.8.1
|
38
38
|
type: :development
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -42,119 +42,39 @@ dependencies:
|
|
42
42
|
requirements:
|
43
43
|
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 0.
|
45
|
+
version: 0.8.1
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: rake
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
49
49
|
none: false
|
50
50
|
requirements:
|
51
|
-
- -
|
51
|
+
- - ~>
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: 0.
|
53
|
+
version: 0.9.3
|
54
54
|
type: :development
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
none: false
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.
|
61
|
+
version: 0.9.3
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: rspec
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
65
65
|
none: false
|
66
66
|
requirements:
|
67
|
-
- -
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: '0'
|
70
|
-
type: :development
|
71
|
-
prerelease: false
|
72
|
-
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
|
-
requirements:
|
75
|
-
- - ! '>='
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: '0'
|
78
|
-
- !ruby/object:Gem::Dependency
|
79
|
-
name: activerecord
|
80
|
-
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
|
-
requirements:
|
83
|
-
- - ! '>='
|
84
|
-
- !ruby/object:Gem::Version
|
85
|
-
version: '0'
|
86
|
-
type: :development
|
87
|
-
prerelease: false
|
88
|
-
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
|
-
requirements:
|
91
|
-
- - ! '>='
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
version: '0'
|
94
|
-
- !ruby/object:Gem::Dependency
|
95
|
-
name: mysql
|
96
|
-
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
|
-
requirements:
|
99
|
-
- - ! '>='
|
100
|
-
- !ruby/object:Gem::Version
|
101
|
-
version: '0'
|
102
|
-
type: :development
|
103
|
-
prerelease: false
|
104
|
-
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
|
-
requirements:
|
107
|
-
- - ! '>='
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: '0'
|
110
|
-
- !ruby/object:Gem::Dependency
|
111
|
-
name: do_mysql
|
112
|
-
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
|
-
requirements:
|
115
|
-
- - ! '>='
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '0'
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
|
-
requirements:
|
123
|
-
- - ! '>='
|
124
|
-
- !ruby/object:Gem::Version
|
125
|
-
version: '0'
|
126
|
-
- !ruby/object:Gem::Dependency
|
127
|
-
name: sequel
|
128
|
-
requirement: !ruby/object:Gem::Requirement
|
129
|
-
none: false
|
130
|
-
requirements:
|
131
|
-
- - ! '>='
|
132
|
-
- !ruby/object:Gem::Version
|
133
|
-
version: '0'
|
134
|
-
type: :development
|
135
|
-
prerelease: false
|
136
|
-
version_requirements: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
|
-
requirements:
|
139
|
-
- - ! '>='
|
140
|
-
- !ruby/object:Gem::Version
|
141
|
-
version: '0'
|
142
|
-
- !ruby/object:Gem::Dependency
|
143
|
-
name: faker
|
144
|
-
requirement: !ruby/object:Gem::Requirement
|
145
|
-
none: false
|
146
|
-
requirements:
|
147
|
-
- - ! '>='
|
67
|
+
- - ~>
|
148
68
|
- !ruby/object:Gem::Version
|
149
|
-
version:
|
69
|
+
version: 2.8.0
|
150
70
|
type: :development
|
151
71
|
prerelease: false
|
152
72
|
version_requirements: !ruby/object:Gem::Requirement
|
153
73
|
none: false
|
154
74
|
requirements:
|
155
|
-
- -
|
75
|
+
- - ~>
|
156
76
|
- !ruby/object:Gem::Version
|
157
|
-
version:
|
77
|
+
version: 2.8.0
|
158
78
|
description:
|
159
79
|
email: seniorlopez@gmail.com
|
160
80
|
executables: []
|
@@ -162,33 +82,16 @@ extensions:
|
|
162
82
|
- ext/mysql2/extconf.rb
|
163
83
|
extra_rdoc_files: []
|
164
84
|
files:
|
165
|
-
- .gitignore
|
166
|
-
- .rbenv-version
|
167
|
-
- .rspec
|
168
|
-
- .rvmrc
|
169
|
-
- .travis.yml
|
170
85
|
- CHANGELOG.md
|
171
|
-
- Gemfile
|
172
|
-
- Gemfile.lock
|
173
86
|
- MIT-LICENSE
|
174
87
|
- README.md
|
175
|
-
- Rakefile
|
176
|
-
- benchmark/active_record.rb
|
177
|
-
- benchmark/active_record_threaded.rb
|
178
|
-
- benchmark/allocations.rb
|
179
|
-
- benchmark/escape.rb
|
180
|
-
- benchmark/query_with_mysql_casting.rb
|
181
|
-
- benchmark/query_without_mysql_casting.rb
|
182
|
-
- benchmark/sequel.rb
|
183
|
-
- benchmark/setup_db.rb
|
184
|
-
- benchmark/threaded.rb
|
185
|
-
- examples/eventmachine.rb
|
186
|
-
- examples/threaded.rb
|
187
88
|
- ext/mysql2/client.c
|
188
89
|
- ext/mysql2/client.h
|
189
90
|
- ext/mysql2/extconf.rb
|
190
91
|
- ext/mysql2/mysql2_ext.c
|
191
92
|
- ext/mysql2/mysql2_ext.h
|
93
|
+
- ext/mysql2/mysql_enc_name_to_ruby.h
|
94
|
+
- ext/mysql2/mysql_enc_to_ruby.h
|
192
95
|
- ext/mysql2/result.c
|
193
96
|
- ext/mysql2/result.h
|
194
97
|
- ext/mysql2/wait_for_single_fd.h
|
@@ -198,7 +101,10 @@ files:
|
|
198
101
|
- lib/mysql2/error.rb
|
199
102
|
- lib/mysql2/result.rb
|
200
103
|
- lib/mysql2/version.rb
|
201
|
-
-
|
104
|
+
- support/mysql_enc_to_ruby.rb
|
105
|
+
- support/ruby_enc_to_mysql.rb
|
106
|
+
- examples/eventmachine.rb
|
107
|
+
- examples/threaded.rb
|
202
108
|
- spec/configuration.yml.example
|
203
109
|
- spec/em/em_spec.rb
|
204
110
|
- spec/mysql2/client_spec.rb
|
@@ -206,10 +112,6 @@ files:
|
|
206
112
|
- spec/mysql2/result_spec.rb
|
207
113
|
- spec/rcov.opts
|
208
114
|
- spec/spec_helper.rb
|
209
|
-
- tasks/benchmarks.rake
|
210
|
-
- tasks/compile.rake
|
211
|
-
- tasks/rspec.rake
|
212
|
-
- tasks/vendor_mysql.rake
|
213
115
|
homepage: http://github.com/brianmario/mysql2
|
214
116
|
licenses: []
|
215
117
|
post_install_message:
|
@@ -245,3 +147,4 @@ test_files:
|
|
245
147
|
- spec/mysql2/result_spec.rb
|
246
148
|
- spec/rcov.opts
|
247
149
|
- spec/spec_helper.rb
|
150
|
+
has_rdoc:
|
data/.gitignore
DELETED
data/.rbenv-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
1.9.3
|
data/.rspec
DELETED
data/.rvmrc
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
rvm use 1.9.3@mysql2 --create
|
data/.travis.yml
DELETED
data/Gemfile
DELETED
data/Gemfile.lock
DELETED
@@ -1,61 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
mysql2 (0.3.12b4)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: http://rubygems.org/
|
8
|
-
specs:
|
9
|
-
activemodel (3.2.1)
|
10
|
-
activesupport (= 3.2.1)
|
11
|
-
builder (~> 3.0.0)
|
12
|
-
activerecord (3.2.1)
|
13
|
-
activemodel (= 3.2.1)
|
14
|
-
activesupport (= 3.2.1)
|
15
|
-
arel (~> 3.0.0)
|
16
|
-
tzinfo (~> 0.3.29)
|
17
|
-
activesupport (3.2.1)
|
18
|
-
i18n (~> 0.6)
|
19
|
-
multi_json (~> 1.0)
|
20
|
-
addressable (2.2.6)
|
21
|
-
arel (3.0.0)
|
22
|
-
builder (3.0.0)
|
23
|
-
data_objects (0.10.8)
|
24
|
-
addressable (~> 2.1)
|
25
|
-
diff-lcs (1.1.3)
|
26
|
-
do_mysql (0.10.8)
|
27
|
-
data_objects (= 0.10.8)
|
28
|
-
eventmachine (0.12.10)
|
29
|
-
faker (1.0.1)
|
30
|
-
i18n (~> 0.4)
|
31
|
-
i18n (0.6.0)
|
32
|
-
multi_json (1.0.4)
|
33
|
-
mysql (2.8.1)
|
34
|
-
rake (0.8.7)
|
35
|
-
rake-compiler (0.7.9)
|
36
|
-
rake
|
37
|
-
rspec (2.8.0)
|
38
|
-
rspec-core (~> 2.8.0)
|
39
|
-
rspec-expectations (~> 2.8.0)
|
40
|
-
rspec-mocks (~> 2.8.0)
|
41
|
-
rspec-core (2.8.0)
|
42
|
-
rspec-expectations (2.8.0)
|
43
|
-
diff-lcs (~> 1.1.2)
|
44
|
-
rspec-mocks (2.8.0)
|
45
|
-
sequel (3.32.0)
|
46
|
-
tzinfo (0.3.31)
|
47
|
-
|
48
|
-
PLATFORMS
|
49
|
-
ruby
|
50
|
-
|
51
|
-
DEPENDENCIES
|
52
|
-
activerecord
|
53
|
-
do_mysql
|
54
|
-
eventmachine
|
55
|
-
faker
|
56
|
-
mysql
|
57
|
-
mysql2!
|
58
|
-
rake (= 0.8.7)
|
59
|
-
rake-compiler (~> 0.7.7)
|
60
|
-
rspec
|
61
|
-
sequel
|