mysql2 0.2.7 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +7 -0
- data/README.md +324 -0
- data/benchmark/active_record_threaded.rb +42 -0
- data/benchmark/query_without_mysql_casting.rb +11 -2
- data/benchmark/threaded.rb +44 -0
- data/ext/mysql2/client.c +46 -26
- data/ext/mysql2/result.c +50 -24
- data/lib/active_record/connection_adapters/mysql2_adapter.rb +2 -51
- data/lib/active_record/fiber_patches.rb +29 -1
- data/lib/mysql2.rb +5 -0
- data/lib/mysql2/client.rb +2 -1
- data/lib/mysql2/version.rb +1 -1
- data/mysql2.gemspec +1 -4
- data/spec/mysql2/client_spec.rb +39 -0
- data/spec/mysql2/result_spec.rb +15 -0
- data/spec/spec_helper.rb +1 -0
- data/tasks/compile.rake +23 -5
- data/tasks/vendor_mysql.rake +6 -7
- metadata +131 -88
- data/README.rdoc +0 -248
data/ext/mysql2/result.c
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
static rb_encoding *binaryEncoding;
|
5
5
|
#endif
|
6
6
|
|
7
|
-
#define MYSQL2_MAX_YEAR
|
7
|
+
#define MYSQL2_MAX_YEAR 2038
|
8
8
|
|
9
9
|
#ifdef NEGATIVE_TIME_T
|
10
10
|
/* 1901-12-13 20:45:52 UTC : The oldest time in 32-bit signed time_t. */
|
@@ -22,7 +22,7 @@ static VALUE intern_encoding_from_charset;
|
|
22
22
|
static ID intern_new, intern_utc, intern_local, intern_encoding_from_charset_code,
|
23
23
|
intern_localtime, intern_local_offset, intern_civil, intern_new_offset;
|
24
24
|
static VALUE sym_symbolize_keys, sym_as, sym_array, sym_database_timezone, sym_application_timezone,
|
25
|
-
sym_local, sym_utc, sym_cast_booleans, sym_cache_rows;
|
25
|
+
sym_local, sym_utc, sym_cast_booleans, sym_cache_rows, sym_cast;
|
26
26
|
static ID intern_merge;
|
27
27
|
|
28
28
|
static void rb_mysql_result_mark(void * wrapper) {
|
@@ -100,7 +100,32 @@ static VALUE rb_mysql_result_fetch_field(VALUE self, unsigned int idx, short int
|
|
100
100
|
return rb_field;
|
101
101
|
}
|
102
102
|
|
103
|
-
|
103
|
+
#ifdef HAVE_RUBY_ENCODING_H
|
104
|
+
inline VALUE mysql2_set_field_string_encoding(VALUE val, MYSQL_FIELD field, rb_encoding *default_internal_enc, rb_encoding *conn_enc) {
|
105
|
+
// if binary flag is set, respect it's wishes
|
106
|
+
if (field.flags & BINARY_FLAG && field.charsetnr == 63) {
|
107
|
+
rb_enc_associate(val, binaryEncoding);
|
108
|
+
} else {
|
109
|
+
// lookup the encoding configured on this field
|
110
|
+
VALUE new_encoding = rb_funcall(cMysql2Client, intern_encoding_from_charset_code, 1, INT2NUM(field.charsetnr));
|
111
|
+
if (new_encoding != Qnil) {
|
112
|
+
// use the field encoding we were able to match
|
113
|
+
rb_encoding *enc = rb_to_encoding(new_encoding);
|
114
|
+
rb_enc_associate(val, enc);
|
115
|
+
} else {
|
116
|
+
// otherwise fall-back to the connection's encoding
|
117
|
+
rb_enc_associate(val, conn_enc);
|
118
|
+
}
|
119
|
+
if (default_internal_enc) {
|
120
|
+
val = rb_str_export_to_enc(val, default_internal_enc);
|
121
|
+
}
|
122
|
+
}
|
123
|
+
return val;
|
124
|
+
}
|
125
|
+
#endif
|
126
|
+
|
127
|
+
|
128
|
+
static VALUE rb_mysql_result_fetch_row(VALUE self, ID db_timezone, ID app_timezone, int symbolizeKeys, int asArray, int castBool, int cast) {
|
104
129
|
VALUE rowVal;
|
105
130
|
mysql2_result_wrapper * wrapper;
|
106
131
|
MYSQL_ROW row;
|
@@ -141,7 +166,19 @@ static VALUE rb_mysql_result_fetch_row(VALUE self, ID db_timezone, ID app_timezo
|
|
141
166
|
VALUE field = rb_mysql_result_fetch_field(self, i, symbolizeKeys);
|
142
167
|
if (row[i]) {
|
143
168
|
VALUE val = Qnil;
|
144
|
-
|
169
|
+
enum enum_field_types type = fields[i].type;
|
170
|
+
|
171
|
+
if(!cast) {
|
172
|
+
if (type == MYSQL_TYPE_NULL) {
|
173
|
+
val = Qnil;
|
174
|
+
} else {
|
175
|
+
val = rb_str_new(row[i], fieldLengths[i]);
|
176
|
+
#ifdef HAVE_RUBY_ENCODING_H
|
177
|
+
val = mysql2_set_field_string_encoding(val, fields[i], default_internal_enc, conn_enc);
|
178
|
+
#endif
|
179
|
+
}
|
180
|
+
} else {
|
181
|
+
switch(type) {
|
145
182
|
case MYSQL_TYPE_NULL: // NULL-type field
|
146
183
|
val = Qnil;
|
147
184
|
break;
|
@@ -260,26 +297,10 @@ static VALUE rb_mysql_result_fetch_row(VALUE self, ID db_timezone, ID app_timezo
|
|
260
297
|
default:
|
261
298
|
val = rb_str_new(row[i], fieldLengths[i]);
|
262
299
|
#ifdef HAVE_RUBY_ENCODING_H
|
263
|
-
|
264
|
-
if (fields[i].flags & BINARY_FLAG && fields[i].charsetnr == 63) {
|
265
|
-
rb_enc_associate(val, binaryEncoding);
|
266
|
-
} else {
|
267
|
-
// lookup the encoding configured on this field
|
268
|
-
VALUE new_encoding = rb_funcall(cMysql2Client, intern_encoding_from_charset_code, 1, INT2NUM(fields[i].charsetnr));
|
269
|
-
if (new_encoding != Qnil) {
|
270
|
-
// use the field encoding we were able to match
|
271
|
-
rb_encoding *enc = rb_to_encoding(new_encoding);
|
272
|
-
rb_enc_associate(val, enc);
|
273
|
-
} else {
|
274
|
-
// otherwise fall-back to the connection's encoding
|
275
|
-
rb_enc_associate(val, conn_enc);
|
276
|
-
}
|
277
|
-
if (default_internal_enc) {
|
278
|
-
val = rb_str_export_to_enc(val, default_internal_enc);
|
279
|
-
}
|
280
|
-
}
|
300
|
+
val = mysql2_set_field_string_encoding(val, fields[i], default_internal_enc, conn_enc);
|
281
301
|
#endif
|
282
302
|
break;
|
303
|
+
}
|
283
304
|
}
|
284
305
|
if (asArray) {
|
285
306
|
rb_ary_push(rowVal, val);
|
@@ -329,7 +350,7 @@ static VALUE rb_mysql_result_each(int argc, VALUE * argv, VALUE self) {
|
|
329
350
|
ID db_timezone, app_timezone, dbTz, appTz;
|
330
351
|
mysql2_result_wrapper * wrapper;
|
331
352
|
unsigned long i;
|
332
|
-
int symbolizeKeys = 0, asArray = 0, castBool = 0, cacheRows = 1;
|
353
|
+
int symbolizeKeys = 0, asArray = 0, castBool = 0, cacheRows = 1, cast = 1;
|
333
354
|
|
334
355
|
GetMysql2Result(self, wrapper);
|
335
356
|
|
@@ -356,6 +377,10 @@ static VALUE rb_mysql_result_each(int argc, VALUE * argv, VALUE self) {
|
|
356
377
|
cacheRows = 0;
|
357
378
|
}
|
358
379
|
|
380
|
+
if (rb_hash_aref(opts, sym_cast) == Qfalse) {
|
381
|
+
cast = 0;
|
382
|
+
}
|
383
|
+
|
359
384
|
dbTz = rb_hash_aref(opts, sym_database_timezone);
|
360
385
|
if (dbTz == sym_local) {
|
361
386
|
db_timezone = intern_local;
|
@@ -400,7 +425,7 @@ static VALUE rb_mysql_result_each(int argc, VALUE * argv, VALUE self) {
|
|
400
425
|
if (cacheRows && i < rowsProcessed) {
|
401
426
|
row = rb_ary_entry(wrapper->rows, i);
|
402
427
|
} else {
|
403
|
-
row = rb_mysql_result_fetch_row(self, db_timezone, app_timezone, symbolizeKeys, asArray, castBool);
|
428
|
+
row = rb_mysql_result_fetch_row(self, db_timezone, app_timezone, symbolizeKeys, asArray, castBool, cast);
|
404
429
|
if (cacheRows) {
|
405
430
|
rb_ary_store(wrapper->rows, i, row);
|
406
431
|
}
|
@@ -473,6 +498,7 @@ void init_mysql2_result() {
|
|
473
498
|
sym_database_timezone = ID2SYM(rb_intern("database_timezone"));
|
474
499
|
sym_application_timezone = ID2SYM(rb_intern("application_timezone"));
|
475
500
|
sym_cache_rows = ID2SYM(rb_intern("cache_rows"));
|
501
|
+
sym_cast = ID2SYM(rb_intern("cast"));
|
476
502
|
|
477
503
|
opt_decimal_zero = rb_str_new2("0.0");
|
478
504
|
rb_global_variable(&opt_decimal_zero); //never GC
|
@@ -38,59 +38,10 @@ module ActiveRecord
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def has_default?
|
41
|
-
return false if sql_type =~ /blob/i || type == :text #mysql forbids defaults on blob and text columns
|
41
|
+
return false if sql_type =~ /blob/i || type == :text # mysql forbids defaults on blob and text columns
|
42
42
|
super
|
43
43
|
end
|
44
44
|
|
45
|
-
# Returns the Ruby class that corresponds to the abstract data type.
|
46
|
-
def klass
|
47
|
-
case type
|
48
|
-
when :integer then Fixnum
|
49
|
-
when :float then Float
|
50
|
-
when :decimal then BigDecimal
|
51
|
-
when :datetime then Time
|
52
|
-
when :date then Date
|
53
|
-
when :timestamp then Time
|
54
|
-
when :time then Time
|
55
|
-
when :text, :string then String
|
56
|
-
when :binary then String
|
57
|
-
when :boolean then Object
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
def type_cast(value)
|
62
|
-
return nil if value.nil?
|
63
|
-
case type
|
64
|
-
when :string then value
|
65
|
-
when :text then value
|
66
|
-
when :integer then value.to_i rescue value ? 1 : 0
|
67
|
-
when :float then value.to_f # returns self if it's already a Float
|
68
|
-
when :decimal then self.class.value_to_decimal(value)
|
69
|
-
when :datetime, :timestamp then value.class == Time ? value : self.class.string_to_time(value)
|
70
|
-
when :time then value.class == Time ? value : self.class.string_to_dummy_time(value)
|
71
|
-
when :date then value.class == Date ? value : self.class.string_to_date(value)
|
72
|
-
when :binary then value
|
73
|
-
when :boolean then self.class.value_to_boolean(value)
|
74
|
-
else value
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def type_cast_code(var_name)
|
79
|
-
case type
|
80
|
-
when :string then nil
|
81
|
-
when :text then nil
|
82
|
-
when :integer then "#{var_name}.to_i rescue #{var_name} ? 1 : 0"
|
83
|
-
when :float then "#{var_name}.to_f"
|
84
|
-
when :decimal then "#{self.class.name}.value_to_decimal(#{var_name})"
|
85
|
-
when :datetime, :timestamp then "#{var_name}.class == Time ? #{var_name} : #{self.class.name}.string_to_time(#{var_name})"
|
86
|
-
when :time then "#{var_name}.class == Time ? #{var_name} : #{self.class.name}.string_to_dummy_time(#{var_name})"
|
87
|
-
when :date then "#{var_name}.class == Date ? #{var_name} : #{self.class.name}.string_to_date(#{var_name})"
|
88
|
-
when :binary then nil
|
89
|
-
when :boolean then "#{self.class.name}.value_to_boolean(#{var_name})"
|
90
|
-
else nil
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
45
|
private
|
95
46
|
def simplified_type(field_type)
|
96
47
|
return :boolean if Mysql2Adapter.emulate_booleans && field_type.downcase.index(BOOL)
|
@@ -611,7 +562,7 @@ module ActiveRecord
|
|
611
562
|
end
|
612
563
|
|
613
564
|
def configure_connection
|
614
|
-
@connection.query_options.merge!(:as => :array)
|
565
|
+
@connection.query_options.merge!(:as => :array, :cast => false)
|
615
566
|
|
616
567
|
# By default, MySQL 'where id is null' selects the last inserted id.
|
617
568
|
# Turn this off. http://dev.rubyonrails.org/ticket/6778
|
@@ -67,6 +67,34 @@ module ActiveRecord
|
|
67
67
|
|
68
68
|
@connections = []
|
69
69
|
@checked_out = []
|
70
|
+
@automatic_reconnect = true
|
71
|
+
@tables = {}
|
72
|
+
|
73
|
+
@columns = Hash.new do |h, table_name|
|
74
|
+
h[table_name] = with_connection do |conn|
|
75
|
+
|
76
|
+
# Fetch a list of columns
|
77
|
+
conn.columns(table_name, "#{table_name} Columns").tap do |columns|
|
78
|
+
|
79
|
+
# set primary key information
|
80
|
+
columns.each do |column|
|
81
|
+
column.primary = column.name == primary_keys[table_name]
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
@columns_hash = Hash.new do |h, table_name|
|
88
|
+
h[table_name] = Hash[columns[table_name].map { |col|
|
89
|
+
[col.name, col]
|
90
|
+
}]
|
91
|
+
end
|
92
|
+
|
93
|
+
@primary_keys = Hash.new do |h, table_name|
|
94
|
+
h[table_name] = with_connection do |conn|
|
95
|
+
table_exists?(table_name) ? conn.primary_key(table_name) : 'id'
|
96
|
+
end
|
97
|
+
end
|
70
98
|
end
|
71
99
|
|
72
100
|
def clear_stale_cached_connections!
|
@@ -101,4 +129,4 @@ module ActiveRecord
|
|
101
129
|
end
|
102
130
|
|
103
131
|
end
|
104
|
-
end
|
132
|
+
end
|
data/lib/mysql2.rb
CHANGED
@@ -14,3 +14,8 @@ require 'mysql2/result'
|
|
14
14
|
# A modern, simple and very fast Mysql library for Ruby - binding to libmysql
|
15
15
|
module Mysql2
|
16
16
|
end
|
17
|
+
|
18
|
+
if defined?(ActiveRecord::VERSION::STRING) && ActiveRecord::VERSION::STRING >= "3.1"
|
19
|
+
puts "WARNING: This version of mysql2 (#{Mysql2::VERSION}) isn't compatible with Rails 3.1 as the ActiveRecord adapter was pulled into Rails itself."
|
20
|
+
puts "WARNING: Please use the 0.3.x (or greater) releases if you plan on using it in Rails >= 3.1.x"
|
21
|
+
end
|
data/lib/mysql2/client.rb
CHANGED
@@ -9,7 +9,8 @@ module Mysql2
|
|
9
9
|
:database_timezone => :local, # timezone Mysql2 will assume datetime objects are stored in
|
10
10
|
:application_timezone => nil, # timezone Mysql2 will convert to before handing the object back to the caller
|
11
11
|
:cache_rows => true, # tells Mysql2 to use it's internal row cache for results
|
12
|
-
:connect_flags => REMEMBER_OPTIONS | LONG_PASSWORD | LONG_FLAG | TRANSACTIONS | PROTOCOL_41 | SECURE_CONNECTION
|
12
|
+
:connect_flags => REMEMBER_OPTIONS | LONG_PASSWORD | LONG_FLAG | TRANSACTIONS | PROTOCOL_41 | SECURE_CONNECTION,
|
13
|
+
:cast => true
|
13
14
|
}
|
14
15
|
|
15
16
|
def initialize(opts = {})
|
data/lib/mysql2/version.rb
CHANGED
data/mysql2.gemspec
CHANGED
@@ -7,9 +7,6 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.date = Time.now.utc.strftime("%Y-%m-%d")
|
8
8
|
s.email = %q{seniorlopez@gmail.com}
|
9
9
|
s.extensions = ["ext/mysql2/extconf.rb"]
|
10
|
-
s.extra_rdoc_files = [
|
11
|
-
"README.rdoc"
|
12
|
-
]
|
13
10
|
s.files = `git ls-files`.split("\n")
|
14
11
|
s.homepage = %q{http://github.com/brianmario/mysql2}
|
15
12
|
s.rdoc_options = ["--charset=UTF-8"]
|
@@ -20,7 +17,7 @@ Gem::Specification.new do |s|
|
|
20
17
|
|
21
18
|
# tests
|
22
19
|
s.add_development_dependency 'eventmachine'
|
23
|
-
s.add_development_dependency 'rake-compiler', "~> 0.7.
|
20
|
+
s.add_development_dependency 'rake-compiler', "~> 0.7.7"
|
24
21
|
s.add_development_dependency 'rspec'
|
25
22
|
# benchmarks
|
26
23
|
s.add_development_dependency 'activerecord'
|
data/spec/mysql2/client_spec.rb
CHANGED
@@ -167,6 +167,45 @@ describe Mysql2::Client do
|
|
167
167
|
end
|
168
168
|
end
|
169
169
|
|
170
|
+
it "should respond to escape" do
|
171
|
+
Mysql2::Client.should respond_to(:escape)
|
172
|
+
end
|
173
|
+
|
174
|
+
context "escape" do
|
175
|
+
it "should return a new SQL-escape version of the passed string" do
|
176
|
+
Mysql2::Client.escape("abc'def\"ghi\0jkl%mno").should eql("abc\\'def\\\"ghi\\0jkl%mno")
|
177
|
+
end
|
178
|
+
|
179
|
+
it "should return the passed string if nothing was escaped" do
|
180
|
+
str = "plain"
|
181
|
+
Mysql2::Client.escape(str).object_id.should eql(str.object_id)
|
182
|
+
end
|
183
|
+
|
184
|
+
it "should not overflow the thread stack" do
|
185
|
+
lambda {
|
186
|
+
Thread.new { Mysql2::Client.escape("'" * 256 * 1024) }.join
|
187
|
+
}.should_not raise_error(SystemStackError)
|
188
|
+
end
|
189
|
+
|
190
|
+
it "should not overflow the process stack" do
|
191
|
+
lambda {
|
192
|
+
Thread.new { Mysql2::Client.escape("'" * 1024 * 1024 * 4) }.join
|
193
|
+
}.should_not raise_error(SystemStackError)
|
194
|
+
end
|
195
|
+
|
196
|
+
if RUBY_VERSION =~ /1.9/
|
197
|
+
it "should carry over the original string's encoding" do
|
198
|
+
str = "abc'def\"ghi\0jkl%mno"
|
199
|
+
escaped = Mysql2::Client.escape(str)
|
200
|
+
escaped.encoding.should eql(str.encoding)
|
201
|
+
|
202
|
+
str.encode!('us-ascii')
|
203
|
+
escaped = Mysql2::Client.escape(str)
|
204
|
+
escaped.encoding.should eql(str.encoding)
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
170
209
|
it "should respond to #escape" do
|
171
210
|
@client.should respond_to(:escape)
|
172
211
|
end
|
data/spec/mysql2/result_spec.rb
CHANGED
@@ -79,6 +79,16 @@ describe Mysql2::Result do
|
|
79
79
|
@test_result = @client.query("SELECT * FROM mysql2_test ORDER BY id DESC LIMIT 1").first
|
80
80
|
end
|
81
81
|
|
82
|
+
it "should return nil values for NULL and strings for everything else when :cast is false" do
|
83
|
+
result = @client.query('SELECT null_test, tiny_int_test, bool_cast_test, int_test, date_test, enum_test FROM mysql2_test WHERE bool_cast_test = 1 LIMIT 1', :cast => false).first
|
84
|
+
result["null_test"].should be_nil
|
85
|
+
result["tiny_int_test"].should == "1"
|
86
|
+
result["bool_cast_test"].should == "1"
|
87
|
+
result["int_test"].should == "10"
|
88
|
+
result["date_test"].should == "2010-04-04"
|
89
|
+
result["enum_test"].should == "val1"
|
90
|
+
end
|
91
|
+
|
82
92
|
it "should return nil for a NULL value" do
|
83
93
|
@test_result['null_test'].class.should eql(NilClass)
|
84
94
|
@test_result['null_test'].should eql(nil)
|
@@ -173,6 +183,11 @@ describe Mysql2::Result do
|
|
173
183
|
r.first['test'].class.should eql(DateTime)
|
174
184
|
end
|
175
185
|
|
186
|
+
it "should return DateTime when time > year 2038" do
|
187
|
+
r = @client.query("SELECT CAST('2039-01-01 01:01:01' AS DATETIME) as test")
|
188
|
+
r.first['test'].class.should eql(DateTime)
|
189
|
+
end
|
190
|
+
|
176
191
|
it "should return Time for a TIMESTAMP value when within the supported range" do
|
177
192
|
@test_result['timestamp_test'].class.should eql(Time)
|
178
193
|
@test_result['timestamp_test'].strftime("%F %T").should eql('2010-04-04 11:44:00')
|
data/spec/spec_helper.rb
CHANGED
data/tasks/compile.rake
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require "rake/extensiontask"
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
CONNECTOR_VERSION = "6.0.2" #"mysql-connector-c-noinstall-6.0.2-win32.zip"
|
4
|
+
CONNECTOR_MIRROR = ENV['CONNECTOR_MIRROR'] || ENV['MYSQL_MIRROR'] || "http://mysql.he.net/"
|
5
5
|
|
6
6
|
def gemspec
|
7
7
|
@clean_gemspec ||= eval(File.read(File.expand_path('../../mysql2.gemspec', __FILE__)))
|
@@ -9,12 +9,12 @@ end
|
|
9
9
|
|
10
10
|
Rake::ExtensionTask.new("mysql2", gemspec) do |ext|
|
11
11
|
# reference where the vendored MySQL got extracted
|
12
|
-
|
12
|
+
connector_lib = File.expand_path(File.join(File.dirname(__FILE__), '..', 'vendor', "mysql-connector-c-noinstall-#{CONNECTOR_VERSION}-win32"))
|
13
13
|
|
14
14
|
# DRY options feed into compile or cross-compile process
|
15
15
|
windows_options = [
|
16
|
-
"--with-mysql-include=#{
|
17
|
-
"--with-mysql-lib=#{
|
16
|
+
"--with-mysql-include=#{connector_lib}/include",
|
17
|
+
"--with-mysql-lib=#{connector_lib}/lib"
|
18
18
|
]
|
19
19
|
|
20
20
|
# automatically add build options to avoid need of manual input
|
@@ -28,6 +28,24 @@ Rake::ExtensionTask.new("mysql2", gemspec) do |ext|
|
|
28
28
|
# inject 1.8/1.9 pure-ruby entry point when cross compiling only
|
29
29
|
ext.cross_compiling do |spec|
|
30
30
|
spec.files << 'lib/mysql2/mysql2.rb'
|
31
|
+
spec.post_install_message = <<-POST_INSTALL_MESSAGE
|
32
|
+
|
33
|
+
======================================================================================================
|
34
|
+
|
35
|
+
You've installed the binary version of #{spec.name}.
|
36
|
+
It was built using MySQL Connector/C version #{CONNECTOR_VERSION}.
|
37
|
+
It's recommended to use the exact same version to avoid potential issues.
|
38
|
+
|
39
|
+
At the time of building this gem, the necessary DLL files where available
|
40
|
+
in the following download:
|
41
|
+
|
42
|
+
http://dev.mysql.com/get/Downloads/Connector-C/mysql-connector-c-noinstall-#{CONNECTOR_VERSION}-win32.zip/from/pick
|
43
|
+
|
44
|
+
And put lib\\libmysql.dll file in your Ruby bin directory, for example C:\\Ruby\\bin
|
45
|
+
|
46
|
+
======================================================================================================
|
47
|
+
|
48
|
+
POST_INSTALL_MESSAGE
|
31
49
|
end
|
32
50
|
end
|
33
51
|
|
data/tasks/vendor_mysql.rake
CHANGED
@@ -4,9 +4,8 @@ require 'rake/extensioncompiler'
|
|
4
4
|
# download mysql library and headers
|
5
5
|
directory "vendor"
|
6
6
|
|
7
|
-
file "vendor/mysql-noinstall-#{
|
8
|
-
|
9
|
-
url = "http://dev.mysql.com/get/Downloads/MySQL-#{base_version}/#{File.basename(t.name)}/from/#{MYSQL_MIRROR}/"
|
7
|
+
file "vendor/mysql-connector-c-noinstall-#{CONNECTOR_VERSION}-win32.zip" => ["vendor"] do |t|
|
8
|
+
url = "http://dev.mysql.com/get/Downloads/Connector-C/mysql-connector-c-noinstall-#{CONNECTOR_VERSION}-win32.zip/from/#{CONNECTOR_MIRROR}/"
|
10
9
|
when_writing "downloading #{t.name}" do
|
11
10
|
cd File.dirname(t.name) do
|
12
11
|
sh "wget -c #{url} || curl -C - -O #{url}"
|
@@ -14,11 +13,11 @@ file "vendor/mysql-noinstall-#{MYSQL_VERSION}-win32.zip" => ['vendor'] do |t|
|
|
14
13
|
end
|
15
14
|
end
|
16
15
|
|
17
|
-
file "vendor/mysql-#{
|
16
|
+
file "vendor/mysql-connector-c-noinstall-#{CONNECTOR_VERSION}-win32/include/mysql.h" => ["vendor/mysql-connector-c-noinstall-#{CONNECTOR_VERSION}-win32.zip"] do |t|
|
18
17
|
full_file = File.expand_path(t.prerequisites.last)
|
19
18
|
when_writing "creating #{t.name}" do
|
20
19
|
cd "vendor" do
|
21
|
-
sh "unzip #{full_file} mysql-#{
|
20
|
+
sh "unzip #{full_file} mysql-connector-c-noinstall-#{CONNECTOR_VERSION}-win32/bin/** mysql-connector-c-noinstall-#{CONNECTOR_VERSION}-win32/include/** mysql-connector-c-noinstall-#{CONNECTOR_VERSION}-win32/lib/**"
|
22
21
|
end
|
23
22
|
# update file timestamp to avoid Rake perform this extraction again.
|
24
23
|
touch t.name
|
@@ -26,10 +25,10 @@ file "vendor/mysql-#{MYSQL_VERSION}-win32/include/mysql.h" => ["vendor/mysql-noi
|
|
26
25
|
end
|
27
26
|
|
28
27
|
# clobber expanded packages
|
29
|
-
CLOBBER.include("vendor/mysql-#{
|
28
|
+
CLOBBER.include("vendor/mysql-connector-c-noinstall-#{CONNECTOR_VERSION}-win32")
|
30
29
|
|
31
30
|
# vendor:mysql
|
32
|
-
task 'vendor:mysql' => ["vendor/mysql-#{
|
31
|
+
task 'vendor:mysql' => ["vendor/mysql-connector-c-noinstall-#{CONNECTOR_VERSION}-win32/include/mysql.h"]
|
33
32
|
|
34
33
|
# hook into cross compilation vendored mysql dependency
|
35
34
|
if RUBY_PLATFORM =~ /mingw|mswin/ then
|