solaris-mysql2 0.3.11
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +12 -0
- data/.rspec +3 -0
- data/.rvmrc +1 -0
- data/.travis.yml +7 -0
- data/CHANGELOG.md +244 -0
- data/Gemfile +3 -0
- data/MIT-LICENSE +20 -0
- data/README.md +334 -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 +56 -0
- data/benchmark/sequel.rb +37 -0
- data/benchmark/setup_db.rb +119 -0
- data/benchmark/threaded.rb +44 -0
- data/examples/eventmachine.rb +21 -0
- data/examples/threaded.rb +20 -0
- data/ext/mysql2/client.c +901 -0
- data/ext/mysql2/client.h +42 -0
- data/ext/mysql2/extconf.rb +74 -0
- data/ext/mysql2/mysql2_ext.c +12 -0
- data/ext/mysql2/mysql2_ext.h +42 -0
- data/ext/mysql2/result.c +566 -0
- data/ext/mysql2/result.h +20 -0
- data/ext/mysql2/wait_for_single_fd.h +36 -0
- data/lib/mysql2.rb +21 -0
- data/lib/mysql2/client.rb +264 -0
- data/lib/mysql2/em.rb +37 -0
- data/lib/mysql2/error.rb +15 -0
- data/lib/mysql2/result.rb +5 -0
- data/lib/mysql2/version.rb +3 -0
- data/solaris-mysql2.gemspec +29 -0
- data/spec/em/em_spec.rb +50 -0
- data/spec/mysql2/client_spec.rb +465 -0
- data/spec/mysql2/error_spec.rb +69 -0
- data/spec/mysql2/result_spec.rb +388 -0
- data/spec/rcov.opts +3 -0
- data/spec/spec_helper.rb +67 -0
- 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 +198 -0
data/spec/rcov.opts
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'rspec'
|
4
|
+
require 'mysql2'
|
5
|
+
require 'timeout'
|
6
|
+
|
7
|
+
RSpec.configure do |config|
|
8
|
+
config.before(:all) do
|
9
|
+
client = Mysql2::Client.new :host => "localhost", :username => "root", :database => 'test'
|
10
|
+
client.query %[
|
11
|
+
CREATE TABLE IF NOT EXISTS mysql2_test (
|
12
|
+
id MEDIUMINT NOT NULL AUTO_INCREMENT,
|
13
|
+
null_test VARCHAR(10),
|
14
|
+
bit_test BIT(64),
|
15
|
+
tiny_int_test TINYINT,
|
16
|
+
bool_cast_test TINYINT(1),
|
17
|
+
small_int_test SMALLINT,
|
18
|
+
medium_int_test MEDIUMINT,
|
19
|
+
int_test INT,
|
20
|
+
big_int_test BIGINT,
|
21
|
+
float_test FLOAT(10,3),
|
22
|
+
float_zero_test FLOAT(10,3),
|
23
|
+
double_test DOUBLE(10,3),
|
24
|
+
decimal_test DECIMAL(10,3),
|
25
|
+
decimal_zero_test DECIMAL(10,3),
|
26
|
+
date_test DATE,
|
27
|
+
date_time_test DATETIME,
|
28
|
+
timestamp_test TIMESTAMP,
|
29
|
+
time_test TIME,
|
30
|
+
year_test YEAR(4),
|
31
|
+
char_test CHAR(10),
|
32
|
+
varchar_test VARCHAR(10),
|
33
|
+
binary_test BINARY(10),
|
34
|
+
varbinary_test VARBINARY(10),
|
35
|
+
tiny_blob_test TINYBLOB,
|
36
|
+
tiny_text_test TINYTEXT,
|
37
|
+
blob_test BLOB,
|
38
|
+
text_test TEXT,
|
39
|
+
medium_blob_test MEDIUMBLOB,
|
40
|
+
medium_text_test MEDIUMTEXT,
|
41
|
+
long_blob_test LONGBLOB,
|
42
|
+
long_text_test LONGTEXT,
|
43
|
+
enum_test ENUM('val1', 'val2'),
|
44
|
+
set_test SET('val1', 'val2'),
|
45
|
+
PRIMARY KEY (id)
|
46
|
+
)
|
47
|
+
]
|
48
|
+
client.query "DELETE FROM mysql2_test;"
|
49
|
+
client.query %[
|
50
|
+
INSERT INTO mysql2_test (
|
51
|
+
null_test, bit_test, tiny_int_test, bool_cast_test, small_int_test, medium_int_test, int_test, big_int_test,
|
52
|
+
float_test, float_zero_test, double_test, decimal_test, decimal_zero_test, date_test, date_time_test, timestamp_test, time_test,
|
53
|
+
year_test, char_test, varchar_test, binary_test, varbinary_test, tiny_blob_test,
|
54
|
+
tiny_text_test, blob_test, text_test, medium_blob_test, medium_text_test,
|
55
|
+
long_blob_test, long_text_test, enum_test, set_test
|
56
|
+
)
|
57
|
+
|
58
|
+
VALUES (
|
59
|
+
NULL, b'101', 1, 1, 10, 10, 10, 10,
|
60
|
+
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',
|
61
|
+
2009, "test", "test", "test", "test", "test",
|
62
|
+
"test", "test", "test", "test", "test",
|
63
|
+
"test", "test", 'val1', 'val1,val2'
|
64
|
+
)
|
65
|
+
]
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
BENCHMARKS = Dir["#{File.dirname(__FILE__)}/../benchmark/*.rb"].map do |path|
|
2
|
+
File.basename(path, '.rb')
|
3
|
+
end.select { |x| x != 'setup_db' }
|
4
|
+
|
5
|
+
namespace :bench do
|
6
|
+
BENCHMARKS.each do |feature|
|
7
|
+
desc "Run #{feature} benchmarks"
|
8
|
+
task(feature){ ruby "benchmark/#{feature}.rb" }
|
9
|
+
end
|
10
|
+
|
11
|
+
task :all do
|
12
|
+
BENCHMARKS.each do |feature|
|
13
|
+
ruby "benchmark/#{feature}.rb"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
task :setup do
|
18
|
+
ruby 'benchmark/setup_db'
|
19
|
+
end
|
20
|
+
end
|
data/tasks/compile.rake
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
require "rake/extensiontask"
|
2
|
+
|
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
|
+
|
6
|
+
def gemspec
|
7
|
+
@clean_gemspec ||= eval(File.read(File.expand_path('../../mysql2.gemspec', __FILE__)))
|
8
|
+
end
|
9
|
+
|
10
|
+
Rake::ExtensionTask.new("mysql2", gemspec) do |ext|
|
11
|
+
# reference where the vendored MySQL got extracted
|
12
|
+
connector_lib = File.expand_path(File.join(File.dirname(__FILE__), '..', 'vendor', "mysql-connector-c-noinstall-#{CONNECTOR_VERSION}-win32"))
|
13
|
+
|
14
|
+
# DRY options feed into compile or cross-compile process
|
15
|
+
windows_options = [
|
16
|
+
"--with-mysql-include=#{connector_lib}/include",
|
17
|
+
"--with-mysql-lib=#{connector_lib}/lib"
|
18
|
+
]
|
19
|
+
|
20
|
+
# automatically add build options to avoid need of manual input
|
21
|
+
if RUBY_PLATFORM =~ /mswin|mingw/ then
|
22
|
+
ext.config_options = windows_options
|
23
|
+
else
|
24
|
+
ext.cross_compile = true
|
25
|
+
ext.cross_platform = ['x86-mingw32', 'x86-mswin32-60']
|
26
|
+
ext.cross_config_options = windows_options
|
27
|
+
|
28
|
+
# inject 1.8/1.9 pure-ruby entry point when cross compiling only
|
29
|
+
ext.cross_compiling do |spec|
|
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
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
ext.lib_dir = File.join 'lib', 'mysql2'
|
53
|
+
|
54
|
+
# clean compiled extension
|
55
|
+
CLEAN.include "#{ext.lib_dir}/*.#{RbConfig::CONFIG['DLEXT']}"
|
56
|
+
end
|
57
|
+
Rake::Task[:spec].prerequisites << :compile
|
58
|
+
|
59
|
+
file 'lib/mysql2/mysql2.rb' do |t|
|
60
|
+
name = gemspec.name
|
61
|
+
File.open(t.name, 'wb') do |f|
|
62
|
+
f.write <<-eoruby
|
63
|
+
RUBY_VERSION =~ /(\\d+.\\d+)/
|
64
|
+
require "#{name}/\#{$1}/#{name}"
|
65
|
+
eoruby
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
if Rake::Task.task_defined?(:cross)
|
70
|
+
Rake::Task[:cross].prerequisites << "lib/mysql2/mysql2.rb"
|
71
|
+
end
|
data/tasks/rspec.rake
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
begin
|
2
|
+
require 'rspec'
|
3
|
+
require 'rspec/core/rake_task'
|
4
|
+
|
5
|
+
desc "Run all examples with RCov"
|
6
|
+
RSpec::Core::RakeTask.new('spec:rcov') do |t|
|
7
|
+
t.rcov = true
|
8
|
+
end
|
9
|
+
RSpec::Core::RakeTask.new('spec') do |t|
|
10
|
+
t.verbose = true
|
11
|
+
end
|
12
|
+
|
13
|
+
task :default => :spec
|
14
|
+
rescue LoadError
|
15
|
+
puts "rspec, or one of its dependencies, is not available. Install it with: sudo gem install rspec"
|
16
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'rake/clean'
|
2
|
+
require 'rake/extensioncompiler'
|
3
|
+
|
4
|
+
# download mysql library and headers
|
5
|
+
directory "vendor"
|
6
|
+
|
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}/"
|
9
|
+
when_writing "downloading #{t.name}" do
|
10
|
+
cd File.dirname(t.name) do
|
11
|
+
sh "wget -c #{url} || curl -C - -O #{url}"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
file "vendor/mysql-connector-c-noinstall-#{CONNECTOR_VERSION}-win32/include/mysql.h" => ["vendor/mysql-connector-c-noinstall-#{CONNECTOR_VERSION}-win32.zip"] do |t|
|
17
|
+
full_file = File.expand_path(t.prerequisites.last)
|
18
|
+
when_writing "creating #{t.name}" do
|
19
|
+
cd "vendor" do
|
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/**"
|
21
|
+
end
|
22
|
+
# update file timestamp to avoid Rake perform this extraction again.
|
23
|
+
touch t.name
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# clobber expanded packages
|
28
|
+
CLOBBER.include("vendor/mysql-connector-c-noinstall-#{CONNECTOR_VERSION}-win32")
|
29
|
+
|
30
|
+
# vendor:mysql
|
31
|
+
task 'vendor:mysql' => ["vendor/mysql-connector-c-noinstall-#{CONNECTOR_VERSION}-win32/include/mysql.h"]
|
32
|
+
|
33
|
+
# hook into cross compilation vendored mysql dependency
|
34
|
+
if RUBY_PLATFORM =~ /mingw|mswin/ then
|
35
|
+
Rake::Task['compile'].prerequisites.unshift 'vendor:mysql'
|
36
|
+
else
|
37
|
+
if Rake::Task.tasks.map {|t| t.name }.include? 'cross'
|
38
|
+
Rake::Task['cross'].prerequisites.unshift 'vendor:mysql'
|
39
|
+
end
|
40
|
+
end
|
metadata
ADDED
@@ -0,0 +1,198 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: solaris-mysql2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.11
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Brian Lopez
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-01-26 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: eventmachine
|
16
|
+
requirement: &70176301335020 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70176301335020
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rake-compiler
|
27
|
+
requirement: &70176301334460 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.7.7
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70176301334460
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rake
|
38
|
+
requirement: &70176301333860 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - =
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 0.8.7
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70176301333860
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rspec
|
49
|
+
requirement: &70176301333260 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70176301333260
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: activerecord
|
60
|
+
requirement: &70176301332440 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *70176301332440
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: mysql
|
71
|
+
requirement: &70176301331100 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *70176301331100
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: do_mysql
|
82
|
+
requirement: &70176301330120 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: *70176301330120
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: sequel
|
93
|
+
requirement: &70176301329480 !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
type: :development
|
100
|
+
prerelease: false
|
101
|
+
version_requirements: *70176301329480
|
102
|
+
- !ruby/object:Gem::Dependency
|
103
|
+
name: faker
|
104
|
+
requirement: &70176301328120 !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
type: :development
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: *70176301328120
|
113
|
+
description:
|
114
|
+
email: seniorlopez@gmail.com
|
115
|
+
executables: []
|
116
|
+
extensions:
|
117
|
+
- ext/mysql2/extconf.rb
|
118
|
+
extra_rdoc_files: []
|
119
|
+
files:
|
120
|
+
- .gitignore
|
121
|
+
- .rspec
|
122
|
+
- .rvmrc
|
123
|
+
- .travis.yml
|
124
|
+
- CHANGELOG.md
|
125
|
+
- Gemfile
|
126
|
+
- MIT-LICENSE
|
127
|
+
- README.md
|
128
|
+
- Rakefile
|
129
|
+
- benchmark/active_record.rb
|
130
|
+
- benchmark/active_record_threaded.rb
|
131
|
+
- benchmark/allocations.rb
|
132
|
+
- benchmark/escape.rb
|
133
|
+
- benchmark/query_with_mysql_casting.rb
|
134
|
+
- benchmark/query_without_mysql_casting.rb
|
135
|
+
- benchmark/sequel.rb
|
136
|
+
- benchmark/setup_db.rb
|
137
|
+
- benchmark/threaded.rb
|
138
|
+
- examples/eventmachine.rb
|
139
|
+
- examples/threaded.rb
|
140
|
+
- ext/mysql2/client.c
|
141
|
+
- ext/mysql2/client.h
|
142
|
+
- ext/mysql2/extconf.rb
|
143
|
+
- ext/mysql2/mysql2_ext.c
|
144
|
+
- ext/mysql2/mysql2_ext.h
|
145
|
+
- ext/mysql2/result.c
|
146
|
+
- ext/mysql2/result.h
|
147
|
+
- ext/mysql2/wait_for_single_fd.h
|
148
|
+
- lib/mysql2.rb
|
149
|
+
- lib/mysql2/client.rb
|
150
|
+
- lib/mysql2/em.rb
|
151
|
+
- lib/mysql2/error.rb
|
152
|
+
- lib/mysql2/result.rb
|
153
|
+
- lib/mysql2/version.rb
|
154
|
+
- solaris-mysql2.gemspec
|
155
|
+
- spec/em/em_spec.rb
|
156
|
+
- spec/mysql2/client_spec.rb
|
157
|
+
- spec/mysql2/error_spec.rb
|
158
|
+
- spec/mysql2/result_spec.rb
|
159
|
+
- spec/rcov.opts
|
160
|
+
- spec/spec_helper.rb
|
161
|
+
- tasks/benchmarks.rake
|
162
|
+
- tasks/compile.rake
|
163
|
+
- tasks/rspec.rake
|
164
|
+
- tasks/vendor_mysql.rake
|
165
|
+
homepage: http://github.com/brianmario/mysql2
|
166
|
+
licenses: []
|
167
|
+
post_install_message:
|
168
|
+
rdoc_options:
|
169
|
+
- --charset=UTF-8
|
170
|
+
require_paths:
|
171
|
+
- lib
|
172
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
173
|
+
none: false
|
174
|
+
requirements:
|
175
|
+
- - ! '>='
|
176
|
+
- !ruby/object:Gem::Version
|
177
|
+
version: '0'
|
178
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
179
|
+
none: false
|
180
|
+
requirements:
|
181
|
+
- - ! '>='
|
182
|
+
- !ruby/object:Gem::Version
|
183
|
+
version: '0'
|
184
|
+
requirements: []
|
185
|
+
rubyforge_project:
|
186
|
+
rubygems_version: 1.8.10
|
187
|
+
signing_key:
|
188
|
+
specification_version: 3
|
189
|
+
summary: A simple, fast Mysql library for Ruby, binding to libmysql
|
190
|
+
test_files:
|
191
|
+
- examples/eventmachine.rb
|
192
|
+
- examples/threaded.rb
|
193
|
+
- spec/em/em_spec.rb
|
194
|
+
- spec/mysql2/client_spec.rb
|
195
|
+
- spec/mysql2/error_spec.rb
|
196
|
+
- spec/mysql2/result_spec.rb
|
197
|
+
- spec/rcov.opts
|
198
|
+
- spec/spec_helper.rb
|