mysql-pr 2.9.11 → 3.0.1
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.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +84 -0
- data/CHANGELOG.md +55 -0
- data/LICENSE +83 -0
- data/README.md +199 -0
- data/Rakefile +10 -0
- data/docker-compose.yml +25 -0
- data/lib/mysql-pr/charset.rb +185 -216
- data/lib/mysql-pr/constants.rb +9 -5
- data/lib/mysql-pr/error.rb +12 -10
- data/lib/mysql-pr/packet.rb +27 -20
- data/lib/mysql-pr/protocol.rb +410 -174
- data/lib/mysql-pr/version.rb +5 -0
- data/lib/mysql-pr.rb +350 -308
- data/mysql-pr.gemspec +35 -0
- metadata +88 -28
- data/README.rdoc +0 -60
- data/spec/mysql/packet_spec.rb +0 -118
- data/spec/mysql_spec.rb +0 -1701
data/mysql-pr.gemspec
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "lib/mysql-pr/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = "mysql-pr"
|
|
7
|
+
spec.version = MysqlPR::VERSION
|
|
8
|
+
spec.authors = ["Tomita Masahiro", "Alex Jokela"]
|
|
9
|
+
spec.email = ["tommy@tmtm.org", "alex@camulus.com"]
|
|
10
|
+
|
|
11
|
+
spec.summary = "Pure Ruby MySQL connector"
|
|
12
|
+
spec.description = "A pure Ruby MySQL client library. No native extensions required."
|
|
13
|
+
spec.homepage = "https://github.com/ajokela/mysql-pr"
|
|
14
|
+
spec.license = "Ruby"
|
|
15
|
+
spec.required_ruby_version = ">= 3.0.0"
|
|
16
|
+
|
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
|
18
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
|
19
|
+
spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/main/CHANGELOG.md"
|
|
20
|
+
|
|
21
|
+
spec.files = Dir.chdir(__dir__) do
|
|
22
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
|
23
|
+
(File.expand_path(f) == __FILE__) ||
|
|
24
|
+
f.start_with?(*%w[bin/ test/ spec/ features/ .git .github appveyor Gemfile])
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
spec.bindir = "exe"
|
|
28
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
|
29
|
+
spec.require_paths = ["lib"]
|
|
30
|
+
|
|
31
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
|
32
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
|
33
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
|
34
|
+
spec.add_development_dependency "rubocop", "~> 1.0"
|
|
35
|
+
end
|
metadata
CHANGED
|
@@ -1,59 +1,119 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mysql-pr
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
|
|
5
|
-
version: 2.9.11
|
|
4
|
+
version: 3.0.1
|
|
6
5
|
platform: ruby
|
|
7
6
|
authors:
|
|
8
7
|
- Tomita Masahiro
|
|
9
8
|
- Alex Jokela
|
|
10
9
|
autorequire:
|
|
11
|
-
bindir:
|
|
10
|
+
bindir: exe
|
|
12
11
|
cert_chain: []
|
|
13
|
-
date:
|
|
14
|
-
dependencies:
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
date: 2025-11-25 00:00:00.000000000 Z
|
|
13
|
+
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
15
|
+
name: bundler
|
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
|
17
|
+
requirements:
|
|
18
|
+
- - "~>"
|
|
19
|
+
- !ruby/object:Gem::Version
|
|
20
|
+
version: '2.0'
|
|
21
|
+
type: :development
|
|
22
|
+
prerelease: false
|
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
24
|
+
requirements:
|
|
25
|
+
- - "~>"
|
|
26
|
+
- !ruby/object:Gem::Version
|
|
27
|
+
version: '2.0'
|
|
28
|
+
- !ruby/object:Gem::Dependency
|
|
29
|
+
name: rake
|
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
|
31
|
+
requirements:
|
|
32
|
+
- - "~>"
|
|
33
|
+
- !ruby/object:Gem::Version
|
|
34
|
+
version: '13.0'
|
|
35
|
+
type: :development
|
|
36
|
+
prerelease: false
|
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
38
|
+
requirements:
|
|
39
|
+
- - "~>"
|
|
40
|
+
- !ruby/object:Gem::Version
|
|
41
|
+
version: '13.0'
|
|
42
|
+
- !ruby/object:Gem::Dependency
|
|
43
|
+
name: rspec
|
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
|
45
|
+
requirements:
|
|
46
|
+
- - "~>"
|
|
47
|
+
- !ruby/object:Gem::Version
|
|
48
|
+
version: '3.0'
|
|
49
|
+
type: :development
|
|
50
|
+
prerelease: false
|
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
52
|
+
requirements:
|
|
53
|
+
- - "~>"
|
|
54
|
+
- !ruby/object:Gem::Version
|
|
55
|
+
version: '3.0'
|
|
56
|
+
- !ruby/object:Gem::Dependency
|
|
57
|
+
name: rubocop
|
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
|
59
|
+
requirements:
|
|
60
|
+
- - "~>"
|
|
61
|
+
- !ruby/object:Gem::Version
|
|
62
|
+
version: '1.0'
|
|
63
|
+
type: :development
|
|
64
|
+
prerelease: false
|
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
66
|
+
requirements:
|
|
67
|
+
- - "~>"
|
|
68
|
+
- !ruby/object:Gem::Version
|
|
69
|
+
version: '1.0'
|
|
70
|
+
description: A pure Ruby MySQL client library. No native extensions required.
|
|
71
|
+
email:
|
|
72
|
+
- tommy@tmtm.org
|
|
73
|
+
- alex@camulus.com
|
|
17
74
|
executables: []
|
|
18
75
|
extensions: []
|
|
19
|
-
extra_rdoc_files:
|
|
20
|
-
- README.rdoc
|
|
76
|
+
extra_rdoc_files: []
|
|
21
77
|
files:
|
|
22
|
-
-
|
|
78
|
+
- ".rspec"
|
|
79
|
+
- ".rubocop.yml"
|
|
80
|
+
- CHANGELOG.md
|
|
81
|
+
- LICENSE
|
|
82
|
+
- README.md
|
|
83
|
+
- Rakefile
|
|
84
|
+
- docker-compose.yml
|
|
23
85
|
- lib/mysql-pr.rb
|
|
24
|
-
- lib/mysql-pr/constants.rb
|
|
25
|
-
- lib/mysql-pr/protocol.rb
|
|
26
86
|
- lib/mysql-pr/charset.rb
|
|
87
|
+
- lib/mysql-pr/constants.rb
|
|
27
88
|
- lib/mysql-pr/error.rb
|
|
28
89
|
- lib/mysql-pr/packet.rb
|
|
29
|
-
-
|
|
30
|
-
-
|
|
31
|
-
|
|
90
|
+
- lib/mysql-pr/protocol.rb
|
|
91
|
+
- lib/mysql-pr/version.rb
|
|
92
|
+
- mysql-pr.gemspec
|
|
93
|
+
homepage: https://github.com/ajokela/mysql-pr
|
|
32
94
|
licenses:
|
|
33
|
-
- Ruby
|
|
95
|
+
- Ruby
|
|
96
|
+
metadata:
|
|
97
|
+
homepage_uri: https://github.com/ajokela/mysql-pr
|
|
98
|
+
source_code_uri: https://github.com/ajokela/mysql-pr
|
|
99
|
+
changelog_uri: https://github.com/ajokela/mysql-pr/blob/main/CHANGELOG.md
|
|
34
100
|
post_install_message:
|
|
35
101
|
rdoc_options: []
|
|
36
102
|
require_paths:
|
|
37
103
|
- lib
|
|
38
104
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
39
105
|
requirements:
|
|
40
|
-
- -
|
|
106
|
+
- - ">="
|
|
41
107
|
- !ruby/object:Gem::Version
|
|
42
|
-
version:
|
|
43
|
-
none: false
|
|
108
|
+
version: 3.0.0
|
|
44
109
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
45
110
|
requirements:
|
|
46
|
-
- -
|
|
111
|
+
- - ">="
|
|
47
112
|
- !ruby/object:Gem::Version
|
|
48
113
|
version: '0'
|
|
49
|
-
none: false
|
|
50
114
|
requirements: []
|
|
51
|
-
|
|
52
|
-
rubygems_version: 1.8.24
|
|
115
|
+
rubygems_version: 3.5.3
|
|
53
116
|
signing_key:
|
|
54
|
-
specification_version:
|
|
117
|
+
specification_version: 4
|
|
55
118
|
summary: Pure Ruby MySQL connector
|
|
56
|
-
test_files:
|
|
57
|
-
- spec/mysql_spec.rb
|
|
58
|
-
- spec/mysql/packet_spec.rb
|
|
59
|
-
...
|
|
119
|
+
test_files: []
|
data/README.rdoc
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
= mysql-pr
|
|
2
|
-
|
|
3
|
-
== Description
|
|
4
|
-
|
|
5
|
-
Pure Ruby MySQL connector.
|
|
6
|
-
|
|
7
|
-
== Features/Problems
|
|
8
|
-
|
|
9
|
-
* Ruby だけで書かれているのでコンパイル不要です。
|
|
10
|
-
|
|
11
|
-
* Ruby 1.9.x の M17N に対応しています。
|
|
12
|
-
|
|
13
|
-
* MySQL/Ruby 2.8.x とほぼ互換があります。
|
|
14
|
-
|
|
15
|
-
== Synopsis
|
|
16
|
-
|
|
17
|
-
使用例:
|
|
18
|
-
|
|
19
|
-
my = MysqlPR.connect('hostname', 'username', 'password', 'dbname')
|
|
20
|
-
my.query("select col1, col2 from tblname").each do |col1, col2|
|
|
21
|
-
p col1, col2
|
|
22
|
-
end
|
|
23
|
-
stmt = my.prepare('insert into tblname (col1,col2) values (?,?)')
|
|
24
|
-
stmt.execute 123, 'abc'
|
|
25
|
-
|
|
26
|
-
== Incompatible with MySQL/Ruby 2.8.x
|
|
27
|
-
|
|
28
|
-
* Ruby 1.8.x ではシフトJISのような安全でないマルチバイト文字セットに対して MysqlPR#escape_string を使用すると例外が発生します。
|
|
29
|
-
|
|
30
|
-
* いくつかのメソッドがありません: MysqlPR#debug, MysqlPR#change_user,
|
|
31
|
-
MysqlPR#create_db, MysqlPR#drop_db, MysqlPR#dump_debug_info,
|
|
32
|
-
MysqlPR#ssl_set, MysqlPR#reconnect
|
|
33
|
-
|
|
34
|
-
* MysqlPR#options でサポートしているオプションは次のものだけです:
|
|
35
|
-
MysqlPR::INIT_COMMAND, MysqlPR::OPT_CONNECT_TIMEOUT,
|
|
36
|
-
MysqlPR::OPT_LOCAL_INFILE, MysqlPR::OPT_READ_TIMEOUT,
|
|
37
|
-
MysqlPR::OPT_WRITE_TIMEOUT, MysqlPR::SET_CHARSET_NAME.
|
|
38
|
-
これら以外を指定すると "option not implementted" という warning が標準エラー出力に出力されます。
|
|
39
|
-
|
|
40
|
-
* MysqlPR#use_result は MysqlPR#store_result と同じです。つまりサーバーから一気に結果セットを読み込みます。
|
|
41
|
-
|
|
42
|
-
== Improvement from MySQL/Ruby 2.8.x
|
|
43
|
-
|
|
44
|
-
* Ruby 1.9.x の M17N に対応しています。
|
|
45
|
-
mysqld へのクエリ文字列やプリペアドステートメントで与える値は mysqld との接続の文字コードに自動的に変換されます。
|
|
46
|
-
mysqld からの結果文字列は接続文字コードとして取り出されます。
|
|
47
|
-
|
|
48
|
-
* MysqlPR::Result, MysqlPR::Stmt が Enumerable を include しています。
|
|
49
|
-
|
|
50
|
-
* ブロックなしの MysqlPR::Result#each, each_hash MysqlPR::Stmt#each, each_hash が Enumerator を返します。
|
|
51
|
-
|
|
52
|
-
* MysqlPR#charset= で接続 charset を指定できます。
|
|
53
|
-
|
|
54
|
-
* MysqlPR::Error だけでなく、エラー種別ごとにエラークラスが用意されてます。たとえば、構文エラーの場合は MysqlPR::ServerError::ParseError など。これらのエラーは MysqlPR::Error の継承クラスです。
|
|
55
|
-
|
|
56
|
-
== Copyright
|
|
57
|
-
|
|
58
|
-
Authors :: TOMITA Masahiro <tommy@tmtm.org>, Alex Jokela <alex@camulus.com>
|
|
59
|
-
Copyright :: Copyright (c) 2009-2012 TOMITA Masahiro, Copyright (c) 2012 Alex Jokela
|
|
60
|
-
License :: Ruby's
|
data/spec/mysql/packet_spec.rb
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
# coding: binary
|
|
2
|
-
describe MysqlPR::Packet do
|
|
3
|
-
def self._(s)
|
|
4
|
-
s.unpack('H*').first
|
|
5
|
-
end
|
|
6
|
-
subject{MysqlPR::Packet.new(data)}
|
|
7
|
-
describe '#lcb' do
|
|
8
|
-
[
|
|
9
|
-
["\xfb", nil],
|
|
10
|
-
["\xfc\x01\x02", 0x0201],
|
|
11
|
-
["\xfd\x01\x02\x03", 0x030201],
|
|
12
|
-
["\xfe\x01\x02\x03\x04\x05\x06\x07\x08", 0x0807060504030201],
|
|
13
|
-
["\x01", 0x01],
|
|
14
|
-
].each do |data, result|
|
|
15
|
-
context "for '#{_ data}'" do
|
|
16
|
-
let(:data){data}
|
|
17
|
-
it{subject.lcb.should == result}
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
describe '#lcs' do
|
|
23
|
-
[
|
|
24
|
-
["\x03\x41\x42\x43", 'ABC'],
|
|
25
|
-
["\x01", ''],
|
|
26
|
-
["", nil],
|
|
27
|
-
].each do |data, result|
|
|
28
|
-
context "for '#{_ data}'" do
|
|
29
|
-
let(:data){data}
|
|
30
|
-
it{subject.lcs.should == result}
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
describe '#read' do
|
|
36
|
-
let(:data){'ABCDEFGHI'}
|
|
37
|
-
it{subject.read(7).should == 'ABCDEFG'}
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
describe '#string' do
|
|
41
|
-
let(:data){"ABC\0DEF"}
|
|
42
|
-
it 'should NUL terminated String' do
|
|
43
|
-
subject.string.should == 'ABC'
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
describe '#utiny' do
|
|
48
|
-
[
|
|
49
|
-
["\x01", 0x01],
|
|
50
|
-
["\xFF", 0xff],
|
|
51
|
-
].each do |data, result|
|
|
52
|
-
context "for '#{_ data}'" do
|
|
53
|
-
let(:data){data}
|
|
54
|
-
it{subject.utiny.should == result}
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
describe '#ushort' do
|
|
60
|
-
[
|
|
61
|
-
["\x01\x02", 0x0201],
|
|
62
|
-
["\xFF\xFE", 0xfeff],
|
|
63
|
-
].each do |data, result|
|
|
64
|
-
context "for '#{_ data}'" do
|
|
65
|
-
let(:data){data}
|
|
66
|
-
it{subject.ushort.should == result}
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
describe '#ulong' do
|
|
72
|
-
[
|
|
73
|
-
["\x01\x02\x03\x04", 0x04030201],
|
|
74
|
-
["\xFF\xFE\xFD\xFC", 0xfcfdfeff],
|
|
75
|
-
].each do |data, result|
|
|
76
|
-
context "for '#{_ data}'" do
|
|
77
|
-
let(:data){data}
|
|
78
|
-
it{subject.ulong.should == result}
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
describe '#eof?' do
|
|
84
|
-
[
|
|
85
|
-
["\xfe\x00\x00\x00\x00", true],
|
|
86
|
-
["ABCDE", false],
|
|
87
|
-
].each do |data, result|
|
|
88
|
-
context "for '#{_ data}'" do
|
|
89
|
-
let(:data){data}
|
|
90
|
-
it{subject.eof?.should == result}
|
|
91
|
-
end
|
|
92
|
-
end
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
describe 'MysqlPR::Packet.lcb' do
|
|
98
|
-
[
|
|
99
|
-
[nil, "\xfb"],
|
|
100
|
-
[1, "\x01"],
|
|
101
|
-
[250, "\xfa"],
|
|
102
|
-
[251, "\xfc\xfb\x00"],
|
|
103
|
-
[65535, "\xfc\xff\xff"],
|
|
104
|
-
[65536, "\xfd\x00\x00\x01"],
|
|
105
|
-
[16777215, "\xfd\xff\xff\xff"],
|
|
106
|
-
[16777216, "\xfe\x00\x00\x00\x01\x00\x00\x00\x00"],
|
|
107
|
-
[0xffffffffffffffff, "\xfe\xff\xff\xff\xff\xff\xff\xff\xff"],
|
|
108
|
-
].each do |val, result|
|
|
109
|
-
context "with #{val}" do
|
|
110
|
-
it{MysqlPR::Packet.lcb(val).should == result}
|
|
111
|
-
end
|
|
112
|
-
end
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
describe 'MysqlPR::Packet.lcs' do
|
|
116
|
-
it{MysqlPR::Packet.lcs("hoge").should == "\x04hoge"}
|
|
117
|
-
it{MysqlPR::Packet.lcs("あいう".force_encoding("UTF-8")).should == "\x09\xe3\x81\x82\xe3\x81\x84\xe3\x81\x86"}
|
|
118
|
-
end
|