rdp-mysql2 0.2.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. data/.gitignore +12 -0
  2. data/.rspec +2 -0
  3. data/.rvmrc +1 -0
  4. data/CHANGELOG.md +142 -0
  5. data/Gemfile +3 -0
  6. data/MIT-LICENSE +20 -0
  7. data/README.rdoc +261 -0
  8. data/Rakefile +5 -0
  9. data/benchmark/active_record.rb +51 -0
  10. data/benchmark/active_record_threaded.rb +42 -0
  11. data/benchmark/allocations.rb +33 -0
  12. data/benchmark/escape.rb +36 -0
  13. data/benchmark/query_with_mysql_casting.rb +80 -0
  14. data/benchmark/query_without_mysql_casting.rb +47 -0
  15. data/benchmark/sequel.rb +37 -0
  16. data/benchmark/setup_db.rb +119 -0
  17. data/benchmark/threaded.rb +44 -0
  18. data/examples/eventmachine.rb +21 -0
  19. data/examples/threaded.rb +20 -0
  20. data/ext/mysql2/client.c +839 -0
  21. data/ext/mysql2/client.h +41 -0
  22. data/ext/mysql2/extconf.rb +72 -0
  23. data/ext/mysql2/mysql2_ext.c +12 -0
  24. data/ext/mysql2/mysql2_ext.h +42 -0
  25. data/ext/mysql2/result.c +488 -0
  26. data/ext/mysql2/result.h +20 -0
  27. data/lib/active_record/connection_adapters/em_mysql2_adapter.rb +64 -0
  28. data/lib/active_record/connection_adapters/mysql2_adapter.rb +654 -0
  29. data/lib/active_record/fiber_patches.rb +104 -0
  30. data/lib/arel/engines/sql/compilers/mysql2_compiler.rb +11 -0
  31. data/lib/mysql2.rb +16 -0
  32. data/lib/mysql2/client.rb +240 -0
  33. data/lib/mysql2/em.rb +37 -0
  34. data/lib/mysql2/em_fiber.rb +31 -0
  35. data/lib/mysql2/error.rb +15 -0
  36. data/lib/mysql2/result.rb +5 -0
  37. data/lib/mysql2/version.rb +3 -0
  38. data/mysql2.gemspec +32 -0
  39. data/spec/em/em_fiber_spec.rb +22 -0
  40. data/spec/em/em_spec.rb +49 -0
  41. data/spec/mysql2/client_spec.rb +430 -0
  42. data/spec/mysql2/error_spec.rb +69 -0
  43. data/spec/mysql2/result_spec.rb +333 -0
  44. data/spec/rcov.opts +3 -0
  45. data/spec/spec_helper.rb +66 -0
  46. data/tasks/benchmarks.rake +20 -0
  47. data/tasks/compile.rake +71 -0
  48. data/tasks/rspec.rake +16 -0
  49. data/tasks/vendor_mysql.rake +40 -0
  50. metadata +236 -0
@@ -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
@@ -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
@@ -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,236 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rdp-mysql2
3
+ version: !ruby/object:Gem::Version
4
+ hash: 65
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 2
9
+ - 7
10
+ - 1
11
+ version: 0.2.7.1
12
+ platform: ruby
13
+ authors:
14
+ - Brian Lopez
15
+ autorequire:
16
+ bindir: bin
17
+ cert_chain: []
18
+
19
+ date: 2011-05-26 00:00:00 Z
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: eventmachine
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :development
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: rake-compiler
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ hash: 13
44
+ segments:
45
+ - 0
46
+ - 7
47
+ - 7
48
+ version: 0.7.7
49
+ type: :development
50
+ version_requirements: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ name: rspec
53
+ prerelease: false
54
+ requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ hash: 3
60
+ segments:
61
+ - 0
62
+ version: "0"
63
+ type: :development
64
+ version_requirements: *id003
65
+ - !ruby/object:Gem::Dependency
66
+ name: activerecord
67
+ prerelease: false
68
+ requirement: &id004 !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ hash: 3
74
+ segments:
75
+ - 0
76
+ version: "0"
77
+ type: :development
78
+ version_requirements: *id004
79
+ - !ruby/object:Gem::Dependency
80
+ name: mysql
81
+ prerelease: false
82
+ requirement: &id005 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ hash: 3
88
+ segments:
89
+ - 0
90
+ version: "0"
91
+ type: :development
92
+ version_requirements: *id005
93
+ - !ruby/object:Gem::Dependency
94
+ name: do_mysql
95
+ prerelease: false
96
+ requirement: &id006 !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ hash: 3
102
+ segments:
103
+ - 0
104
+ version: "0"
105
+ type: :development
106
+ version_requirements: *id006
107
+ - !ruby/object:Gem::Dependency
108
+ name: sequel
109
+ prerelease: false
110
+ requirement: &id007 !ruby/object:Gem::Requirement
111
+ none: false
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ hash: 3
116
+ segments:
117
+ - 0
118
+ version: "0"
119
+ type: :development
120
+ version_requirements: *id007
121
+ - !ruby/object:Gem::Dependency
122
+ name: faker
123
+ prerelease: false
124
+ requirement: &id008 !ruby/object:Gem::Requirement
125
+ none: false
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ hash: 3
130
+ segments:
131
+ - 0
132
+ version: "0"
133
+ type: :development
134
+ version_requirements: *id008
135
+ description:
136
+ email: seniorlopez@gmail.com
137
+ executables: []
138
+
139
+ extensions:
140
+ - ext/mysql2/extconf.rb
141
+ extra_rdoc_files:
142
+ - README.rdoc
143
+ files:
144
+ - .gitignore
145
+ - .rspec
146
+ - .rvmrc
147
+ - CHANGELOG.md
148
+ - Gemfile
149
+ - MIT-LICENSE
150
+ - README.rdoc
151
+ - Rakefile
152
+ - benchmark/active_record.rb
153
+ - benchmark/active_record_threaded.rb
154
+ - benchmark/allocations.rb
155
+ - benchmark/escape.rb
156
+ - benchmark/query_with_mysql_casting.rb
157
+ - benchmark/query_without_mysql_casting.rb
158
+ - benchmark/sequel.rb
159
+ - benchmark/setup_db.rb
160
+ - benchmark/threaded.rb
161
+ - examples/eventmachine.rb
162
+ - examples/threaded.rb
163
+ - ext/mysql2/client.c
164
+ - ext/mysql2/client.h
165
+ - ext/mysql2/extconf.rb
166
+ - ext/mysql2/mysql2_ext.c
167
+ - ext/mysql2/mysql2_ext.h
168
+ - ext/mysql2/result.c
169
+ - ext/mysql2/result.h
170
+ - lib/active_record/connection_adapters/em_mysql2_adapter.rb
171
+ - lib/active_record/connection_adapters/mysql2_adapter.rb
172
+ - lib/active_record/fiber_patches.rb
173
+ - lib/arel/engines/sql/compilers/mysql2_compiler.rb
174
+ - lib/mysql2.rb
175
+ - lib/mysql2/client.rb
176
+ - lib/mysql2/em.rb
177
+ - lib/mysql2/em_fiber.rb
178
+ - lib/mysql2/error.rb
179
+ - lib/mysql2/result.rb
180
+ - lib/mysql2/version.rb
181
+ - mysql2.gemspec
182
+ - spec/em/em_fiber_spec.rb
183
+ - spec/em/em_spec.rb
184
+ - spec/mysql2/client_spec.rb
185
+ - spec/mysql2/error_spec.rb
186
+ - spec/mysql2/result_spec.rb
187
+ - spec/rcov.opts
188
+ - spec/spec_helper.rb
189
+ - tasks/benchmarks.rake
190
+ - tasks/compile.rake
191
+ - tasks/rspec.rake
192
+ - tasks/vendor_mysql.rake
193
+ homepage: http://github.com/brianmario/mysql2
194
+ licenses: []
195
+
196
+ post_install_message:
197
+ rdoc_options:
198
+ - --charset=UTF-8
199
+ require_paths:
200
+ - lib
201
+ - ext
202
+ required_ruby_version: !ruby/object:Gem::Requirement
203
+ none: false
204
+ requirements:
205
+ - - ">="
206
+ - !ruby/object:Gem::Version
207
+ hash: 3
208
+ segments:
209
+ - 0
210
+ version: "0"
211
+ required_rubygems_version: !ruby/object:Gem::Requirement
212
+ none: false
213
+ requirements:
214
+ - - ">="
215
+ - !ruby/object:Gem::Version
216
+ hash: 3
217
+ segments:
218
+ - 0
219
+ version: "0"
220
+ requirements: []
221
+
222
+ rubyforge_project:
223
+ rubygems_version: 1.8.2
224
+ signing_key:
225
+ specification_version: 3
226
+ summary: A simple, fast Mysql library for Ruby, binding to libmysql
227
+ test_files:
228
+ - examples/eventmachine.rb
229
+ - examples/threaded.rb
230
+ - spec/em/em_fiber_spec.rb
231
+ - spec/em/em_spec.rb
232
+ - spec/mysql2/client_spec.rb
233
+ - spec/mysql2/error_spec.rb
234
+ - spec/mysql2/result_spec.rb
235
+ - spec/rcov.opts
236
+ - spec/spec_helper.rb