mysql2 0.2.24 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/.rvmrc +1 -0
- data/CHANGELOG.md +148 -0
- data/Gemfile +3 -0
- data/README.rdoc +257 -0
- data/Rakefile +5 -0
- data/benchmark/active_record.rb +51 -0
- data/benchmark/active_record_threaded.rb +42 -0
- data/benchmark/allocations.rb +33 -0
- data/benchmark/escape.rb +36 -0
- data/benchmark/query_with_mysql_casting.rb +80 -0
- data/benchmark/query_without_mysql_casting.rb +47 -0
- data/benchmark/sequel.rb +37 -0
- data/benchmark/setup_db.rb +119 -0
- data/benchmark/threaded.rb +44 -0
- data/ext/mysql2/client.c +272 -849
- data/ext/mysql2/client.h +12 -27
- data/ext/mysql2/extconf.rb +14 -72
- data/ext/mysql2/mysql2_ext.h +4 -7
- data/ext/mysql2/result.c +123 -319
- data/ext/mysql2/result.h +1 -4
- data/lib/active_record/connection_adapters/em_mysql2_adapter.rb +64 -0
- data/lib/active_record/fiber_patches.rb +104 -0
- data/lib/mysql2.rb +5 -20
- data/lib/mysql2/client.rb +200 -50
- data/lib/mysql2/em.rb +3 -13
- data/lib/mysql2/em_fiber.rb +31 -0
- data/lib/mysql2/error.rb +6 -71
- data/lib/mysql2/version.rb +2 -2
- data/mysql2.gemspec +32 -0
- data/spec/em/em_fiber_spec.rb +22 -0
- data/spec/em/em_spec.rb +9 -74
- data/spec/mysql2/client_spec.rb +126 -593
- data/spec/mysql2/error_spec.rb +44 -58
- data/spec/mysql2/result_spec.rb +85 -257
- data/spec/spec_helper.rb +3 -24
- data/tasks/benchmarks.rake +20 -0
- data/tasks/compile.rake +71 -0
- data/tasks/rspec.rake +16 -0
- data/tasks/vendor_mysql.rake +40 -0
- metadata +179 -92
- checksums.yaml +0 -7
- data/README.md +0 -524
- data/ext/mysql2/infile.c +0 -122
- data/ext/mysql2/infile.h +0 -1
- data/ext/mysql2/mysql_enc_name_to_ruby.h +0 -168
- data/ext/mysql2/mysql_enc_to_ruby.h +0 -246
- data/ext/mysql2/wait_for_single_fd.h +0 -36
- data/lib/active_record/connection_adapters/mysql2_adapter.rb +0 -635
- data/lib/arel/engines/sql/compilers/mysql2_compiler.rb +0 -11
- data/lib/mysql2/console.rb +0 -5
- data/spec/configuration.yml.example +0 -17
- data/spec/my.cnf.example +0 -9
- data/spec/test_data +0 -1
- data/support/mysql_enc_to_ruby.rb +0 -82
- data/support/ruby_enc_to_mysql.rb +0 -61
data/lib/mysql2/console.rb
DELETED
@@ -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/my.cnf.example
DELETED
data/spec/test_data
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
\N Hello World
|
@@ -1,82 +0,0 @@
|
|
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
|
@@ -1,61 +0,0 @@
|
|
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
|