mysql2 0.3.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +1 -151
  3. data/LICENSE +21 -0
  4. data/README.md +634 -0
  5. data/examples/eventmachine.rb +1 -3
  6. data/examples/threaded.rb +5 -9
  7. data/ext/mysql2/client.c +1154 -342
  8. data/ext/mysql2/client.h +20 -33
  9. data/ext/mysql2/extconf.rb +229 -37
  10. data/ext/mysql2/infile.c +122 -0
  11. data/ext/mysql2/infile.h +1 -0
  12. data/ext/mysql2/mysql2_ext.c +3 -1
  13. data/ext/mysql2/mysql2_ext.h +18 -16
  14. data/ext/mysql2/mysql_enc_name_to_ruby.h +168 -0
  15. data/ext/mysql2/mysql_enc_to_ruby.h +259 -0
  16. data/ext/mysql2/result.c +708 -191
  17. data/ext/mysql2/result.h +15 -6
  18. data/ext/mysql2/statement.c +602 -0
  19. data/ext/mysql2/statement.h +17 -0
  20. data/ext/mysql2/wait_for_single_fd.h +37 -0
  21. data/lib/mysql2.rb +69 -7
  22. data/lib/mysql2/client.rb +126 -211
  23. data/lib/mysql2/console.rb +5 -0
  24. data/lib/mysql2/em.rb +24 -8
  25. data/lib/mysql2/error.rb +93 -8
  26. data/lib/mysql2/field.rb +3 -0
  27. data/lib/mysql2/result.rb +2 -0
  28. data/lib/mysql2/statement.rb +11 -0
  29. data/lib/mysql2/version.rb +2 -2
  30. data/spec/configuration.yml.example +11 -0
  31. data/spec/em/em_spec.rb +101 -15
  32. data/spec/my.cnf.example +9 -0
  33. data/spec/mysql2/client_spec.rb +874 -232
  34. data/spec/mysql2/error_spec.rb +55 -46
  35. data/spec/mysql2/result_spec.rb +306 -154
  36. data/spec/mysql2/statement_spec.rb +712 -0
  37. data/spec/spec_helper.rb +103 -57
  38. data/spec/ssl/ca-cert.pem +17 -0
  39. data/spec/ssl/ca-key.pem +27 -0
  40. data/spec/ssl/ca.cnf +22 -0
  41. data/spec/ssl/cert.cnf +22 -0
  42. data/spec/ssl/client-cert.pem +17 -0
  43. data/spec/ssl/client-key.pem +27 -0
  44. data/spec/ssl/client-req.pem +15 -0
  45. data/spec/ssl/gen_certs.sh +48 -0
  46. data/spec/ssl/pkcs8-client-key.pem +28 -0
  47. data/spec/ssl/pkcs8-server-key.pem +28 -0
  48. data/spec/ssl/server-cert.pem +17 -0
  49. data/spec/ssl/server-key.pem +27 -0
  50. data/spec/ssl/server-req.pem +15 -0
  51. data/spec/test_data +1 -0
  52. data/support/5072E1F5.asc +432 -0
  53. data/support/libmysql.def +219 -0
  54. data/support/mysql_enc_to_ruby.rb +81 -0
  55. data/support/ruby_enc_to_mysql.rb +61 -0
  56. metadata +82 -188
  57. data/.gitignore +0 -12
  58. data/.rspec +0 -2
  59. data/.rvmrc +0 -1
  60. data/Gemfile +0 -3
  61. data/MIT-LICENSE +0 -20
  62. data/README.rdoc +0 -257
  63. data/Rakefile +0 -5
  64. data/benchmark/active_record.rb +0 -51
  65. data/benchmark/active_record_threaded.rb +0 -42
  66. data/benchmark/allocations.rb +0 -33
  67. data/benchmark/escape.rb +0 -36
  68. data/benchmark/query_with_mysql_casting.rb +0 -80
  69. data/benchmark/query_without_mysql_casting.rb +0 -47
  70. data/benchmark/sequel.rb +0 -37
  71. data/benchmark/setup_db.rb +0 -119
  72. data/benchmark/threaded.rb +0 -44
  73. data/lib/active_record/connection_adapters/em_mysql2_adapter.rb +0 -64
  74. data/lib/active_record/fiber_patches.rb +0 -104
  75. data/lib/mysql2/em_fiber.rb +0 -31
  76. data/mysql2.gemspec +0 -32
  77. data/spec/em/em_fiber_spec.rb +0 -22
  78. data/tasks/benchmarks.rake +0 -20
  79. data/tasks/compile.rake +0 -71
  80. data/tasks/rspec.rake +0 -16
  81. data/tasks/vendor_mysql.rake +0 -40
data/spec/spec_helper.rb CHANGED
@@ -1,66 +1,112 @@
1
- # encoding: UTF-8
2
-
3
1
  require 'rspec'
4
2
  require 'mysql2'
5
3
  require 'timeout'
4
+ require 'yaml'
5
+ DatabaseCredentials = YAML.load_file('spec/configuration.yml')
6
6
 
7
7
  RSpec.configure do |config|
8
+ config.disable_monkey_patching!
9
+
10
+ def with_internal_encoding(encoding)
11
+ old_enc = Encoding.default_internal
12
+ old_verbose = $VERBOSE
13
+ $VERBOSE = nil
14
+ Encoding.default_internal = encoding
15
+ $VERBOSE = old_verbose
16
+
17
+ yield
18
+ ensure
19
+ $VERBOSE = nil
20
+ Encoding.default_internal = old_enc
21
+ $VERBOSE = old_verbose
22
+ end
23
+
24
+ def new_client(option_overrides = {})
25
+ client = Mysql2::Client.new(DatabaseCredentials['root'].merge(option_overrides))
26
+ @clients ||= []
27
+ @clients << client
28
+ return client unless block_given?
29
+ begin
30
+ yield client
31
+ ensure
32
+ client.close
33
+ @clients.delete(client)
34
+ end
35
+ end
36
+
37
+ def num_classes
38
+ # rubocop:disable Lint/UnifiedInteger
39
+ 0.class == Integer ? [Integer] : [Fixnum, Bignum]
40
+ # rubocop:enable Lint/UnifiedInteger
41
+ end
42
+
43
+ config.before :each do
44
+ @client = new_client
45
+ end
46
+
47
+ config.after :each do
48
+ @clients.each(&:close)
49
+ end
50
+
8
51
  config.before(:all) do
9
- client = Mysql2::Client.new :host => "localhost", :username => "root", :database => 'test'
10
- client.query %[
11
- CREATE TABLE IF NOT EXISTS mysql2_test (
12
- id MEDIUMINT NOT NULL AUTO_INCREMENT,
13
- null_test VARCHAR(10),
14
- bit_test BIT(64),
15
- tiny_int_test TINYINT,
16
- bool_cast_test TINYINT(1),
17
- small_int_test SMALLINT,
18
- medium_int_test MEDIUMINT,
19
- int_test INT,
20
- big_int_test BIGINT,
21
- float_test FLOAT(10,3),
22
- float_zero_test FLOAT(10,3),
23
- double_test DOUBLE(10,3),
24
- decimal_test DECIMAL(10,3),
25
- decimal_zero_test DECIMAL(10,3),
26
- date_test DATE,
27
- date_time_test DATETIME,
28
- timestamp_test TIMESTAMP,
29
- time_test TIME,
30
- year_test YEAR(4),
31
- char_test CHAR(10),
32
- varchar_test VARCHAR(10),
33
- binary_test BINARY(10),
34
- varbinary_test VARBINARY(10),
35
- tiny_blob_test TINYBLOB,
36
- tiny_text_test TINYTEXT,
37
- blob_test BLOB,
38
- text_test TEXT,
39
- medium_blob_test MEDIUMBLOB,
40
- medium_text_test MEDIUMTEXT,
41
- long_blob_test LONGBLOB,
42
- long_text_test LONGTEXT,
43
- enum_test ENUM('val1', 'val2'),
44
- set_test SET('val1', 'val2'),
45
- PRIMARY KEY (id)
46
- )
47
- ]
48
- client.query %[
49
- INSERT INTO mysql2_test (
50
- null_test, bit_test, tiny_int_test, bool_cast_test, small_int_test, medium_int_test, int_test, big_int_test,
51
- float_test, float_zero_test, double_test, decimal_test, decimal_zero_test, date_test, date_time_test, timestamp_test, time_test,
52
- year_test, char_test, varchar_test, binary_test, varbinary_test, tiny_blob_test,
53
- tiny_text_test, blob_test, text_test, medium_blob_test, medium_text_test,
54
- long_blob_test, long_text_test, enum_test, set_test
55
- )
52
+ new_client do |client|
53
+ client.query %[
54
+ CREATE TABLE IF NOT EXISTS mysql2_test (
55
+ id MEDIUMINT NOT NULL AUTO_INCREMENT,
56
+ null_test VARCHAR(10),
57
+ bit_test BIT(64),
58
+ single_bit_test BIT(1),
59
+ tiny_int_test TINYINT,
60
+ bool_cast_test TINYINT(1),
61
+ small_int_test SMALLINT,
62
+ medium_int_test MEDIUMINT,
63
+ int_test INT,
64
+ big_int_test BIGINT,
65
+ float_test FLOAT(10,3),
66
+ float_zero_test FLOAT(10,3),
67
+ double_test DOUBLE(10,3),
68
+ decimal_test DECIMAL(10,3),
69
+ decimal_zero_test DECIMAL(10,3),
70
+ date_test DATE,
71
+ date_time_test DATETIME,
72
+ timestamp_test TIMESTAMP,
73
+ time_test TIME,
74
+ year_test YEAR(4),
75
+ char_test CHAR(10),
76
+ varchar_test VARCHAR(10),
77
+ binary_test BINARY(10),
78
+ varbinary_test VARBINARY(10),
79
+ tiny_blob_test TINYBLOB,
80
+ tiny_text_test TINYTEXT,
81
+ blob_test BLOB,
82
+ text_test TEXT,
83
+ medium_blob_test MEDIUMBLOB,
84
+ medium_text_test MEDIUMTEXT,
85
+ long_blob_test LONGBLOB,
86
+ long_text_test LONGTEXT,
87
+ enum_test ENUM('val1', 'val2'),
88
+ set_test SET('val1', 'val2'),
89
+ PRIMARY KEY (id)
90
+ )
91
+ ]
92
+ client.query "DELETE FROM mysql2_test;"
93
+ client.query %[
94
+ INSERT INTO mysql2_test (
95
+ null_test, bit_test, single_bit_test, tiny_int_test, bool_cast_test, small_int_test, medium_int_test, int_test, big_int_test,
96
+ float_test, float_zero_test, double_test, decimal_test, decimal_zero_test, date_test, date_time_test, timestamp_test, time_test,
97
+ year_test, char_test, varchar_test, binary_test, varbinary_test, tiny_blob_test,
98
+ tiny_text_test, blob_test, text_test, medium_blob_test, medium_text_test,
99
+ long_blob_test, long_text_test, enum_test, set_test
100
+ )
56
101
 
57
- VALUES (
58
- NULL, b'101', 1, 1, 10, 10, 10, 10,
59
- 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',
60
- 2009, "test", "test", "test", "test", "test",
61
- "test", "test", "test", "test", "test",
62
- "test", "test", 'val1', 'val1,val2'
63
- )
64
- ]
102
+ VALUES (
103
+ NULL, b'101', b'1', 1, 1, 10, 10, 10, 10,
104
+ 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',
105
+ 2009, "test", "test", "test", "test", "test",
106
+ "test", "test", "test", "test", "test",
107
+ "test", "test", 'val1', 'val1,val2'
108
+ )
109
+ ]
110
+ end
65
111
  end
66
112
  end
@@ -0,0 +1,17 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIICqjCCAZICCQDbDS+Z2mpWkDANBgkqhkiG9w0BAQsFADAXMRUwEwYDVQQDDAxj
3
+ YV9teXNxbDJnZW0wHhcNMTUwOTA5MDQ1NzIxWhcNMjUwNzE4MDQ1NzIxWjAXM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OoREFz2lC
20
+ XIY8ljbLpzG5N0BOu5Q0SkzdnTzdoZGXtm55se+MX2nsu7qERXsqIpl0rIVLUo53
21
+ kZwCABPNSGuCeKwUYNDukAg1AoGBALiHHSqEVKhIOn4FDgqM0uM49CA9t6NPyqI9
22
+ sq6r2GWcgpNPXDLPL3e0KGlK3gBkTLApbULsXt1HVpZT9HlJ+nD/0/UieHS6BUgh
23
+ Txxkrgbe/GQ6vZBuEYJQFBxiQHlm9Fcu/zsOOMvn94W4edD5bkCYmfChtxHAYcKF
24
+ 2cWlnJbNAoGAWMV4GIY2DYlztXdyMVuPwsjPcSPMmL8Nc2ATWYRfcoG0Zl0yvwPh
25
+ 2VOu7Q/7bNF2LOe6lPe1hoeB6rT44IYZaWMo3ikY8xW9RztOLSv8E9uE1K9yq8OA
26
+ P8QzXmr1Lga+hoEmMHc2biEJNeF6iAcAFfrHj9Sr7w5PC8g4A3PlCvU=
27
+ -----END RSA PRIVATE KEY-----
data/spec/ssl/ca.cnf ADDED
@@ -0,0 +1,22 @@
1
+
2
+ [ ca ]
3
+ # January 1, 2015
4
+ default_startdate = 2015010360000Z
5
+
6
+ [ req ]
7
+ distinguished_name = req_distinguished_name
8
+
9
+ [ req_distinguished_name ]
10
+ # If this isn't set, the error is error, no objects specified in config file
11
+ commonName = Common Name (hostname, IP, or your name)
12
+
13
+ countryName_default = US
14
+ stateOrProvinceName_default = CA
15
+ localityName_default = San Francisco
16
+ 0.organizationName_default = mysql2_gem
17
+ organizationalUnitName_default = Mysql2Gem
18
+ emailAddress_default = mysql2gem@example.com
19
+
20
+
21
+ commonName_default = ca_mysql2gem
22
+
data/spec/ssl/cert.cnf ADDED
@@ -0,0 +1,22 @@
1
+
2
+ [ ca ]
3
+ # January 1, 2015
4
+ default_startdate = 2015010360000Z
5
+
6
+ [ req ]
7
+ distinguished_name = req_distinguished_name
8
+
9
+ [ req_distinguished_name ]
10
+ # If this isn't set, the error is error, no objects specified in config file
11
+ commonName = Common Name (hostname, IP, or your name)
12
+
13
+ countryName_default = US
14
+ stateOrProvinceName_default = CA
15
+ localityName_default = San Francisco
16
+ 0.organizationName_default = mysql2_gem
17
+ organizationalUnitName_default = Mysql2Gem
18
+ emailAddress_default = mysql2gem@example.com
19
+
20
+
21
+ commonName_default = mysql2gem.example.com
22
+
@@ -0,0 +1,17 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIICqzCCAZMCAQEwDQYJKoZIhvcNAQELBQAwFzEVMBMGA1UEAwwMY2FfbXlzcWwy
3
+ Z2VtMB4XDTE1MDkwOTA0NTcyMVoXDTI1MDcxODA0NTcyMVowIDEeMBwGA1UEAwwV
4
+ bXlzcWwyZ2VtLmV4YW1wbGUuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB
5
+ CgKCAQEA1ZuBf1FVJqil7/LvnXqPd43ujo0xqbFy7QrqmM5U/UM3ggMCf2Gr2/Wo
6
+ ZJGPTk1NFaiUyM5mhSlgi0/SGPEp9JMUuH+Uiv9UwmOFl9Em3FXQQ8SG7fV7651u
7
+ AUskNgfEqoy+f+uvi1P155rHNDx7Yw6i+wwfpLGTU0boMnLL6cO/KcIbZlx4/2Lq
8
+ r5sYbpIqhz46bbG+fIhvepruH9h7WVWqAibTqymYrA3T03O/HWTOqfq03gM7Oe3t
9
+ JvJbqX2LecQvi2SbQoX8c2MrQ6X7xDe2Ajh7Yx9DQ1gqClTglbPFHNiWPcGACg+W
10
+ 2ptCY/Q2SdP5h1dtj5Sw5VwL3dvCjQIDAQABMA0GCSqGSIb3DQEBCwUAA4IBAQA2
11
+ qTbfgDm0IG8x1qP61ztT9F2WRwG7cp6qHT5oB5wDcOUFes9QJjeB8RoIkB+hRlqG
12
+ J6/Tbxs49d7oKhOQ0UaTnfIKC5m0UFYFGc3lUcwxQyggOWx9XV5ZmGb48+RLFnDV
13
+ Gfcs/hvfem6Xfpgzr8bGs2ZM9x1j9YnXNJVePmKwktjCPnXPOeHyxNZPA+CWHed/
14
+ dNg1IWu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4
+ jo0xqbFy7QrqmM5U/UM3ggMCf2Gr2/WoZJGPTk1NFaiUyM5mhSlgi0/SGPEp9JMU
5
+ uH+Uiv9UwmOFl9Em3FXQQ8SG7fV7651uAUskNgfEqoy+f+uvi1P155rHNDx7Yw6i
6
+ +wwfpLGTU0boMnLL6cO/KcIbZlx4/2Lqr5sYbpIqhz46bbG+fIhvepruH9h7WVWq
7
+ AibTqymYrA3T03O/HWTOqfq03gM7Oe3tJvJbqX2LecQvi2SbQoX8c2MrQ6X7xDe2
8
+ Ajh7Yx9DQ1gqClTglbPFHNiWPcGACg+W2ptCY/Q2SdP5h1dtj5Sw5VwL3dvCjQID
9
+ AQABoAAwDQYJKoZIhvcNAQELBQADggEBAB05YaBSyAKCgHfBWhpZ1+OOVp1anr2v
10
+ TkStnqmNrNM2qBJXjfrythPTX4EJAt7+eNdH/6IVA93qKC/EUQVuMjgfMmMUaM+m
11
+ 5pqfAo95w7vUY147U9nbC+EIo2u1KOVTNTgl45H372/1vCwTHZYu2atCk4tN3ueO
12
+ 0O2XW89Kq94/7PDAExN2PhZdeATVX9dPNT+7ZUDNe8cuq9v0YCHy+2JN2WkplxcG
13
+ kMyCE3YYLnd96YtWiS9DOUib3+b7FwyGe0dXeLVw1br3NZGCZrybyfmnAQfiouAF
14
+ 9nMxKIpWFSx00ubGrUefOQqp6nuk27n+scgr4+d6dBXz9efEEvTbLKA=
15
+ -----END CERTIFICATE REQUEST-----
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -eux
4
+
5
+ echo "
6
+ [ ca ]
7
+ # January 1, 2015
8
+ default_startdate = 2015010360000Z
9
+
10
+ [ req ]
11
+ distinguished_name = req_distinguished_name
12
+
13
+ [ req_distinguished_name ]
14
+ # If this isn't set, the error is "error, no objects specified in config file"
15
+ commonName = Common Name (hostname, IP, or your name)
16
+
17
+ countryName_default = US
18
+ stateOrProvinceName_default = CA
19
+ localityName_default = San Francisco
20
+ 0.organizationName_default = mysql2_gem
21
+ organizationalUnitName_default = Mysql2Gem
22
+ emailAddress_default = mysql2gem@example.com
23
+ " | tee ca.cnf cert.cnf
24
+
25
+ # The client and server certs must have a diferent common name than the CA
26
+ # to avoid "SSL connection error: error:00000001:lib(0):func(0):reason(1)"
27
+
28
+ echo "
29
+ commonName_default = ca_mysql2gem
30
+ " >> ca.cnf
31
+
32
+ echo "
33
+ commonName_default = mysql2gem.example.com
34
+ " >> cert.cnf
35
+
36
+ # Generate a set of certificates
37
+ openssl genrsa -out ca-key.pem 2048
38
+ openssl req -new -x509 -nodes -days 3600 -key ca-key.pem -out ca-cert.pem -batch -config ca.cnf
39
+ openssl req -newkey rsa:2048 -days 3600 -nodes -keyout pkcs8-server-key.pem -out server-req.pem -batch -config cert.cnf
40
+ openssl x509 -req -in server-req.pem -days 3600 -CA ca-cert.pem -CAkey ca-key.pem -set_serial 01 -out server-cert.pem
41
+ openssl req -newkey rsa:2048 -days 3600 -nodes -keyout pkcs8-client-key.pem -out client-req.pem -batch -config cert.cnf
42
+ openssl x509 -req -in client-req.pem -days 3600 -CA ca-cert.pem -CAkey ca-key.pem -set_serial 01 -out client-cert.pem
43
+
44
+ # Convert format from PKCS#8 to PKCS#1
45
+ openssl rsa -in pkcs8-server-key.pem -out server-key.pem
46
+ openssl rsa -in pkcs8-client-key.pem -out client-key.pem
47
+
48
+ echo "done"
@@ -0,0 +1,28 @@
1
+ -----BEGIN PRIVATE KEY-----
2
+ MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDVm4F/UVUmqKXv
3
+ 8u+deo93je6OjTGpsXLtCuqYzlT9QzeCAwJ/Yavb9ahkkY9OTU0VqJTIzmaFKWCL
4
+ T9IY8Sn0kxS4f5SK/1TCY4WX0SbcVdBDxIbt9XvrnW4BSyQ2B8SqjL5/66+LU/Xn
5
+ msc0PHtjDqL7DB+ksZNTRugycsvpw78pwhtmXHj/YuqvmxhukiqHPjptsb58iG96
6
+ mu4f2HtZVaoCJtOrK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