db-mariadb 0.7.0 → 0.9.0
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 +4 -4
- data/lib/.DS_Store +0 -0
- data/lib/db/mariadb/connection.rb +2 -2
- data/lib/db/mariadb/native.rb +29 -3
- data/lib/db/mariadb/native/connection.rb +19 -19
- data/lib/db/mariadb/native/field.rb +3 -3
- data/lib/db/mariadb/native/result.rb +15 -5
- data/lib/db/mariadb/native/types.rb +15 -7
- data/lib/db/mariadb/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cdabbcef5551dd3be495d8d81e4c9f0429869d122d6bd709e70b34e3559920c6
|
|
4
|
+
data.tar.gz: 7535f54e25c490e9269ded81e9e817f898ba2945d65beeb0d1d1e48058b8a41a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a0e0faeb7065dd9138baabdde82200083ad769d72ee5149a414a68b8122d4ad884c4308544d66d8aa9c6d55cb46759e5fc6890f1f718124d6f248018229bcdba
|
|
7
|
+
data.tar.gz: 37bc20b8fa6b5ee0b047ba8d2b95b2b2176b9414a918ba0831e039aac94ca8f8e1c849c8e483d6334b1c0e71a891c01b74b7223d36d17b0e2b3a705b2f9a9fa6
|
data/lib/.DS_Store
CHANGED
|
Binary file
|
data/lib/db/mariadb/native.rb
CHANGED
|
@@ -18,14 +18,40 @@
|
|
|
18
18
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
19
|
# THE SOFTWARE.
|
|
20
20
|
|
|
21
|
-
require 'ffi'
|
|
21
|
+
require 'ffi/module'
|
|
22
|
+
require 'ffi/module/config_tool'
|
|
22
23
|
|
|
23
24
|
module DB
|
|
24
25
|
module MariaDB
|
|
25
26
|
module Native
|
|
26
|
-
extend FFI::Library
|
|
27
|
+
extend FFI::Module::Library
|
|
28
|
+
extend FFI::Module::Loader
|
|
29
|
+
extend FFI::Module::ConfigTool
|
|
27
30
|
|
|
28
|
-
|
|
31
|
+
ffi_load('mariadb') ||
|
|
32
|
+
ffi_load_using_config_tool(%w{mariadb_config --libs}) ||
|
|
33
|
+
ffi_load_using_config_tool(%w{mysql_config --libs}) ||
|
|
34
|
+
ffi_load_failure(<<~EOF)
|
|
35
|
+
Unable to load libmariadb!
|
|
36
|
+
|
|
37
|
+
## Ubuntu
|
|
38
|
+
|
|
39
|
+
sudo apt-get install libmariadb-dev
|
|
40
|
+
|
|
41
|
+
## Arch Linux
|
|
42
|
+
|
|
43
|
+
sudo pacman -S mariadb
|
|
44
|
+
|
|
45
|
+
## MacPorts
|
|
46
|
+
|
|
47
|
+
sudo port install mariadb-10.5
|
|
48
|
+
sudo port select --set mysql mariadb-10.5
|
|
49
|
+
|
|
50
|
+
## Homebrew
|
|
51
|
+
|
|
52
|
+
brew install mariadb
|
|
53
|
+
|
|
54
|
+
EOF
|
|
29
55
|
end
|
|
30
56
|
end
|
|
31
57
|
end
|
|
@@ -39,32 +39,32 @@ module DB
|
|
|
39
39
|
CLIENT_MULTI_STATEMENT = 0x00010000
|
|
40
40
|
CLIENT_MULTI_RESULTS = 0x00020000
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
ffi_attach_function :mysql_init, [:pointer], :pointer
|
|
43
|
+
ffi_attach_function :mysql_options, [:pointer, :int, :pointer], :int
|
|
44
|
+
ffi_attach_function :mysql_get_socket, [:pointer], :int
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
ffi_attach_function :mysql_real_connect_start, [:pointer, :pointer, :string, :string, :string, :string, :int, :string, :long], :int
|
|
47
|
+
ffi_attach_function :mysql_real_connect_cont, [:pointer, :pointer, :int], :int
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
ffi_attach_function :mysql_real_query_start, [:pointer, :pointer, :string, :ulong], :int
|
|
50
|
+
ffi_attach_function :mysql_real_query_cont, [:pointer, :pointer, :int], :int
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
ffi_attach_function :mysql_use_result, [:pointer], :pointer
|
|
53
|
+
ffi_attach_function :mysql_next_result, [:pointer], :int
|
|
54
|
+
ffi_attach_function :mysql_more_results, [:pointer], :int
|
|
55
|
+
ffi_attach_function :mysql_free_result, [:pointer], :void
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
ffi_attach_function :mysql_affected_rows, [:pointer], :uint64
|
|
58
|
+
ffi_attach_function :mysql_insert_id, [:pointer], :uint64
|
|
59
|
+
ffi_attach_function :mysql_info, [:pointer], :string
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
ffi_attach_function :mysql_close, [:pointer], :void
|
|
62
|
+
ffi_attach_function :mysql_errno, [:pointer], :uint
|
|
63
|
+
ffi_attach_function :mysql_error, [:pointer], :string
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
ffi_attach_function :mysql_stat, [:pointer], :string
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
ffi_attach_function :mysql_real_escape_string, [:pointer, :pointer, :string, :size_t], :size_t
|
|
68
68
|
|
|
69
69
|
module IO
|
|
70
70
|
def self.new(fd, mode)
|
|
@@ -28,7 +28,7 @@ require 'json'
|
|
|
28
28
|
module DB
|
|
29
29
|
module MariaDB
|
|
30
30
|
module Native
|
|
31
|
-
Type =
|
|
31
|
+
Type = ffi_define_enumeration(:field_type, [
|
|
32
32
|
:decimal,
|
|
33
33
|
:tiny,
|
|
34
34
|
:short,
|
|
@@ -57,7 +57,7 @@ module DB
|
|
|
57
57
|
:var_string,
|
|
58
58
|
:string,
|
|
59
59
|
:geometry,
|
|
60
|
-
)
|
|
60
|
+
])
|
|
61
61
|
|
|
62
62
|
DEFAULT_TYPES = {
|
|
63
63
|
decimal: Types::Decimal,
|
|
@@ -74,7 +74,7 @@ module DB
|
|
|
74
74
|
year: Types::Integer,
|
|
75
75
|
newdate: Types::DateTime,
|
|
76
76
|
bit: Types::Integer,
|
|
77
|
-
json: JSON,
|
|
77
|
+
json: Types::JSON,
|
|
78
78
|
newdecimal: Types::Decimal,
|
|
79
79
|
enum: Types::Symbol,
|
|
80
80
|
set: Types::Integer,
|
|
@@ -23,13 +23,13 @@ require_relative 'field'
|
|
|
23
23
|
module DB
|
|
24
24
|
module MariaDB
|
|
25
25
|
module Native
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
ffi_attach_function :mysql_fetch_row_start, [:pointer, :pointer], :int
|
|
27
|
+
ffi_attach_function :mysql_fetch_row_cont, [:pointer, :pointer, :int], :int
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
ffi_attach_function :mysql_num_rows, [:pointer], :uint64
|
|
30
|
+
ffi_attach_function :mysql_num_fields, [:pointer], :uint32
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
ffi_attach_function :mysql_fetch_fields, [:pointer], :pointer
|
|
33
33
|
|
|
34
34
|
class Result < FFI::Pointer
|
|
35
35
|
def initialize(connection, types = {}, address)
|
|
@@ -109,6 +109,16 @@ module DB
|
|
|
109
109
|
@connection.check_error!("Reading recordset")
|
|
110
110
|
end
|
|
111
111
|
|
|
112
|
+
def map(&block)
|
|
113
|
+
results = []
|
|
114
|
+
|
|
115
|
+
self.each do |row|
|
|
116
|
+
results << yield(row)
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
return results
|
|
120
|
+
end
|
|
121
|
+
|
|
112
122
|
def to_a
|
|
113
123
|
rows = []
|
|
114
124
|
|
|
@@ -29,33 +29,41 @@ module DB
|
|
|
29
29
|
module Types
|
|
30
30
|
module Integer
|
|
31
31
|
def self.parse(string)
|
|
32
|
-
Integer(string)
|
|
32
|
+
Integer(string) if string
|
|
33
33
|
end
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
module Decimal
|
|
37
37
|
def self.parse(string)
|
|
38
|
-
BigDecimal(string)
|
|
38
|
+
BigDecimal(string) if string
|
|
39
39
|
end
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
module Float
|
|
43
43
|
def self.parse(string)
|
|
44
|
-
Float(string)
|
|
44
|
+
Float(string) if string
|
|
45
45
|
end
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
module Symbol
|
|
49
49
|
def self.parse(string)
|
|
50
|
-
string
|
|
50
|
+
string&.to_sym
|
|
51
51
|
end
|
|
52
52
|
end
|
|
53
53
|
|
|
54
54
|
module DateTime
|
|
55
55
|
def self.parse(string)
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
if string
|
|
57
|
+
parts = string.split(/[\-\s:]/)
|
|
58
|
+
|
|
59
|
+
return Time.utc(*parts)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
module JSON
|
|
65
|
+
def self.parse(string)
|
|
66
|
+
::JSON.parse(string, symbolize_names: true) if string
|
|
59
67
|
end
|
|
60
68
|
end
|
|
61
69
|
end
|
data/lib/db/mariadb/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: db-mariadb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.9.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Samuel Williams
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2021-
|
|
11
|
+
date: 2021-05-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
|
-
name: ffi
|
|
14
|
+
name: ffi-module
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - "
|
|
17
|
+
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version:
|
|
19
|
+
version: 0.3.0
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
|
-
- - "
|
|
24
|
+
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version:
|
|
26
|
+
version: 0.3.0
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: async-io
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|