mysql2 0.2.6-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. data/.gitignore +12 -0
  2. data/.rspec +2 -0
  3. data/CHANGELOG.md +117 -0
  4. data/MIT-LICENSE +20 -0
  5. data/README.rdoc +240 -0
  6. data/Rakefile +5 -0
  7. data/VERSION +1 -0
  8. data/benchmark/active_record.rb +53 -0
  9. data/benchmark/allocations.rb +33 -0
  10. data/benchmark/escape.rb +39 -0
  11. data/benchmark/query_with_mysql_casting.rb +83 -0
  12. data/benchmark/query_without_mysql_casting.rb +50 -0
  13. data/benchmark/sequel.rb +39 -0
  14. data/benchmark/setup_db.rb +115 -0
  15. data/examples/eventmachine.rb +21 -0
  16. data/examples/threaded.rb +20 -0
  17. data/ext/mysql2/client.c +659 -0
  18. data/ext/mysql2/client.h +41 -0
  19. data/ext/mysql2/extconf.rb +65 -0
  20. data/ext/mysql2/mysql2_ext.c +12 -0
  21. data/ext/mysql2/mysql2_ext.h +32 -0
  22. data/ext/mysql2/result.c +475 -0
  23. data/ext/mysql2/result.h +20 -0
  24. data/lib/active_record/connection_adapters/em_mysql2_adapter.rb +63 -0
  25. data/lib/active_record/connection_adapters/mysql2_adapter.rb +654 -0
  26. data/lib/active_record/fiber_patches.rb +104 -0
  27. data/lib/arel/engines/sql/compilers/mysql2_compiler.rb +11 -0
  28. data/lib/mysql2.rb +16 -0
  29. data/lib/mysql2/client.rb +235 -0
  30. data/lib/mysql2/em.rb +33 -0
  31. data/lib/mysql2/error.rb +15 -0
  32. data/lib/mysql2/result.rb +5 -0
  33. data/mysql2.gemspec +89 -0
  34. data/spec/em/em_spec.rb +49 -0
  35. data/spec/mysql2/client_spec.rb +348 -0
  36. data/spec/mysql2/error_spec.rb +25 -0
  37. data/spec/mysql2/result_spec.rb +318 -0
  38. data/spec/rcov.opts +3 -0
  39. data/spec/spec_helper.rb +67 -0
  40. data/tasks/benchmarks.rake +8 -0
  41. data/tasks/compile.rake +54 -0
  42. data/tasks/jeweler.rake +17 -0
  43. data/tasks/rspec.rake +16 -0
  44. data/tasks/vendor_mysql.rake +41 -0
  45. metadata +120 -0
data/spec/rcov.opts ADDED
@@ -0,0 +1,3 @@
1
+ --exclude spec,gem
2
+ --text-summary
3
+ --sort coverage --sort-reverse
@@ -0,0 +1,67 @@
1
+ # encoding: UTF-8
2
+
3
+ $LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
4
+ require 'rspec'
5
+ require 'mysql2'
6
+ require 'timeout'
7
+
8
+ RSpec.configure do |config|
9
+ config.before(:all) do
10
+ client = Mysql2::Client.new :database => 'test'
11
+ client.query %[
12
+ CREATE TABLE IF NOT EXISTS mysql2_test (
13
+ id MEDIUMINT NOT NULL AUTO_INCREMENT,
14
+ null_test VARCHAR(10),
15
+ bit_test BIT(64),
16
+ tiny_int_test TINYINT,
17
+ bool_cast_test TINYINT(1),
18
+ small_int_test SMALLINT,
19
+ medium_int_test MEDIUMINT,
20
+ int_test INT,
21
+ big_int_test BIGINT,
22
+ float_test FLOAT(10,3),
23
+ float_zero_test FLOAT(10,3),
24
+ double_test DOUBLE(10,3),
25
+ decimal_test DECIMAL(10,3),
26
+ decimal_zero_test DECIMAL(10,3),
27
+ date_test DATE,
28
+ date_time_test DATETIME,
29
+ timestamp_test TIMESTAMP,
30
+ time_test TIME,
31
+ year_test YEAR(4),
32
+ char_test CHAR(10),
33
+ varchar_test VARCHAR(10),
34
+ binary_test BINARY(10),
35
+ varbinary_test VARBINARY(10),
36
+ tiny_blob_test TINYBLOB,
37
+ tiny_text_test TINYTEXT,
38
+ blob_test BLOB,
39
+ text_test TEXT,
40
+ medium_blob_test MEDIUMBLOB,
41
+ medium_text_test MEDIUMTEXT,
42
+ long_blob_test LONGBLOB,
43
+ long_text_test LONGTEXT,
44
+ enum_test ENUM('val1', 'val2'),
45
+ set_test SET('val1', 'val2'),
46
+ PRIMARY KEY (id)
47
+ )
48
+ ]
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,8 @@
1
+ namespace :bench do
2
+ [ :active_record, :escape, :query_with_mysql_casting,
3
+ :query_without_mysql_casting, :sequel, :allocations,
4
+ :thread_alone].each do |feature|
5
+ desc "Run #{feature} benchmarks"
6
+ task(feature){ ruby "benchmark/#{feature}.rb" }
7
+ end
8
+ end
@@ -0,0 +1,54 @@
1
+ gem 'rake-compiler', '~> 0.7.1'
2
+ require "rake/extensiontask"
3
+
4
+ MYSQL_VERSION = "5.1.51"
5
+ MYSQL_MIRROR = ENV['MYSQL_MIRROR'] || "http://mysql.he.net/"
6
+
7
+ def gemspec
8
+ @clean_gemspec ||= eval(File.read(File.expand_path('../../mysql2.gemspec', __FILE__)))
9
+ end
10
+
11
+ Rake::ExtensionTask.new("mysql2", gemspec) do |ext|
12
+ # reference where the vendored MySQL got extracted
13
+ mysql_lib = File.expand_path(File.join(File.dirname(__FILE__), '..', 'vendor', "mysql-#{MYSQL_VERSION}-win32"))
14
+
15
+ # DRY options feed into compile or cross-compile process
16
+ windows_options = [
17
+ "--with-mysql-include=#{mysql_lib}/include",
18
+ "--with-mysql-lib=#{mysql_lib}/lib/opt"
19
+ ]
20
+
21
+ # automatically add build options to avoid need of manual input
22
+ if RUBY_PLATFORM =~ /mswin|mingw/ then
23
+ ext.config_options = windows_options
24
+ else
25
+ ext.cross_compile = true
26
+ ext.cross_platform = ['x86-mingw32', 'x86-mswin32-60']
27
+ ext.cross_config_options = windows_options
28
+
29
+ # inject 1.8/1.9 pure-ruby entry point when cross compiling only
30
+ ext.cross_compiling do |spec|
31
+ spec.files << 'lib/mysql2/mysql2.rb'
32
+ end
33
+ end
34
+
35
+ ext.lib_dir = File.join 'lib', 'mysql2'
36
+
37
+ # clean compiled extension
38
+ CLEAN.include "#{ext.lib_dir}/*.#{RbConfig::CONFIG['DLEXT']}"
39
+ end
40
+ Rake::Task[:spec].prerequisites << :compile
41
+
42
+ file 'lib/mysql2/mysql2.rb' do |t|
43
+ name = gemspec.name
44
+ File.open(t.name, 'wb') do |f|
45
+ f.write <<-eoruby
46
+ RUBY_VERSION =~ /(\\d+.\\d+)/
47
+ require "#{name}/\#{$1}/#{name}"
48
+ eoruby
49
+ end
50
+ end
51
+
52
+ if Rake::Task.task_defined?(:cross)
53
+ Rake::Task[:cross].prerequisites << "lib/mysql2/mysql2.rb"
54
+ end
@@ -0,0 +1,17 @@
1
+ begin
2
+ require 'jeweler'
3
+ JEWELER = Jeweler::Tasks.new do |gem|
4
+ gem.name = "mysql2"
5
+ gem.summary = "A simple, fast Mysql library for Ruby, binding to libmysql"
6
+ gem.email = "seniorlopez@gmail.com"
7
+ gem.homepage = "http://github.com/brianmario/mysql2"
8
+ gem.authors = ["Brian Lopez"]
9
+ gem.require_paths = ["lib", "ext"]
10
+ gem.extra_rdoc_files = `git ls-files *.rdoc`.split("\n")
11
+ gem.files = `git ls-files`.split("\n")
12
+ gem.extensions = ["ext/mysql2/extconf.rb"]
13
+ gem.files.include %w(lib/jeweler/templates/.document lib/jeweler/templates/.gitignore)
14
+ end
15
+ rescue LoadError
16
+ puts "jeweler, or one of its dependencies, is not available. Install it with: sudo gem install jeweler"
17
+ 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,41 @@
1
+ require 'rake/clean'
2
+ require 'rake/extensioncompiler'
3
+
4
+ # download mysql library and headers
5
+ directory "vendor"
6
+
7
+ file "vendor/mysql-noinstall-#{MYSQL_VERSION}-win32.zip" => ['vendor'] do |t|
8
+ base_version = MYSQL_VERSION.gsub(/\.[0-9]+$/, '')
9
+ url = "http://dev.mysql.com/get/Downloads/MySQL-#{base_version}/#{File.basename(t.name)}/from/#{MYSQL_MIRROR}/"
10
+ when_writing "downloading #{t.name}" do
11
+ cd File.dirname(t.name) do
12
+ sh "wget -c #{url} || curl -C - -O #{url}"
13
+ end
14
+ end
15
+ end
16
+
17
+ file "vendor/mysql-#{MYSQL_VERSION}-win32/include/mysql.h" => ["vendor/mysql-noinstall-#{MYSQL_VERSION}-win32.zip"] do |t|
18
+ full_file = File.expand_path(t.prerequisites.last)
19
+ when_writing "creating #{t.name}" do
20
+ cd "vendor" do
21
+ sh "unzip #{full_file} mysql-#{MYSQL_VERSION}-win32/bin/** mysql-#{MYSQL_VERSION}-win32/include/** mysql-#{MYSQL_VERSION}-win32/lib/**"
22
+ end
23
+ # update file timestamp to avoid Rake perform this extraction again.
24
+ touch t.name
25
+ end
26
+ end
27
+
28
+ # clobber expanded packages
29
+ CLOBBER.include("vendor/mysql-#{MYSQL_VERSION}-win32")
30
+
31
+ # vendor:mysql
32
+ task 'vendor:mysql' => ["vendor/mysql-#{MYSQL_VERSION}-win32/include/mysql.h"]
33
+
34
+ # hook into cross compilation vendored mysql dependency
35
+ if RUBY_PLATFORM =~ /mingw|mswin/ then
36
+ Rake::Task['compile'].prerequisites.unshift 'vendor:mysql'
37
+ else
38
+ if Rake::Task.tasks.map {|t| t.name }.include? 'cross'
39
+ Rake::Task['cross'].prerequisites.unshift 'vendor:mysql'
40
+ end
41
+ end
metadata ADDED
@@ -0,0 +1,120 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mysql2
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 2
9
+ - 6
10
+ version: 0.2.6
11
+ platform: x86-mingw32
12
+ authors:
13
+ - Brian Lopez
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-10-19 00:00:00 -07:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description:
23
+ email: seniorlopez@gmail.com
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files:
29
+ - README.rdoc
30
+ files:
31
+ - .gitignore
32
+ - .rspec
33
+ - CHANGELOG.md
34
+ - MIT-LICENSE
35
+ - README.rdoc
36
+ - Rakefile
37
+ - VERSION
38
+ - benchmark/active_record.rb
39
+ - benchmark/allocations.rb
40
+ - benchmark/escape.rb
41
+ - benchmark/query_with_mysql_casting.rb
42
+ - benchmark/query_without_mysql_casting.rb
43
+ - benchmark/sequel.rb
44
+ - benchmark/setup_db.rb
45
+ - examples/eventmachine.rb
46
+ - examples/threaded.rb
47
+ - ext/mysql2/client.c
48
+ - ext/mysql2/client.h
49
+ - ext/mysql2/extconf.rb
50
+ - ext/mysql2/mysql2_ext.c
51
+ - ext/mysql2/mysql2_ext.h
52
+ - ext/mysql2/result.c
53
+ - ext/mysql2/result.h
54
+ - lib/active_record/connection_adapters/em_mysql2_adapter.rb
55
+ - lib/active_record/connection_adapters/mysql2_adapter.rb
56
+ - lib/active_record/fiber_patches.rb
57
+ - lib/arel/engines/sql/compilers/mysql2_compiler.rb
58
+ - lib/mysql2.rb
59
+ - lib/mysql2/client.rb
60
+ - lib/mysql2/em.rb
61
+ - lib/mysql2/error.rb
62
+ - lib/mysql2/result.rb
63
+ - mysql2.gemspec
64
+ - spec/em/em_spec.rb
65
+ - spec/mysql2/client_spec.rb
66
+ - spec/mysql2/error_spec.rb
67
+ - spec/mysql2/result_spec.rb
68
+ - spec/rcov.opts
69
+ - spec/spec_helper.rb
70
+ - tasks/benchmarks.rake
71
+ - tasks/compile.rake
72
+ - tasks/jeweler.rake
73
+ - tasks/rspec.rake
74
+ - tasks/vendor_mysql.rake
75
+ - lib/mysql2/1.8/mysql2.so
76
+ - lib/mysql2/1.9/mysql2.so
77
+ - lib/mysql2/mysql2.rb
78
+ has_rdoc: true
79
+ homepage: http://github.com/brianmario/mysql2
80
+ licenses: []
81
+
82
+ post_install_message:
83
+ rdoc_options:
84
+ - --charset=UTF-8
85
+ require_paths:
86
+ - lib
87
+ - ext
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ hash: 3
94
+ segments:
95
+ - 0
96
+ version: "0"
97
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ hash: 3
103
+ segments:
104
+ - 0
105
+ version: "0"
106
+ requirements: []
107
+
108
+ rubyforge_project:
109
+ rubygems_version: 1.3.7
110
+ signing_key:
111
+ specification_version: 3
112
+ summary: A simple, fast Mysql library for Ruby, binding to libmysql
113
+ test_files:
114
+ - spec/em/em_spec.rb
115
+ - spec/mysql2/client_spec.rb
116
+ - spec/mysql2/error_spec.rb
117
+ - spec/mysql2/result_spec.rb
118
+ - spec/spec_helper.rb
119
+ - examples/eventmachine.rb
120
+ - examples/threaded.rb