mysql2 0.3.1 → 0.5.2
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.
- checksums.yaml +7 -0
- data/CHANGELOG.md +1 -151
- data/LICENSE +21 -0
- data/README.md +634 -0
- data/examples/eventmachine.rb +1 -3
- data/examples/threaded.rb +5 -9
- data/ext/mysql2/client.c +1154 -342
- data/ext/mysql2/client.h +20 -33
- data/ext/mysql2/extconf.rb +229 -37
- data/ext/mysql2/infile.c +122 -0
- data/ext/mysql2/infile.h +1 -0
- data/ext/mysql2/mysql2_ext.c +3 -1
- data/ext/mysql2/mysql2_ext.h +18 -16
- data/ext/mysql2/mysql_enc_name_to_ruby.h +168 -0
- data/ext/mysql2/mysql_enc_to_ruby.h +259 -0
- data/ext/mysql2/result.c +708 -191
- data/ext/mysql2/result.h +15 -6
- data/ext/mysql2/statement.c +602 -0
- data/ext/mysql2/statement.h +17 -0
- data/ext/mysql2/wait_for_single_fd.h +37 -0
- data/lib/mysql2.rb +69 -7
- data/lib/mysql2/client.rb +126 -211
- data/lib/mysql2/console.rb +5 -0
- data/lib/mysql2/em.rb +24 -8
- data/lib/mysql2/error.rb +93 -8
- data/lib/mysql2/field.rb +3 -0
- data/lib/mysql2/result.rb +2 -0
- data/lib/mysql2/statement.rb +11 -0
- data/lib/mysql2/version.rb +2 -2
- data/spec/configuration.yml.example +11 -0
- data/spec/em/em_spec.rb +101 -15
- data/spec/my.cnf.example +9 -0
- data/spec/mysql2/client_spec.rb +874 -232
- data/spec/mysql2/error_spec.rb +55 -46
- data/spec/mysql2/result_spec.rb +306 -154
- data/spec/mysql2/statement_spec.rb +712 -0
- data/spec/spec_helper.rb +103 -57
- data/spec/ssl/ca-cert.pem +17 -0
- data/spec/ssl/ca-key.pem +27 -0
- data/spec/ssl/ca.cnf +22 -0
- data/spec/ssl/cert.cnf +22 -0
- data/spec/ssl/client-cert.pem +17 -0
- data/spec/ssl/client-key.pem +27 -0
- data/spec/ssl/client-req.pem +15 -0
- data/spec/ssl/gen_certs.sh +48 -0
- data/spec/ssl/pkcs8-client-key.pem +28 -0
- data/spec/ssl/pkcs8-server-key.pem +28 -0
- data/spec/ssl/server-cert.pem +17 -0
- data/spec/ssl/server-key.pem +27 -0
- data/spec/ssl/server-req.pem +15 -0
- data/spec/test_data +1 -0
- data/support/5072E1F5.asc +432 -0
- data/support/libmysql.def +219 -0
- data/support/mysql_enc_to_ruby.rb +81 -0
- data/support/ruby_enc_to_mysql.rb +61 -0
- metadata +82 -188
- data/.gitignore +0 -12
- data/.rspec +0 -2
- data/.rvmrc +0 -1
- data/Gemfile +0 -3
- data/MIT-LICENSE +0 -20
- data/README.rdoc +0 -257
- 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 -47
- data/benchmark/sequel.rb +0 -37
- data/benchmark/setup_db.rb +0 -119
- data/benchmark/threaded.rb +0 -44
- data/lib/active_record/connection_adapters/em_mysql2_adapter.rb +0 -64
- data/lib/active_record/fiber_patches.rb +0 -104
- data/lib/mysql2/em_fiber.rb +0 -31
- data/mysql2.gemspec +0 -32
- data/spec/em/em_fiber_spec.rb +0 -22
- data/tasks/benchmarks.rake +0 -20
- data/tasks/compile.rake +0 -71
- data/tasks/rspec.rake +0 -16
- data/tasks/vendor_mysql.rake +0 -40
data/lib/mysql2/em_fiber.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'mysql2/em'
|
4
|
-
require 'fiber'
|
5
|
-
|
6
|
-
module Mysql2
|
7
|
-
module EM
|
8
|
-
module Fiber
|
9
|
-
class Client < ::Mysql2::EM::Client
|
10
|
-
def query(sql, opts={})
|
11
|
-
if ::EM.reactor_running?
|
12
|
-
deferable = super(sql, opts)
|
13
|
-
|
14
|
-
fiber = ::Fiber.current
|
15
|
-
deferable.callback do |result|
|
16
|
-
fiber.resume(result)
|
17
|
-
end
|
18
|
-
deferable.errback do |err|
|
19
|
-
fiber.resume(err)
|
20
|
-
end
|
21
|
-
::Fiber.yield.tap do |result|
|
22
|
-
raise result if result.is_a?(::Exception)
|
23
|
-
end
|
24
|
-
else
|
25
|
-
super(sql, opts)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
data/mysql2.gemspec
DELETED
@@ -1,32 +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.extra_rdoc_files = [
|
11
|
-
"README.rdoc"
|
12
|
-
]
|
13
|
-
s.files = `git ls-files`.split("\n")
|
14
|
-
s.homepage = %q{http://github.com/brianmario/mysql2}
|
15
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
16
|
-
s.require_paths = ["lib", "ext"]
|
17
|
-
s.rubygems_version = %q{1.4.2}
|
18
|
-
s.summary = %q{A simple, fast Mysql library for Ruby, binding to libmysql}
|
19
|
-
s.test_files = `git ls-files spec examples`.split("\n")
|
20
|
-
|
21
|
-
# tests
|
22
|
-
s.add_development_dependency 'eventmachine'
|
23
|
-
s.add_development_dependency 'rake-compiler', "~> 0.7.7"
|
24
|
-
s.add_development_dependency 'rspec'
|
25
|
-
# benchmarks
|
26
|
-
s.add_development_dependency 'activerecord'
|
27
|
-
s.add_development_dependency 'mysql'
|
28
|
-
s.add_development_dependency 'do_mysql'
|
29
|
-
s.add_development_dependency 'sequel'
|
30
|
-
s.add_development_dependency 'faker'
|
31
|
-
end
|
32
|
-
|
data/spec/em/em_fiber_spec.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
if defined? EventMachine && defined? Fiber
|
3
|
-
require 'spec_helper'
|
4
|
-
require 'mysql2/em_fiber'
|
5
|
-
|
6
|
-
describe Mysql2::EM::Fiber::Client do
|
7
|
-
it 'should support queries' do
|
8
|
-
results = []
|
9
|
-
EM.run do
|
10
|
-
Fiber.new {
|
11
|
-
client1 = Mysql2::EM::Fiber::Client.new
|
12
|
-
results = client1.query "SELECT sleep(0.1) as first_query"
|
13
|
-
EM.stop_event_loop
|
14
|
-
}.resume
|
15
|
-
end
|
16
|
-
|
17
|
-
results.first.keys.should include("first_query")
|
18
|
-
end
|
19
|
-
end
|
20
|
-
else
|
21
|
-
puts "Either EventMachine or Fibers not available. Skipping tests that use them."
|
22
|
-
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,16 +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
|
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
|