mysql2 0.5.3 → 0.5.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8be4e0f4afbea38c5460544e39c9e0d987dd040c9de5ebdbc4c1e200102ca8e4
4
- data.tar.gz: 996e05358297b03bf8f06abffd37d83a590912246ec607d2c3ee53b325c43022
3
+ metadata.gz: d8e25b1a25080490b1bf04829d8f6616609391a094baa783d7da242342a4ff3b
4
+ data.tar.gz: 7dfab0d03b289b665807d21b29326b96711e5c1d3ae697e81f0e4ab7a5dd6280
5
5
  SHA512:
6
- metadata.gz: daf37441bcb29366453963529b5a144df0d599b79b7a0b9d90b2ae5ed3dee97c1945a58111d6fe6bc2f1c20f75c9960c3cc1cd988a0e5d1be5ce44b7dcdf3633
7
- data.tar.gz: 421df08c45f4257c2f04f3dc0a0e1c1557c695598c4e1a80236d618d1a79510459b8919b753ad9af2d46d21fa19ba060d5b53da2f54a00ff90ca45a4534c9108
6
+ metadata.gz: 3709403d316832055596c96af2e260e3de9d181ba558f551f0d5fe0d89abfec0ea242f6c30228eac02284e1e7287cbd315933fadc517fab88a10d588c4f0d8b6
7
+ data.tar.gz: 63c17fa1c273cefa454ea7f6cc0860014514e4c899ceb1bd856271cd238938a4d0fb263118eb64dde0a9568905d6410110fbe3b8359bff3fab8314607de6dd50
data/README.md CHANGED
@@ -1,7 +1,12 @@
1
1
  # Mysql2 - A modern, simple and very fast MySQL library for Ruby - binding to libmysql
2
2
 
3
- Travis CI [![Travis CI Status](https://travis-ci.org/brianmario/mysql2.png)](https://travis-ci.org/brianmario/mysql2)
4
- Appveyor CI [![Appveyor CI Status](https://ci.appveyor.com/api/projects/status/github/sodabrew/mysql2)](https://ci.appveyor.com/project/sodabrew/mysql2)
3
+ GitHub Actions
4
+ [![GitHub Actions Status: Build](https://github.com/brianmario/mysql2/actions/workflows/build.yml/badge.svg)](https://github.com/brianmario/mysql2/actions/workflows/build.yml)
5
+ [![GitHub Actions Status: Container](https://github.com/brianmario/mysql2/actions/workflows/container.yml/badge.svg)](https://github.com/brianmario/mysql2/actions/workflows/container.yml)
6
+ Travis CI
7
+ [![Travis CI Status](https://travis-ci.org/brianmario/mysql2.png)](https://travis-ci.org/brianmario/mysql2)
8
+ Appveyor CI
9
+ [![Appveyor CI Status](https://ci.appveyor.com/api/projects/status/github/sodabrew/mysql2)](https://ci.appveyor.com/project/sodabrew/mysql2)
5
10
 
6
11
  The Mysql2 gem is meant to serve the extremely common use-case of connecting, querying and iterating on results.
7
12
  Some database libraries out there serve as direct 1:1 mappings of the already complex C APIs available.
@@ -60,6 +65,11 @@ This may be needed if you deploy to a system where these libraries
60
65
  are located somewhere different than on your build system.
61
66
  This overrides any rpath calculated by default or by the options above.
62
67
 
68
+ * `--with-openssl-dir[=/path/to/openssl]` - Specify the directory where OpenSSL
69
+ is installed. In most cases, the Ruby runtime and MySQL client libraries will
70
+ link against a system-installed OpenSSL library and this option is not needed.
71
+ Use this option when non-default library paths are needed.
72
+
63
73
  * `--with-sanitize[=address,cfi,integer,memory,thread,undefined]` -
64
74
  Enable sanitizers for Clang / GCC. If no argument is given, try to enable
65
75
  all sanitizers or fail if none are available. If a command-separated list of
@@ -84,13 +94,48 @@ the library file `libmysqlclient.so` but is missing the header file `mysql.h`
84
94
 
85
95
  ### Mac OS X
86
96
 
87
- You may use MacPorts, Homebrew, or a native MySQL installer package. The most
97
+ You may use Homebrew, MacPorts, or a native MySQL installer package. The most
88
98
  common paths will be automatically searched. If you want to select a specific
89
99
  MySQL directory, use the `--with-mysql-dir` or `--with-mysql-config` options above.
90
100
 
91
101
  If you have not done so already, you will need to install the XCode select tools by running
92
102
  `xcode-select --install`.
93
103
 
104
+ Later versions of MacOS no longer distribute a linkable OpenSSL library. It is
105
+ common to use Homebrew or MacPorts to install OpenSSL. Make sure that both the
106
+ Ruby runtime and MySQL client libraries are compiled with the same OpenSSL
107
+ family, 1.0 or 1.1 or 3.0, since only one can be loaded at runtime.
108
+
109
+ ``` sh
110
+ $ brew install openssl@1.1
111
+ $ gem install mysql2 -- --with-openssl-dir=$(brew --prefix openssl@1.1)
112
+
113
+ or
114
+
115
+ $ sudo port install openssl11
116
+ ```
117
+
118
+ Since most Ruby projects use Bundler, you can set build options in the Bundler
119
+ config rather than manually installing a global mysql2 gem. This example shows
120
+ how to set build arguments with [Bundler config](https://bundler.io/man/bundle-config.1.html):
121
+
122
+ ``` sh
123
+ $ bundle config --local build.mysql2 -- --with-openssl-dir=$(brew --prefix openssl@1.1)
124
+ ```
125
+
126
+ Another helpful trick is to use the same OpenSSL library that your Ruby was
127
+ built with, if it was built with an alternate OpenSSL path. This example finds
128
+ the argument `--with-openssl-dir=/some/path` from the Ruby build and adds that
129
+ to the [Bundler config](https://bundler.io/man/bundle-config.1.html):
130
+
131
+ ``` sh
132
+ $ bundle config --local build.mysql2 -- $(ruby -r rbconfig -e 'puts RbConfig::CONFIG["configure_args"]' | xargs -n1 | grep with-openssl-dir)
133
+ ```
134
+
135
+ Note the additional double dashes (`--`) these separate command-line arguments
136
+ that `gem` or `bundler` interpret from the addiitonal arguments that are passed
137
+ to the mysql2 build process.
138
+
94
139
  ### Windows
95
140
 
96
141
  Make sure that you have Ruby and the DevKit compilers installed. We recommend
@@ -143,7 +188,7 @@ results.each do |row|
143
188
  # the keys are the fields, as you'd expect
144
189
  # the values are pre-built ruby primitives mapped from their corresponding field types in MySQL
145
190
  puts row["id"] # row["id"].is_a? Integer
146
- if row["dne"] # non-existant hash entry is nil
191
+ if row["dne"] # non-existent hash entry is nil
147
192
  puts row["dne"]
148
193
  end
149
194
  end
@@ -165,11 +210,12 @@ client.query("SELECT * FROM users WHERE group='githubbers'", :symbolize_keys =>
165
210
  end
166
211
  ```
167
212
 
168
- You can get the headers and the columns in the order that they were returned
213
+ You can get the headers, columns, and the field types in the order that they were returned
169
214
  by the query like this:
170
215
 
171
216
  ``` ruby
172
217
  headers = results.fields # <= that's an array of field names, in order
218
+ types = results.field_types # <= that's an array of field types, in order
173
219
  results.each(:as => :array) do |row|
174
220
  # Each row is an array, ordered the same as the query results
175
221
  # An otter's den is called a "holt" or "couch"
@@ -197,6 +243,23 @@ statement = @client.prepare("SELECT * FROM users WHERE last_login >= ? AND locat
197
243
  result = statement.execute(1, "CA", :as => :array)
198
244
  ```
199
245
 
246
+ Session Tracking information can be accessed with
247
+
248
+ ``` ruby
249
+ c = Mysql2::Client.new(
250
+ host: "127.0.0.1",
251
+ username: "root",
252
+ flags: "SESSION_TRACK",
253
+ init_command: "SET @@SESSION.session_track_schema=ON"
254
+ )
255
+ c.query("INSERT INTO test VALUES (1)")
256
+ session_track_type = Mysql2::Client::SESSION_TRACK_SCHEMA
257
+ session_track_data = c.session_track(session_track_type)
258
+ ```
259
+
260
+ The types of session track types can be found at
261
+ [https://dev.mysql.com/doc/refman/5.7/en/session-state-tracking.html](https://dev.mysql.com/doc/refman/5.7/en/session-state-tracking.html)
262
+
200
263
  ## Connection options
201
264
 
202
265
  You may set the following connection options in Mysql2::Client.new(...):
@@ -218,7 +281,6 @@ Mysql2::Client.new(
218
281
  :reconnect = true/false,
219
282
  :local_infile = true/false,
220
283
  :secure_auth = true/false,
221
- :ssl_mode = :disabled / :preferred / :required / :verify_ca / :verify_identity,
222
284
  :default_file = '/path/to/my.cfg',
223
285
  :default_group = 'my.cfg section',
224
286
  :default_auth = 'authentication_windows_client'
@@ -239,14 +301,13 @@ type of connection to make, with special interpretation you should be aware of:
239
301
  * An IPv4 or IPv6 address will result in a TCP connection.
240
302
  * Any other value will be looked up as a hostname for a TCP connection.
241
303
 
242
- ### SSL options
304
+ ### SSL/TLS options
243
305
 
244
- Setting any of the following options will enable an SSL connection, but only if
245
- your MySQL client library and server have been compiled with SSL support.
246
- MySQL client library defaults will be used for any parameters that are left out
247
- or set to nil. Relative paths are allowed, and may be required by managed
248
- hosting providers such as Heroku. Set `:sslverify => true` to require that the
249
- server presents a valid certificate.
306
+ Setting any of the following options will enable an SSL/TLS connection, but
307
+ only if your MySQL client library and server have been compiled with SSL
308
+ support. MySQL client library defaults will be used for any parameters that are
309
+ left out or set to nil. Relative paths are allowed, and may be required by
310
+ managed hosting providers such as Heroku.
250
311
 
251
312
  ``` ruby
252
313
  Mysql2::Client.new(
@@ -256,13 +317,32 @@ Mysql2::Client.new(
256
317
  :sslca => '/path/to/ca-cert.pem',
257
318
  :sslcapath => '/path/to/cacerts',
258
319
  :sslcipher => 'DHE-RSA-AES256-SHA',
259
- :sslverify => true,
320
+ :sslverify => true, # Removed in MySQL 8.0
321
+ :ssl_mode => :disabled / :preferred / :required / :verify_ca / :verify_identity,
260
322
  )
261
323
  ```
262
324
 
325
+ For MySQL versions 5.7.11 and higher, use `:ssl_mode` to prefer or require an
326
+ SSL connection and certificate validation. For earlier versions of MySQL, use
327
+ the `:sslverify` boolean. For details on each of the `:ssl_mode` options, see
328
+ [https://dev.mysql.com/doc/refman/8.0/en/connection-options.html](https://dev.mysql.com/doc/refman/8.0/en/connection-options.html#option_general_ssl-mode).
329
+
330
+ The `:ssl_mode` option will also set the appropriate MariaDB connection flags:
331
+
332
+ | `:ssl_mode` | MariaDB option value |
333
+ | --- | --- |
334
+ | `:disabled` | MYSQL_OPT_SSL_ENFORCE = 0 |
335
+ | `:required` | MYSQL_OPT_SSL_ENFORCE = 1 |
336
+ | `:verify_identity` | MYSQL_OPT_SSL_VERIFY_SERVER_CERT = 1 |
337
+
338
+ MariaDB does not support the `:preferred` or `:verify_ca` options. For more
339
+ information about SSL/TLS in MariaDB, see
340
+ [https://mariadb.com/kb/en/securing-connections-for-client-and-server/](https://mariadb.com/kb/en/securing-connections-for-client-and-server/)
341
+ and [https://mariadb.com/kb/en/mysql_optionsv/#tls-options](https://mariadb.com/kb/en/mysql_optionsv/#tls-options)
342
+
263
343
  ### Secure auth
264
344
 
265
- Starting wih MySQL 5.6.5, secure_auth is enabled by default on servers (it was disabled by default prior to this).
345
+ Starting with MySQL 5.6.5, secure_auth is enabled by default on servers (it was disabled by default prior to this).
266
346
  When secure_auth is enabled, the server will refuse a connection if the account password is stored in old pre-MySQL 4.1 format.
267
347
  The MySQL 5.6.5 client library may also refuse to attempt a connection if provided an older format password.
268
348
  To bypass this restriction in the client, pass the option `:secure_auth => false` to Mysql2::Client.new().
@@ -299,12 +379,14 @@ development:
299
379
  secure_auth: false
300
380
  ```
301
381
 
382
+ In this example, the compression flag is negated with `-COMPRESS`.
383
+
302
384
  ### Using Active Record's DATABASE_URL
303
385
 
304
386
  Active Record typically reads its configuration from a file named `database.yml` or an environment variable `DATABASE_URL`.
305
387
  Use the value `mysql2` as the protocol name. For example:
306
388
 
307
- ``` shell
389
+ ``` sh
308
390
  DATABASE_URL=mysql2://sql_user:sql_pass@sql_host_name:port/sql_db_name?option1=value1&option2=value2
309
391
  ```
310
392
 
@@ -363,7 +445,7 @@ end
363
445
 
364
446
  Yields:
365
447
 
366
- ```ruby
448
+ ``` ruby
367
449
  {"1"=>1}
368
450
  {"2"=>2}
369
451
  next_result: Unknown column 'A' in 'field list' (Mysql2::Error)
@@ -423,7 +505,7 @@ Pass the `:as => :array` option to any of the above methods of configuration
423
505
 
424
506
  ### Array of Hashes
425
507
 
426
- The default result type is set to :hash, but you can override a previous setting to something else with :as => :hash
508
+ The default result type is set to `:hash`, but you can override a previous setting to something else with `:as => :hash`
427
509
 
428
510
  ### Timezones
429
511
 
@@ -543,18 +625,20 @@ As for field values themselves, I'm workin on it - but expect that soon.
543
625
 
544
626
  This gem is tested with the following Ruby versions on Linux and Mac OS X:
545
627
 
546
- * Ruby MRI 2.0.0, 2.1.x, 2.2.x, 2.3.x, 2.4.x, 2.5.x, 2.6.x
628
+ * Ruby MRI 2.0 through 2.7 (all versions to date)
629
+ * Ruby MRI 3.0, 3.1, 3.2 (all versions to date)
547
630
  * Rubinius 2.x and 3.x do work but may fail under some workloads
548
631
 
549
632
  This gem is tested with the following MySQL and MariaDB versions:
550
633
 
551
634
  * MySQL 5.5, 5.6, 5.7, 8.0
552
- * MySQL Connector/C 6.0 and 6.1 (primarily on Windows)
553
- * MariaDB 5.5, 10.0, 10.1, 10.2, 10.3
635
+ * MySQL Connector/C 6.0, 6.1, 8.0 (primarily on Windows)
636
+ * MariaDB 5.5, 10.x, with a focus on 10.6 LTS and 10.11 LTS
637
+ * MariaDB Connector/C 2.x, 3.x
554
638
 
555
639
  ### Ruby on Rails / Active Record
556
640
 
557
- * mysql2 0.5.x works with Rails / Active Record 5.0.7, 5.1.6, and higher.
641
+ * mysql2 0.5.x works with Rails / Active Record 4.2.11, 5.0.7, 5.1.6, and higher.
558
642
  * mysql2 0.4.x works with Rails / Active Record 4.2.5 - 5.0 and higher.
559
643
  * mysql2 0.3.x works with Rails / Active Record 3.1, 3.2, 4.x, 5.0.
560
644
  * mysql2 0.2.x works with Rails / Active Record 2.3 - 3.0.
@@ -648,3 +732,4 @@ though.
648
732
  * [John Cant](http://github.com/johncant) - polishing and updating Prepared Statements support
649
733
  * [Justin Case](http://github.com/justincase) - polishing and updating Prepared Statements support and getting it merged
650
734
  * [Tamir Duberstein](http://github.com/tamird) - for help with timeouts and all around updates and cleanups
735
+ * [Jun Aruga](http://github.com/junaruga) - for migrating CI tests to GitHub Actions and other improvements