mysql2 0.2.24 → 0.5.4

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.
Files changed (46) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +1 -0
  3. data/LICENSE +21 -0
  4. data/README.md +237 -85
  5. data/ext/mysql2/client.c +582 -249
  6. data/ext/mysql2/client.h +10 -38
  7. data/ext/mysql2/extconf.rb +217 -66
  8. data/ext/mysql2/infile.c +2 -2
  9. data/ext/mysql2/mysql2_ext.c +9 -2
  10. data/ext/mysql2/mysql2_ext.h +13 -14
  11. data/ext/mysql2/mysql_enc_name_to_ruby.h +62 -58
  12. data/ext/mysql2/mysql_enc_to_ruby.h +82 -18
  13. data/ext/mysql2/result.c +736 -200
  14. data/ext/mysql2/result.h +13 -6
  15. data/ext/mysql2/statement.c +612 -0
  16. data/ext/mysql2/statement.h +17 -0
  17. data/ext/mysql2/wait_for_single_fd.h +2 -1
  18. data/lib/mysql2/client.rb +110 -28
  19. data/lib/mysql2/console.rb +1 -1
  20. data/lib/mysql2/em.rb +15 -9
  21. data/lib/mysql2/error.rb +57 -36
  22. data/lib/mysql2/field.rb +3 -0
  23. data/lib/mysql2/result.rb +2 -0
  24. data/lib/mysql2/statement.rb +9 -0
  25. data/lib/mysql2/version.rb +1 -1
  26. data/lib/mysql2.rb +66 -15
  27. data/support/3A79BD29.asc +49 -0
  28. data/support/5072E1F5.asc +432 -0
  29. data/support/libmysql.def +219 -0
  30. data/support/mysql_enc_to_ruby.rb +15 -11
  31. data/support/ruby_enc_to_mysql.rb +8 -6
  32. metadata +30 -94
  33. data/MIT-LICENSE +0 -20
  34. data/examples/eventmachine.rb +0 -21
  35. data/examples/threaded.rb +0 -20
  36. data/lib/active_record/connection_adapters/mysql2_adapter.rb +0 -635
  37. data/lib/arel/engines/sql/compilers/mysql2_compiler.rb +0 -11
  38. data/spec/configuration.yml.example +0 -17
  39. data/spec/em/em_spec.rb +0 -114
  40. data/spec/my.cnf.example +0 -9
  41. data/spec/mysql2/client_spec.rb +0 -897
  42. data/spec/mysql2/error_spec.rb +0 -83
  43. data/spec/mysql2/result_spec.rb +0 -505
  44. data/spec/rcov.opts +0 -3
  45. data/spec/spec_helper.rb +0 -87
  46. data/spec/test_data +0 -1
data/spec/em/em_spec.rb DELETED
@@ -1,114 +0,0 @@
1
- # encoding: UTF-8
2
- require 'spec_helper'
3
- begin
4
- require 'eventmachine'
5
- require 'mysql2/em'
6
-
7
- describe Mysql2::EM::Client do
8
- it "should support async queries" do
9
- results = []
10
- EM.run do
11
- client1 = Mysql2::EM::Client.new DatabaseCredentials['root']
12
- defer1 = client1.query "SELECT sleep(0.1) as first_query"
13
- defer1.callback do |result|
14
- results << result.first
15
- client1.close
16
- EM.stop_event_loop
17
- end
18
-
19
- client2 = Mysql2::EM::Client.new DatabaseCredentials['root']
20
- defer2 = client2.query "SELECT sleep(0.025) second_query"
21
- defer2.callback do |result|
22
- results << result.first
23
- client2.close
24
- end
25
- end
26
-
27
- results[0].keys.should include("second_query")
28
- results[1].keys.should include("first_query")
29
- end
30
-
31
- it "should support queries in callbacks" do
32
- results = []
33
- EM.run do
34
- client = Mysql2::EM::Client.new DatabaseCredentials['root']
35
- defer1 = client.query "SELECT sleep(0.025) as first_query"
36
- defer1.callback do |result|
37
- results << result.first
38
- defer2 = client.query "SELECT sleep(0.025) as second_query"
39
- defer2.callback do |r|
40
- results << r.first
41
- client.close
42
- EM.stop_event_loop
43
- end
44
- end
45
- end
46
-
47
- results[0].keys.should include("first_query")
48
- results[1].keys.should include("second_query")
49
- end
50
-
51
- it "should not swallow exceptions raised in callbacks" do
52
- lambda {
53
- EM.run do
54
- client = Mysql2::EM::Client.new DatabaseCredentials['root']
55
- defer = client.query "SELECT sleep(0.1) as first_query"
56
- defer.callback do |result|
57
- client.close
58
- raise 'some error'
59
- end
60
- defer.errback do |err|
61
- # This _shouldn't_ be run, but it needed to prevent the specs from
62
- # freezing if this test fails.
63
- EM.stop_event_loop
64
- end
65
- end
66
- }.should raise_error
67
- end
68
-
69
- context 'when an exception is raised by the client' do
70
- let(:client) { Mysql2::EM::Client.new DatabaseCredentials['root'] }
71
- let(:error) { StandardError.new('some error') }
72
- before { client.stub(:async_result).and_raise(error) }
73
-
74
- it "should swallow exceptions raised in by the client" do
75
- errors = []
76
- EM.run do
77
- defer = client.query "SELECT sleep(0.1) as first_query"
78
- defer.callback do |result|
79
- # This _shouldn't_ be run, but it is needed to prevent the specs from
80
- # freezing if this test fails.
81
- EM.stop_event_loop
82
- end
83
- defer.errback do |err|
84
- errors << err
85
- EM.stop_event_loop
86
- end
87
- end
88
- errors.should == [error]
89
- end
90
-
91
- it "should fail the deferrable" do
92
- callbacks_run = []
93
- EM.run do
94
- defer = client.query "SELECT sleep(0.025) as first_query"
95
- EM.add_timer(0.1) do
96
- defer.callback do |result|
97
- callbacks_run << :callback
98
- # This _shouldn't_ be run, but it is needed to prevent the specs from
99
- # freezing if this test fails.
100
- EM.stop_event_loop
101
- end
102
- defer.errback do |err|
103
- callbacks_run << :errback
104
- EM.stop_event_loop
105
- end
106
- end
107
- end
108
- callbacks_run.should == [:errback]
109
- end
110
- end
111
- end
112
- rescue LoadError
113
- puts "EventMachine not installed, skipping the specs that use it"
114
- end
data/spec/my.cnf.example DELETED
@@ -1,9 +0,0 @@
1
- [root]
2
- host=localhost
3
- user=LOCALUSERNAME
4
- password=
5
-
6
- [client]
7
- host=localhost
8
- user=LOCALUSERNAME
9
- password=