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/benchmark/threaded.rb
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
|
3
|
-
|
4
|
-
require 'rubygems'
|
5
|
-
require 'benchmark'
|
6
|
-
require 'active_record'
|
7
|
-
|
8
|
-
mysql2_opts = {
|
9
|
-
:adapter => 'mysql2',
|
10
|
-
:database => 'test',
|
11
|
-
:pool => 25
|
12
|
-
}
|
13
|
-
ActiveRecord::Base.establish_connection(mysql2_opts)
|
14
|
-
x = Benchmark.realtime do
|
15
|
-
threads = []
|
16
|
-
25.times do
|
17
|
-
threads << Thread.new { ActiveRecord::Base.connection.execute("select sleep(1)") }
|
18
|
-
end
|
19
|
-
threads.each {|t| t.join }
|
20
|
-
end
|
21
|
-
puts x
|
22
|
-
|
23
|
-
mysql2_opts = {
|
24
|
-
:adapter => 'mysql',
|
25
|
-
:database => 'test',
|
26
|
-
:pool => 25
|
27
|
-
}
|
28
|
-
ActiveRecord::Base.establish_connection(mysql2_opts)
|
29
|
-
x = Benchmark.realtime do
|
30
|
-
threads = []
|
31
|
-
25.times do
|
32
|
-
threads << Thread.new { ActiveRecord::Base.connection.execute("select sleep(1)") }
|
33
|
-
end
|
34
|
-
threads.each {|t| t.join }
|
35
|
-
end
|
36
|
-
puts x
|
37
|
-
|
38
|
-
# these results are similar on 1.8.7, 1.9.2 and rbx-head
|
39
|
-
#
|
40
|
-
# $ bundle exec ruby benchmarks/threaded.rb
|
41
|
-
# 1.0774750709533691
|
42
|
-
#
|
43
|
-
# and using the mysql gem
|
44
|
-
# 25.099437952041626
|
data/mysql2.gemspec
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
require File.expand_path('../lib/mysql2/version', __FILE__)
|
2
|
-
|
3
|
-
Gem::Specification.new do |s|
|
4
|
-
s.name = %q{mysql2}
|
5
|
-
s.version = Mysql2::VERSION
|
6
|
-
s.authors = ["Brian Lopez"]
|
7
|
-
s.date = Time.now.utc.strftime("%Y-%m-%d")
|
8
|
-
s.email = %q{seniorlopez@gmail.com}
|
9
|
-
s.extensions = ["ext/mysql2/extconf.rb"]
|
10
|
-
s.files = `git ls-files`.split("\n")
|
11
|
-
s.homepage = %q{http://github.com/brianmario/mysql2}
|
12
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
13
|
-
s.require_paths = ["lib"]
|
14
|
-
s.rubygems_version = %q{1.4.2}
|
15
|
-
s.summary = %q{A simple, fast Mysql library for Ruby, binding to libmysql}
|
16
|
-
s.test_files = `git ls-files spec examples`.split("\n")
|
17
|
-
|
18
|
-
# tests
|
19
|
-
s.add_development_dependency 'eventmachine'
|
20
|
-
s.add_development_dependency 'rake-compiler', "~> 0.7.7"
|
21
|
-
s.add_development_dependency 'rake', '0.8.7' # NB: 0.8.7 required by rake-compiler 0.7.9
|
22
|
-
s.add_development_dependency 'rspec'
|
23
|
-
# benchmarks
|
24
|
-
s.add_development_dependency 'activerecord'
|
25
|
-
s.add_development_dependency 'mysql'
|
26
|
-
s.add_development_dependency 'do_mysql'
|
27
|
-
s.add_development_dependency 'sequel'
|
28
|
-
s.add_development_dependency 'faker'
|
29
|
-
end
|
data/tasks/benchmarks.rake
DELETED
@@ -1,20 +0,0 @@
|
|
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
DELETED
@@ -1,71 +0,0 @@
|
|
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
DELETED
@@ -1,26 +0,0 @@
|
|
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
|
17
|
-
|
18
|
-
file 'spec/configuration.yml' => 'spec/configuration.yml.example' do |task|
|
19
|
-
CLEAN.exclude task.name
|
20
|
-
src_path = File.expand_path("../../#{task.prerequisites.first}", __FILE__)
|
21
|
-
dst_path = File.expand_path("../../#{task.name}", __FILE__)
|
22
|
-
cp src_path, dst_path
|
23
|
-
sh "sed -i 's/LOCALUSERNAME/#{ENV['USER']}/' #{dst_path}"
|
24
|
-
end
|
25
|
-
|
26
|
-
Rake::Task[:spec].prerequisites << :'spec/configuration.yml'
|
data/tasks/vendor_mysql.rake
DELETED
@@ -1,40 +0,0 @@
|
|
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
|