mysql2 0.2.1 → 0.2.2
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.
- data/CHANGELOG.md +6 -0
- data/VERSION +1 -1
- data/ext/mysql2/client.c +8 -7
- data/lib/active_record/connection_adapters/mysql2_adapter.rb +5 -3
- data/lib/mysql2.rb +1 -1
- data/mysql2.gemspec +2 -2
- data/spec/mysql2/client_spec.rb +27 -0
- metadata +4 -4
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
# 0.2.2 (August 19th, 2010)
|
4
|
+
* Change how AR adapter would send initial commands upon connecting
|
5
|
+
** we can make multiple session variable assignments in a single query
|
6
|
+
* fix signal handling when waiting on queries
|
7
|
+
* retry connect if interrupted by signals
|
8
|
+
|
3
9
|
## 0.2.1 (August 16th, 2010)
|
4
10
|
* bring mysql2 ActiveRecord adapter back into gem
|
5
11
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.2
|
data/ext/mysql2/client.c
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
#include <mysql2_ext.h>
|
2
2
|
#include <client.h>
|
3
|
+
#include <errno.h>
|
3
4
|
|
4
5
|
VALUE cMysql2Client;
|
5
6
|
extern VALUE mMysql2, cMysql2Error;
|
@@ -96,10 +97,12 @@ static VALUE nogvl_connect(void *ptr) {
|
|
96
97
|
struct nogvl_connect_args *args = ptr;
|
97
98
|
MYSQL *client;
|
98
99
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
100
|
+
do {
|
101
|
+
client = mysql_real_connect(args->mysql, args->host,
|
102
|
+
args->user, args->passwd,
|
103
|
+
args->db, args->port, args->unix_socket,
|
104
|
+
args->client_flag);
|
105
|
+
} while (! client && errno == EINTR && (errno = 0) == 0);
|
103
106
|
|
104
107
|
return client ? Qtrue : Qfalse;
|
105
108
|
}
|
@@ -257,7 +260,6 @@ static VALUE rb_mysql_client_query(int argc, VALUE * argv, VALUE self) {
|
|
257
260
|
int fd, retval;
|
258
261
|
int async = 0;
|
259
262
|
VALUE opts, defaults;
|
260
|
-
int(*selector)(int, fd_set *, fd_set *, fd_set *, struct timeval *) = NULL;
|
261
263
|
GET_CLIENT(self)
|
262
264
|
|
263
265
|
REQUIRE_OPEN_DB(client);
|
@@ -299,12 +301,11 @@ static VALUE rb_mysql_client_query(int argc, VALUE * argv, VALUE self) {
|
|
299
301
|
// the below code is largely from do_mysql
|
300
302
|
// http://github.com/datamapper/do
|
301
303
|
fd = client->net.fd;
|
302
|
-
selector = rb_thread_alone() ? *select : *rb_thread_select;
|
303
304
|
for(;;) {
|
304
305
|
FD_ZERO(&fdset);
|
305
306
|
FD_SET(fd, &fdset);
|
306
307
|
|
307
|
-
retval =
|
308
|
+
retval = rb_thread_select(fd + 1, &fdset, NULL, NULL, NULL);
|
308
309
|
|
309
310
|
if (retval < 0) {
|
310
311
|
rb_sys_fail(0);
|
@@ -606,12 +606,14 @@ module ActiveRecord
|
|
606
606
|
|
607
607
|
def configure_connection
|
608
608
|
@connection.query_options.merge!(:as => :array)
|
609
|
-
encoding = @config[:encoding]
|
610
|
-
execute("SET NAMES '#{encoding}'", :skip_logging) if encoding
|
611
609
|
|
612
610
|
# By default, MySQL 'where id is null' selects the last inserted id.
|
613
611
|
# Turn this off. http://dev.rubyonrails.org/ticket/6778
|
614
|
-
|
612
|
+
variable_assignments = ['SQL_AUTO_IS_NULL=0']
|
613
|
+
encoding = @config[:encoding]
|
614
|
+
variable_assignments << "NAMES '#{encoding}'" if encoding
|
615
|
+
|
616
|
+
execute("SET #{variable_assignments.join(', ')}", :skip_logging)
|
615
617
|
end
|
616
618
|
|
617
619
|
# Returns an array of record hashes with the column names as keys and
|
data/lib/mysql2.rb
CHANGED
data/mysql2.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{mysql2}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Brian Lopez"]
|
12
|
-
s.date = %q{2010-08-
|
12
|
+
s.date = %q{2010-08-19}
|
13
13
|
s.email = %q{seniorlopez@gmail.com}
|
14
14
|
s.extensions = ["ext/mysql2/extconf.rb"]
|
15
15
|
s.extra_rdoc_files = [
|
data/spec/mysql2/client_spec.rb
CHANGED
@@ -78,6 +78,33 @@ describe Mysql2::Client do
|
|
78
78
|
@client.query("SELECT 1")
|
79
79
|
}.should raise_error(Mysql2::Error)
|
80
80
|
end
|
81
|
+
|
82
|
+
# XXX this test is not deterministic (because Unix signal handling is not)
|
83
|
+
# and may fail on a loaded system
|
84
|
+
it "should run signal handlers while waiting for a response" do
|
85
|
+
mark = {}
|
86
|
+
trap(:USR1) { mark[:USR1] = Time.now }
|
87
|
+
begin
|
88
|
+
mark[:START] = Time.now
|
89
|
+
pid = fork do
|
90
|
+
sleep 1 # wait for client "SELECT sleep(2)" query to start
|
91
|
+
Process.kill(:USR1, Process.ppid)
|
92
|
+
sleep # wait for explicit kill to prevent GC disconnect
|
93
|
+
end
|
94
|
+
@client.query("SELECT sleep(2)")
|
95
|
+
mark[:END] = Time.now
|
96
|
+
mark.include?(:USR1).should be_true
|
97
|
+
(mark[:USR1] - mark[:START]).should >= 1
|
98
|
+
(mark[:USR1] - mark[:START]).should < 1.1
|
99
|
+
(mark[:END] - mark[:USR1]).should > 0.9
|
100
|
+
(mark[:END] - mark[:START]).should >= 2
|
101
|
+
(mark[:END] - mark[:START]).should < 2.1
|
102
|
+
Process.kill(:TERM, pid)
|
103
|
+
Process.waitpid2(pid)
|
104
|
+
ensure
|
105
|
+
trap(:USR1, 'DEFAULT')
|
106
|
+
end
|
107
|
+
end if RUBY_PLATFORM !~ /mingw|mswin/
|
81
108
|
end
|
82
109
|
|
83
110
|
it "should respond to #escape" do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mysql2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 2
|
10
|
+
version: 0.2.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Brian Lopez
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-08-
|
18
|
+
date: 2010-08-19 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|