mysql2 0.3.18-x64-mingw32
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.
- data/README.md +539 -0
- data/examples/eventmachine.rb +21 -0
- data/examples/threaded.rb +20 -0
- data/ext/mysql2/client.c +1416 -0
- data/ext/mysql2/client.h +56 -0
- data/ext/mysql2/extconf.rb +177 -0
- data/ext/mysql2/infile.c +122 -0
- data/ext/mysql2/infile.h +1 -0
- data/ext/mysql2/mysql2_ext.c +12 -0
- data/ext/mysql2/mysql2_ext.h +45 -0
- 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 +684 -0
- data/ext/mysql2/result.h +23 -0
- data/ext/mysql2/wait_for_single_fd.h +36 -0
- data/lib/mysql2.rb +64 -0
- data/lib/mysql2/2.0/mysql2.so +0 -0
- data/lib/mysql2/2.1/mysql2.so +0 -0
- data/lib/mysql2/client.rb +90 -0
- data/lib/mysql2/console.rb +5 -0
- data/lib/mysql2/em.rb +56 -0
- data/lib/mysql2/error.rb +80 -0
- data/lib/mysql2/mysql2.rb +2 -0
- data/lib/mysql2/result.rb +5 -0
- data/lib/mysql2/version.rb +3 -0
- data/spec/configuration.yml.example +17 -0
- data/spec/em/em_spec.rb +135 -0
- data/spec/my.cnf.example +9 -0
- data/spec/mysql2/client_spec.rb +897 -0
- data/spec/mysql2/error_spec.rb +83 -0
- data/spec/mysql2/result_spec.rb +505 -0
- data/spec/rcov.opts +3 -0
- data/spec/spec_helper.rb +87 -0
- data/spec/test_data +1 -0
- data/support/libmysql.def +219 -0
- data/support/mysql_enc_to_ruby.rb +82 -0
- data/support/ruby_enc_to_mysql.rb +61 -0
- data/vendor/README +654 -0
- data/vendor/libmysql.dll +0 -0
- metadata +149 -0
data/spec/rcov.opts
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'rspec'
|
4
|
+
require 'mysql2'
|
5
|
+
require 'timeout'
|
6
|
+
require 'yaml'
|
7
|
+
DatabaseCredentials = YAML.load_file('spec/configuration.yml')
|
8
|
+
|
9
|
+
RSpec.configure do |config|
|
10
|
+
def with_internal_encoding(encoding)
|
11
|
+
old_enc = Encoding.default_internal
|
12
|
+
Encoding.default_internal = encoding
|
13
|
+
|
14
|
+
yield
|
15
|
+
ensure
|
16
|
+
Encoding.default_internal = old_enc
|
17
|
+
end
|
18
|
+
|
19
|
+
config.before :each do
|
20
|
+
@client = Mysql2::Client.new DatabaseCredentials['root']
|
21
|
+
end
|
22
|
+
|
23
|
+
config.after :each do
|
24
|
+
@client.close
|
25
|
+
end
|
26
|
+
|
27
|
+
config.before(:all) do
|
28
|
+
client = Mysql2::Client.new DatabaseCredentials['root']
|
29
|
+
client.query %[
|
30
|
+
CREATE TABLE IF NOT EXISTS mysql2_test (
|
31
|
+
id MEDIUMINT NOT NULL AUTO_INCREMENT,
|
32
|
+
null_test VARCHAR(10),
|
33
|
+
bit_test BIT(64),
|
34
|
+
single_bit_test BIT(1),
|
35
|
+
tiny_int_test TINYINT,
|
36
|
+
bool_cast_test TINYINT(1),
|
37
|
+
small_int_test SMALLINT,
|
38
|
+
medium_int_test MEDIUMINT,
|
39
|
+
int_test INT,
|
40
|
+
big_int_test BIGINT,
|
41
|
+
float_test FLOAT(10,3),
|
42
|
+
float_zero_test FLOAT(10,3),
|
43
|
+
double_test DOUBLE(10,3),
|
44
|
+
decimal_test DECIMAL(10,3),
|
45
|
+
decimal_zero_test DECIMAL(10,3),
|
46
|
+
date_test DATE,
|
47
|
+
date_time_test DATETIME,
|
48
|
+
timestamp_test TIMESTAMP,
|
49
|
+
time_test TIME,
|
50
|
+
year_test YEAR(4),
|
51
|
+
char_test CHAR(10),
|
52
|
+
varchar_test VARCHAR(10),
|
53
|
+
binary_test BINARY(10),
|
54
|
+
varbinary_test VARBINARY(10),
|
55
|
+
tiny_blob_test TINYBLOB,
|
56
|
+
tiny_text_test TINYTEXT,
|
57
|
+
blob_test BLOB,
|
58
|
+
text_test TEXT,
|
59
|
+
medium_blob_test MEDIUMBLOB,
|
60
|
+
medium_text_test MEDIUMTEXT,
|
61
|
+
long_blob_test LONGBLOB,
|
62
|
+
long_text_test LONGTEXT,
|
63
|
+
enum_test ENUM('val1', 'val2'),
|
64
|
+
set_test SET('val1', 'val2'),
|
65
|
+
PRIMARY KEY (id)
|
66
|
+
)
|
67
|
+
]
|
68
|
+
client.query "DELETE FROM mysql2_test;"
|
69
|
+
client.query %[
|
70
|
+
INSERT INTO mysql2_test (
|
71
|
+
null_test, bit_test, single_bit_test, tiny_int_test, bool_cast_test, small_int_test, medium_int_test, int_test, big_int_test,
|
72
|
+
float_test, float_zero_test, double_test, decimal_test, decimal_zero_test, date_test, date_time_test, timestamp_test, time_test,
|
73
|
+
year_test, char_test, varchar_test, binary_test, varbinary_test, tiny_blob_test,
|
74
|
+
tiny_text_test, blob_test, text_test, medium_blob_test, medium_text_test,
|
75
|
+
long_blob_test, long_text_test, enum_test, set_test
|
76
|
+
)
|
77
|
+
|
78
|
+
VALUES (
|
79
|
+
NULL, b'101', b'1', 1, 1, 10, 10, 10, 10,
|
80
|
+
10.3, 0, 10.3, 10.3, 0, '2010-4-4', '2010-4-4 11:44:00', '2010-4-4 11:44:00', '11:44:00',
|
81
|
+
2009, "test", "test", "test", "test", "test",
|
82
|
+
"test", "test", "test", "test", "test",
|
83
|
+
"test", "test", 'val1', 'val1,val2'
|
84
|
+
)
|
85
|
+
]
|
86
|
+
end
|
87
|
+
end
|
data/spec/test_data
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
\N Hello World
|
@@ -0,0 +1,219 @@
|
|
1
|
+
; MySQL's Connector/C ships with a libmysql.dll main library and libmysql.lib
|
2
|
+
; interface library. However, the interface library is not linkable by MinGW.
|
3
|
+
;
|
4
|
+
; At compile time, we generate a libmysql.a interface library with dlltool.exe.
|
5
|
+
;
|
6
|
+
; This def file can be re-generated using the reimp.exe or gendef.exe tools.
|
7
|
+
;
|
8
|
+
LIBRARY libmysql.dll
|
9
|
+
EXPORTS
|
10
|
+
mysql_affected_rows
|
11
|
+
mysql_affected_rows@4
|
12
|
+
mysql_change_user
|
13
|
+
mysql_change_user@16
|
14
|
+
mysql_character_set_name
|
15
|
+
mysql_character_set_name@4
|
16
|
+
mysql_close
|
17
|
+
mysql_close@4
|
18
|
+
mysql_data_seek
|
19
|
+
mysql_data_seek@12
|
20
|
+
mysql_debug
|
21
|
+
mysql_debug@4
|
22
|
+
mysql_dump_debug_info
|
23
|
+
mysql_dump_debug_info@4
|
24
|
+
mysql_eof
|
25
|
+
mysql_eof@4
|
26
|
+
mysql_errno
|
27
|
+
mysql_errno@4
|
28
|
+
mysql_error
|
29
|
+
mysql_error@4
|
30
|
+
mysql_escape_string
|
31
|
+
mysql_escape_string@12
|
32
|
+
mysql_fetch_field
|
33
|
+
mysql_fetch_field@4
|
34
|
+
mysql_fetch_field_direct
|
35
|
+
mysql_fetch_field_direct@8
|
36
|
+
mysql_fetch_fields
|
37
|
+
mysql_fetch_fields@4
|
38
|
+
mysql_fetch_lengths
|
39
|
+
mysql_fetch_lengths@4
|
40
|
+
mysql_fetch_row
|
41
|
+
mysql_fetch_row@4
|
42
|
+
mysql_field_count
|
43
|
+
mysql_field_count@4
|
44
|
+
mysql_field_seek
|
45
|
+
mysql_field_seek@8
|
46
|
+
mysql_field_tell
|
47
|
+
mysql_field_tell@4
|
48
|
+
mysql_free_result
|
49
|
+
mysql_free_result@4
|
50
|
+
mysql_get_client_info
|
51
|
+
mysql_get_client_info@0
|
52
|
+
mysql_get_client_version
|
53
|
+
mysql_get_client_version@0
|
54
|
+
mysql_get_host_info
|
55
|
+
mysql_get_host_info@4
|
56
|
+
mysql_get_option
|
57
|
+
mysql_get_option@12
|
58
|
+
mysql_get_proto_info
|
59
|
+
mysql_get_proto_info@4
|
60
|
+
mysql_get_server_info
|
61
|
+
mysql_get_server_info@4
|
62
|
+
mysql_get_server_version
|
63
|
+
mysql_get_server_version@4
|
64
|
+
mysql_get_ssl_cipher
|
65
|
+
mysql_get_ssl_cipher@4
|
66
|
+
mysql_hex_string
|
67
|
+
mysql_hex_string@12
|
68
|
+
mysql_info
|
69
|
+
mysql_info@4
|
70
|
+
mysql_init
|
71
|
+
mysql_init@4
|
72
|
+
mysql_insert_id
|
73
|
+
mysql_insert_id@4
|
74
|
+
mysql_kill
|
75
|
+
mysql_kill@8
|
76
|
+
mysql_library_end
|
77
|
+
mysql_library_end@0
|
78
|
+
mysql_library_init
|
79
|
+
mysql_library_init@12
|
80
|
+
mysql_list_dbs
|
81
|
+
mysql_list_dbs@8
|
82
|
+
mysql_list_fields
|
83
|
+
mysql_list_fields@12
|
84
|
+
mysql_list_processes
|
85
|
+
mysql_list_processes@4
|
86
|
+
mysql_list_tables
|
87
|
+
mysql_list_tables@8
|
88
|
+
mysql_more_results
|
89
|
+
mysql_more_results@4
|
90
|
+
mysql_next_result
|
91
|
+
mysql_next_result@4
|
92
|
+
mysql_num_fields
|
93
|
+
mysql_num_fields@4
|
94
|
+
mysql_num_rows
|
95
|
+
mysql_num_rows@4
|
96
|
+
mysql_options
|
97
|
+
mysql_options@12
|
98
|
+
mysql_options4
|
99
|
+
mysql_options4@16
|
100
|
+
mysql_ping
|
101
|
+
mysql_ping@4
|
102
|
+
mysql_query
|
103
|
+
mysql_query@8
|
104
|
+
mysql_read_query_result
|
105
|
+
mysql_read_query_result@4
|
106
|
+
mysql_real_connect
|
107
|
+
mysql_real_connect@32
|
108
|
+
mysql_real_escape_string
|
109
|
+
mysql_real_escape_string@16
|
110
|
+
mysql_real_query
|
111
|
+
mysql_real_query@12
|
112
|
+
mysql_refresh
|
113
|
+
mysql_refresh@8
|
114
|
+
mysql_reset_connection
|
115
|
+
mysql_reset_connection@4
|
116
|
+
mysql_rollback
|
117
|
+
mysql_rollback@4
|
118
|
+
mysql_row_seek
|
119
|
+
mysql_row_seek@8
|
120
|
+
mysql_row_tell
|
121
|
+
mysql_row_tell@4
|
122
|
+
mysql_select_db
|
123
|
+
mysql_select_db@8
|
124
|
+
mysql_send_query
|
125
|
+
mysql_send_query@12
|
126
|
+
mysql_server_end
|
127
|
+
mysql_server_end@0
|
128
|
+
mysql_server_init
|
129
|
+
mysql_server_init@12
|
130
|
+
mysql_session_track_get_first
|
131
|
+
mysql_session_track_get_first@16
|
132
|
+
mysql_session_track_get_next
|
133
|
+
mysql_session_track_get_next@16
|
134
|
+
mysql_set_character_set
|
135
|
+
mysql_set_character_set@8
|
136
|
+
mysql_set_local_infile_default
|
137
|
+
mysql_set_local_infile_default@4
|
138
|
+
mysql_set_local_infile_handler
|
139
|
+
mysql_set_local_infile_handler@24
|
140
|
+
mysql_set_server_option
|
141
|
+
mysql_set_server_option@8
|
142
|
+
mysql_shutdown
|
143
|
+
mysql_shutdown@8
|
144
|
+
mysql_sqlstate
|
145
|
+
mysql_sqlstate@4
|
146
|
+
mysql_ssl_set
|
147
|
+
mysql_ssl_set@24
|
148
|
+
mysql_stat
|
149
|
+
mysql_stat@4
|
150
|
+
mysql_stmt_affected_rows
|
151
|
+
mysql_stmt_affected_rows@4
|
152
|
+
mysql_stmt_attr_get
|
153
|
+
mysql_stmt_attr_get@12
|
154
|
+
mysql_stmt_attr_set
|
155
|
+
mysql_stmt_attr_set@12
|
156
|
+
mysql_stmt_bind_param
|
157
|
+
mysql_stmt_bind_param@8
|
158
|
+
mysql_stmt_bind_result
|
159
|
+
mysql_stmt_bind_result@8
|
160
|
+
mysql_stmt_close
|
161
|
+
mysql_stmt_close@4
|
162
|
+
mysql_stmt_data_seek
|
163
|
+
mysql_stmt_data_seek@12
|
164
|
+
mysql_stmt_errno
|
165
|
+
mysql_stmt_errno@4
|
166
|
+
mysql_stmt_error
|
167
|
+
mysql_stmt_error@4
|
168
|
+
mysql_stmt_execute
|
169
|
+
mysql_stmt_execute@4
|
170
|
+
mysql_stmt_fetch
|
171
|
+
mysql_stmt_fetch@4
|
172
|
+
mysql_stmt_fetch_column
|
173
|
+
mysql_stmt_fetch_column@16
|
174
|
+
mysql_stmt_field_count
|
175
|
+
mysql_stmt_field_count@4
|
176
|
+
mysql_stmt_free_result
|
177
|
+
mysql_stmt_free_result@4
|
178
|
+
mysql_stmt_init
|
179
|
+
mysql_stmt_init@4
|
180
|
+
mysql_stmt_insert_id
|
181
|
+
mysql_stmt_insert_id@4
|
182
|
+
mysql_stmt_next_result
|
183
|
+
mysql_stmt_next_result@4
|
184
|
+
mysql_stmt_num_rows
|
185
|
+
mysql_stmt_num_rows@4
|
186
|
+
mysql_stmt_param_count
|
187
|
+
mysql_stmt_param_count@4
|
188
|
+
mysql_stmt_param_metadata
|
189
|
+
mysql_stmt_param_metadata@4
|
190
|
+
mysql_stmt_prepare
|
191
|
+
mysql_stmt_prepare@12
|
192
|
+
mysql_stmt_reset
|
193
|
+
mysql_stmt_reset@4
|
194
|
+
mysql_stmt_result_metadata
|
195
|
+
mysql_stmt_result_metadata@4
|
196
|
+
mysql_stmt_row_seek
|
197
|
+
mysql_stmt_row_seek@8
|
198
|
+
mysql_stmt_row_tell
|
199
|
+
mysql_stmt_row_tell@4
|
200
|
+
mysql_stmt_send_long_data
|
201
|
+
mysql_stmt_send_long_data@16
|
202
|
+
mysql_stmt_sqlstate
|
203
|
+
mysql_stmt_sqlstate@4
|
204
|
+
mysql_stmt_store_result
|
205
|
+
mysql_stmt_store_result@4
|
206
|
+
mysql_store_result
|
207
|
+
mysql_store_result@4
|
208
|
+
mysql_thread_end
|
209
|
+
mysql_thread_end@0
|
210
|
+
mysql_thread_id
|
211
|
+
mysql_thread_id@4
|
212
|
+
mysql_thread_init
|
213
|
+
mysql_thread_init@0
|
214
|
+
mysql_thread_safe
|
215
|
+
mysql_thread_safe@0
|
216
|
+
mysql_use_result
|
217
|
+
mysql_use_result@4
|
218
|
+
mysql_warning_count
|
219
|
+
mysql_warning_count@4
|
@@ -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
|