ruby-mysql 2.9.10 → 2.9.11
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of ruby-mysql might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/lib/mysql.rb +4 -3
- data/lib/mysql/charset.rb +1 -0
- data/lib/mysql/constants.rb +1 -0
- data/lib/mysql/error.rb +873 -706
- data/lib/mysql/packet.rb +1 -0
- data/lib/mysql/protocol.rb +12 -9
- data/spec/mysql_spec.rb +20 -9
- metadata +7 -9
data/lib/mysql/packet.rb
CHANGED
data/lib/mysql/protocol.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# coding: ascii-8bit
|
1
2
|
# Copyright (C) 2008-2012 TOMITA Masahiro
|
2
3
|
# mailto:tommy@tmtm.org
|
3
4
|
|
@@ -282,16 +283,16 @@ class Mysql
|
|
282
283
|
|
283
284
|
# Retrieve all records for simple query
|
284
285
|
# === Argument
|
285
|
-
#
|
286
|
+
# fields :: [Array<Mysql::Field>] number of fields
|
286
287
|
# === Return
|
287
288
|
# [Array of Array of String] all records
|
288
|
-
def retr_all_records(
|
289
|
+
def retr_all_records(fields)
|
289
290
|
check_state :RESULT
|
290
291
|
enc = charset.encoding
|
291
292
|
begin
|
292
293
|
all_recs = []
|
293
294
|
until (pkt = read).eof?
|
294
|
-
all_recs.push RawRecord.new(pkt,
|
295
|
+
all_recs.push RawRecord.new(pkt, fields, enc)
|
295
296
|
end
|
296
297
|
pkt.read(3)
|
297
298
|
@server_status = pkt.utiny
|
@@ -501,7 +502,7 @@ class Mysql
|
|
501
502
|
raise EOFError unless ret && ret.length == len
|
502
503
|
end
|
503
504
|
rescue EOFError
|
504
|
-
raise ClientError::ServerGoneError, '
|
505
|
+
raise ClientError::ServerGoneError, 'MySQL server has gone away'
|
505
506
|
rescue Timeout::Error
|
506
507
|
raise ClientError, "read timeout"
|
507
508
|
end while len == MAX_PACKET_LENGTH
|
@@ -549,7 +550,7 @@ class Mysql
|
|
549
550
|
@sock.flush
|
550
551
|
end
|
551
552
|
rescue Errno::EPIPE
|
552
|
-
raise ClientError::ServerGoneError, '
|
553
|
+
raise ClientError::ServerGoneError, 'MySQL server has gone away'
|
553
554
|
rescue Timeout::Error
|
554
555
|
raise ClientError, "write timeout"
|
555
556
|
end
|
@@ -730,14 +731,16 @@ class Mysql
|
|
730
731
|
end
|
731
732
|
|
732
733
|
class RawRecord
|
733
|
-
def initialize(packet,
|
734
|
-
@packet, @
|
734
|
+
def initialize(packet, fields, encoding)
|
735
|
+
@packet, @fields, @encoding = packet, fields, encoding
|
735
736
|
end
|
736
737
|
|
737
738
|
def to_a
|
738
|
-
@
|
739
|
+
@fields.map do |f|
|
739
740
|
if s = @packet.lcs
|
740
|
-
|
741
|
+
unless f.type == Field::TYPE_BIT or f.charsetnr == Charset::BINARY_CHARSET_NUMBER
|
742
|
+
s = Charset.convert_encoding(s, @encoding)
|
743
|
+
end
|
741
744
|
end
|
742
745
|
s
|
743
746
|
end
|
data/spec/mysql_spec.rb
CHANGED
@@ -13,7 +13,7 @@ MYSQL_SOCKET = ENV['MYSQL_SOCKET']
|
|
13
13
|
|
14
14
|
describe 'Mysql::VERSION' do
|
15
15
|
it 'returns client version' do
|
16
|
-
Mysql::VERSION.should ==
|
16
|
+
Mysql::VERSION.should == 20911
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -338,13 +338,14 @@ describe 'Mysql' do
|
|
338
338
|
end
|
339
339
|
|
340
340
|
describe '#kill' do
|
341
|
-
|
342
|
-
@
|
341
|
+
before do
|
342
|
+
@m2 = Mysql.new(MYSQL_SERVER, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE, MYSQL_PORT, MYSQL_SOCKET)
|
343
343
|
end
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
344
|
+
after do
|
345
|
+
@m2.close rescue nil
|
346
|
+
end
|
347
|
+
it 'returns self' do
|
348
|
+
@m.kill(@m2.thread_id).should == @m
|
348
349
|
end
|
349
350
|
end
|
350
351
|
|
@@ -1719,11 +1720,21 @@ if defined? Encoding
|
|
1719
1720
|
|
1720
1721
|
describe 'default_internal is CP932' do
|
1721
1722
|
before do
|
1723
|
+
@m.prepare("insert into t (utf8,cp932,eucjp,bin) values (?,?,?,?)").execute @utf8, @cp932, @eucjp, @bin
|
1722
1724
|
Encoding.default_internal = 'CP932'
|
1723
1725
|
end
|
1724
1726
|
it 'is converted to CP932' do
|
1725
1727
|
@m.query('select "あいう"').fetch.should == ["\x82\xA0\x82\xA2\x82\xA4".force_encoding("CP932")]
|
1726
1728
|
end
|
1729
|
+
it 'data is stored as is' do
|
1730
|
+
@m.query('select hex(utf8),hex(cp932),hex(eucjp),hex(bin) from t').fetch.should == ['E38184E3828DE381AF', '82A282EB82CD', 'A4A4A4EDA4CF', '00017F80FEFF']
|
1731
|
+
end
|
1732
|
+
it 'By simple query, charset of retrieved data is connection charset' do
|
1733
|
+
@m.query('select utf8,cp932,eucjp,bin from t').fetch.should == [@cp932, @cp932, @cp932, @bin]
|
1734
|
+
end
|
1735
|
+
it 'By prepared statement, charset of retrieved data is connection charset except for binary' do
|
1736
|
+
@m.prepare('select utf8,cp932,eucjp,bin from t').execute.fetch.should == [@cp932, @cp932, @cp932, @bin]
|
1737
|
+
end
|
1727
1738
|
end
|
1728
1739
|
|
1729
1740
|
describe 'query with CP932 encoding' do
|
@@ -1746,7 +1757,7 @@ if defined? Encoding
|
|
1746
1757
|
@m.query('select hex(utf8),hex(cp932),hex(eucjp),hex(bin) from t').fetch.should == ['E38184E3828DE381AF', '82A282EB82CD', 'A4A4A4EDA4CF', '00017F80FEFF']
|
1747
1758
|
end
|
1748
1759
|
it 'By simple query, charset of retrieved data is connection charset' do
|
1749
|
-
@m.query('select utf8,cp932,eucjp,bin from t').fetch.should == [@utf8, @utf8, @utf8, @bin
|
1760
|
+
@m.query('select utf8,cp932,eucjp,bin from t').fetch.should == [@utf8, @utf8, @utf8, @bin]
|
1750
1761
|
end
|
1751
1762
|
it 'By prepared statement, charset of retrieved data is connection charset except for binary' do
|
1752
1763
|
@m.prepare('select utf8,cp932,eucjp,bin from t').execute.fetch.should == [@utf8, @utf8, @utf8, @bin]
|
@@ -1761,7 +1772,7 @@ if defined? Encoding
|
|
1761
1772
|
@m.query("select hex(utf8),hex(cp932),hex(eucjp),hex(bin) from t").fetch.should == ["E38184E3828DE381AF", "82A282EB82CD", "A4A4A4EDA4CF", "E38184E3828DE381AF"]
|
1762
1773
|
end
|
1763
1774
|
it 'By simple query, charset of retrieved data is connection charset' do
|
1764
|
-
@m.query("select utf8,cp932,eucjp,bin from t").fetch.should == [@utf8, @utf8, @utf8, @utf8]
|
1775
|
+
@m.query("select utf8,cp932,eucjp,bin from t").fetch.should == [@utf8, @utf8, @utf8, @utf8.dup.force_encoding('ASCII-8BIT')]
|
1765
1776
|
end
|
1766
1777
|
it 'By prepared statement, charset of retrieved data is connection charset except for binary' do
|
1767
1778
|
@m.prepare("select utf8,cp932,eucjp,bin from t").execute.fetch.should == [@utf8, @utf8, @utf8, @utf8.dup.force_encoding("ASCII-8BIT")]
|
metadata
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-mysql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.9.
|
5
|
-
prerelease:
|
4
|
+
version: 2.9.11
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Tomita Masahiro
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2013-04-09 00:00:00.000000000 Z
|
13
12
|
dependencies: []
|
14
13
|
description: This is MySQL connector. pure Ruby version
|
15
14
|
email: tommy@tmtm.org
|
@@ -30,27 +29,26 @@ files:
|
|
30
29
|
homepage: http://github.com/tmtm/ruby-mysql
|
31
30
|
licenses:
|
32
31
|
- Ruby's
|
32
|
+
metadata: {}
|
33
33
|
post_install_message:
|
34
34
|
rdoc_options: []
|
35
35
|
require_paths:
|
36
36
|
- lib
|
37
37
|
required_ruby_version: !ruby/object:Gem::Requirement
|
38
|
-
none: false
|
39
38
|
requirements:
|
40
|
-
- -
|
39
|
+
- - '>='
|
41
40
|
- !ruby/object:Gem::Version
|
42
41
|
version: '0'
|
43
42
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
44
|
-
none: false
|
45
43
|
requirements:
|
46
|
-
- -
|
44
|
+
- - '>='
|
47
45
|
- !ruby/object:Gem::Version
|
48
46
|
version: '0'
|
49
47
|
requirements: []
|
50
48
|
rubyforge_project:
|
51
|
-
rubygems_version:
|
49
|
+
rubygems_version: 2.0.0
|
52
50
|
signing_key:
|
53
|
-
specification_version:
|
51
|
+
specification_version: 4
|
54
52
|
summary: MySQL connector
|
55
53
|
test_files:
|
56
54
|
- spec/mysql_spec.rb
|