db-mariadb 0.2.4 → 0.6.0

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: a86f522a5df8d261feb1be7625f9ac23ba8768184f4103a3479a6d6acfb2638e
4
- data.tar.gz: 551fe857397d0921d0f134c3701b26ff04cc4eabe1995c63128c0045350b17a2
3
+ metadata.gz: 86a404e12eedc21b57a6de7b9bdbd5233ec8e026f4983425482a6282850b208c
4
+ data.tar.gz: cfac0f1fd6b91606ddb9cf50c8bf4fc2a5cdf70ec7227f360b8f447e8cd8ba0f
5
5
  SHA512:
6
- metadata.gz: 978358ac2a66906fa116fa610d3280863b16412624f7d9ece0d17f010b70dd20a399d474c6005dc87ffb5756381ac8cf8dd4733935acd4cdc0deebcad195c137
7
- data.tar.gz: 4f1a7fb2d36f7c243ad7e737bb75dc79cf352284975da61a95cbbb7d644539aa9e5131fb811ce34aba5b3cd24fa195dab09c30a1b622dca62e8fba8f8061679d
6
+ metadata.gz: cebdcc060495de35cc9940d092cc613f598b3d512339b2589e8abdf45ab62c9e38f43c166ddeac76061ec44756dbe33b031db212c264cda2cade1e7eb9d70c28
7
+ data.tar.gz: 9df850b4e73f27df943c6154f21c9a870fe8c26bb88a4569ff66449e0cdb3e16f71f6e094c39463dbd0ce1ab86ecf92d6563d9ce771f6292b7c4664ac61aed27
data/lib/db/mariadb.rb CHANGED
@@ -24,4 +24,4 @@ require_relative 'mariadb/connection'
24
24
  require_relative 'mariadb/adapter'
25
25
 
26
26
  require 'db/adapters'
27
- DB::Adapters.register(:mysql, DB::MariaDB::Adapter)
27
+ DB::Adapters.register(:mariadb, DB::MariaDB::Adapter)
@@ -24,8 +24,6 @@ require_relative 'connection'
24
24
 
25
25
  module DB
26
26
  module MariaDB
27
- LOCAL = "mysql://localhost/test"
28
-
29
27
  class Adapter
30
28
  def initialize(**options)
31
29
  @options = options
@@ -27,12 +27,6 @@ require_relative 'native/connection'
27
27
 
28
28
  module DB
29
29
  module MariaDB
30
- module IO
31
- def self.new(fd, mode)
32
- Async::IO::Generic.new(::IO.new(fd, mode, autoclose: false))
33
- end
34
- end
35
-
36
30
  # This implements the interface between the underyling native interface interface and "standardised" connection interface.
37
31
  class Connection < Async::Pool::Resource
38
32
  def initialize(**options)
@@ -24,6 +24,9 @@ require_relative '../error'
24
24
  module DB
25
25
  module MariaDB
26
26
  module Native
27
+ MYSQL_PROTOCOL_TCP = 1
28
+
29
+ MYSQL_OPT_PROTOCOL = 9
27
30
  MYSQL_OPT_NONBLOCK = 6000
28
31
 
29
32
  MYSQL_WAIT_READ = 1
@@ -63,11 +66,21 @@ module DB
63
66
 
64
67
  attach_function :mysql_real_escape_string, [:pointer, :pointer, :string, :size_t], :size_t
65
68
 
69
+ module IO
70
+ def self.new(fd, mode)
71
+ Async::IO::Generic.new(::IO.new(fd, mode, autoclose: false))
72
+ end
73
+ end
74
+
66
75
  class Connection < FFI::Pointer
67
- def self.connect(io: IO, host: 'localhost', user: nil, password: nil, database: nil, port: 0, unix_socket: nil, client_flags: 0, compression: false, types: DEFAULT_TYPES, **options)
76
+ def self.connect(wrapper: IO, host: 'localhost', username: nil, password: nil, database: nil, port: 0, unix_socket: nil, client_flags: 0, compression: false, types: DEFAULT_TYPES, **options)
68
77
  pointer = Native.mysql_init(nil)
69
78
  Native.mysql_options(pointer, MYSQL_OPT_NONBLOCK, nil)
70
79
 
80
+ # if protocol
81
+ # Native.mysql_options(pointer, MYSQL_OPT_PROTOCOL, FFI::MemoryPointer.new(:uint, protocol))
82
+ # end
83
+
71
84
  client_flags |= CLIENT_MULTI_STATEMENT | CLIENT_MULTI_RESULTS
72
85
 
73
86
  if compression
@@ -76,11 +89,11 @@ module DB
76
89
 
77
90
  result = FFI::MemoryPointer.new(:pointer)
78
91
 
79
- status = Native.mysql_real_connect_start(result, pointer, host, user, password, database, port, unix_socket, client_flags);
92
+ status = Native.mysql_real_connect_start(result, pointer, host, username, password, database, port, unix_socket, client_flags);
93
+
94
+ io = wrapper.new(Native.mysql_get_socket(pointer), "r+")
80
95
 
81
96
  if status > 0
82
- io = IO.new(Native.mysql_get_socket(pointer), "r+")
83
-
84
97
  while status > 0
85
98
  if status & MYSQL_WAIT_READ
86
99
  io.wait_readable
@@ -22,6 +22,9 @@ require_relative '../native'
22
22
 
23
23
  require_relative 'types'
24
24
 
25
+ require 'date'
26
+ require 'json'
27
+
25
28
  module DB
26
29
  module MariaDB
27
30
  module Native
@@ -20,6 +20,6 @@
20
20
 
21
21
  module DB
22
22
  module MariaDB
23
- VERSION = "0.2.4"
23
+ VERSION = "0.6.0"
24
24
  end
25
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: db-mariadb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.6.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: 2020-07-05 00:00:00.000000000 Z
11
+ date: 2021-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -143,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
143
143
  - !ruby/object:Gem::Version
144
144
  version: '0'
145
145
  requirements: []
146
- rubygems_version: 3.0.3
146
+ rubygems_version: 3.1.2
147
147
  signing_key:
148
148
  specification_version: 4
149
149
  summary: An event-driven interface for MariaDB and MySQL servers.