vertica 0.12.0 → 1.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +18 -20
- data/lib/vertica.rb +15 -8
- data/lib/vertica/column.rb +32 -13
- data/lib/vertica/connection.rb +143 -119
- data/lib/vertica/{messages/backend_messages → protocol/backend}/authentication.rb +1 -1
- data/lib/vertica/{messages/backend_messages → protocol/backend}/backend_key_data.rb +1 -1
- data/lib/vertica/{messages/backend_messages → protocol/backend}/bind_complete.rb +1 -1
- data/lib/vertica/{messages/backend_messages → protocol/backend}/close_complete.rb +1 -1
- data/lib/vertica/{messages/backend_messages → protocol/backend}/command_complete.rb +1 -1
- data/lib/vertica/{messages/backend_messages → protocol/backend}/copy_in_response.rb +2 -2
- data/lib/vertica/{messages/backend_messages → protocol/backend}/data_row.rb +1 -1
- data/lib/vertica/{messages/backend_messages → protocol/backend}/empty_query_response.rb +1 -1
- data/lib/vertica/{messages/backend_messages → protocol/backend}/error_response.rb +1 -1
- data/lib/vertica/{messages/backend_messages → protocol/backend}/no_data.rb +1 -1
- data/lib/vertica/{messages/backend_messages → protocol/backend}/notice_response.rb +6 -6
- data/lib/vertica/{messages/backend_messages → protocol/backend}/parameter_description.rb +2 -2
- data/lib/vertica/{messages/backend_messages → protocol/backend}/parameter_status.rb +3 -3
- data/lib/vertica/{messages/backend_messages → protocol/backend}/parse_complete.rb +1 -1
- data/lib/vertica/{messages/backend_messages → protocol/backend}/portal_suspended.rb +1 -1
- data/lib/vertica/{messages/backend_messages → protocol/backend}/ready_for_query.rb +2 -2
- data/lib/vertica/{messages/backend_messages → protocol/backend}/row_description.rb +9 -9
- data/lib/vertica/{messages/backend_messages → protocol/backend}/unknown.rb +1 -1
- data/lib/vertica/{messages/frontend_messages → protocol/frontend}/bind.rb +2 -3
- data/lib/vertica/{messages/frontend_messages → protocol/frontend}/cancel_request.rb +3 -4
- data/lib/vertica/{messages/frontend_messages → protocol/frontend}/close.rb +3 -3
- data/lib/vertica/{messages/frontend_messages → protocol/frontend}/copy_data.rb +6 -6
- data/lib/vertica/{messages/frontend_messages → protocol/frontend}/copy_done.rb +1 -1
- data/lib/vertica/{messages/frontend_messages → protocol/frontend}/copy_fail.rb +5 -5
- data/lib/vertica/{messages/frontend_messages → protocol/frontend}/describe.rb +3 -3
- data/lib/vertica/{messages/frontend_messages → protocol/frontend}/execute.rb +3 -3
- data/lib/vertica/{messages/frontend_messages → protocol/frontend}/flush.rb +1 -1
- data/lib/vertica/{messages/frontend_messages → protocol/frontend}/parse.rb +3 -3
- data/lib/vertica/protocol/frontend/password.rb +32 -0
- data/lib/vertica/{messages/frontend_messages → protocol/frontend}/query.rb +3 -4
- data/lib/vertica/{messages/frontend_messages → protocol/frontend}/ssl_request.rb +2 -2
- data/lib/vertica/{messages/frontend_messages → protocol/frontend}/startup.rb +2 -3
- data/lib/vertica/{messages/frontend_messages → protocol/frontend}/sync.rb +1 -1
- data/lib/vertica/{messages/frontend_messages → protocol/frontend}/terminate.rb +1 -1
- data/lib/vertica/protocol/message.rb +86 -0
- data/lib/vertica/query.rb +63 -44
- data/lib/vertica/result.rb +25 -47
- data/lib/vertica/row.rb +44 -0
- data/lib/vertica/row_description.rb +102 -0
- data/lib/vertica/version.rb +1 -1
- data/test/connection.yml.example +8 -8
- data/test/functional/functional_connection_test.rb +178 -0
- data/test/functional/{query_test.rb → functional_query_test.rb} +64 -67
- data/test/functional/functional_value_conversion_test.rb +117 -0
- data/test/test_helper.rb +1 -1
- data/test/unit/backend_message_test.rb +57 -57
- data/test/unit/column_test.rb +23 -23
- data/test/unit/frontend_message_test.rb +5 -5
- data/test/unit/quoting_test.rb +16 -5
- data/test/unit/result_test.rb +61 -0
- data/test/unit/row_description_test.rb +56 -0
- data/test/unit/row_test.rb +31 -0
- data/vertica.gemspec +1 -0
- metadata +67 -45
- data/lib/vertica/messages/frontend_messages/password.rb +0 -34
- data/lib/vertica/messages/message.rb +0 -79
- data/test/functional/connection_test.rb +0 -128
- data/test/functional/value_conversion_test.rb +0 -88
@@ -1,8 +1,8 @@
|
|
1
1
|
module Vertica
|
2
|
-
module
|
2
|
+
module Protocol
|
3
3
|
class NoticeResponse < BackendMessage
|
4
4
|
message_id 'N'
|
5
|
-
|
5
|
+
|
6
6
|
FIELDS_DEFINITIONS = [
|
7
7
|
{ :type => 'q', :name => "Internal Query", :method => :internal_query },
|
8
8
|
{ :type => 'S', :name => "Severity", :method => :severity },
|
@@ -17,9 +17,9 @@ module Vertica
|
|
17
17
|
{ :type => 'F', :name => "File", :method => :file },
|
18
18
|
{ :type => 'L', :name => "Line", :method => :line }
|
19
19
|
]
|
20
|
-
|
20
|
+
|
21
21
|
FIELDS = Hash[*FIELDS_DEFINITIONS.map { |f| [f[:type], f[:name]] }.flatten]
|
22
|
-
|
22
|
+
|
23
23
|
attr_reader :values
|
24
24
|
|
25
25
|
def initialize(data)
|
@@ -32,12 +32,12 @@ module Vertica
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def error_message
|
35
|
-
ordered_values = FIELDS_DEFINITIONS.map do |field|
|
35
|
+
ordered_values = FIELDS_DEFINITIONS.map do |field|
|
36
36
|
"#{field[:name]}: #{@values[field[:name]]}" if @values[field[:name]]
|
37
37
|
end
|
38
38
|
ordered_values.compact.join(', ')
|
39
39
|
end
|
40
|
-
|
40
|
+
|
41
41
|
FIELDS_DEFINITIONS.each do |field_def|
|
42
42
|
define_method(field_def[:method]) do
|
43
43
|
@values[field_def[:name]]
|
@@ -1,10 +1,10 @@
|
|
1
1
|
module Vertica
|
2
|
-
module
|
2
|
+
module Protocol
|
3
3
|
class ParameterDescription < BackendMessage
|
4
4
|
message_id 't'
|
5
5
|
|
6
6
|
attr_reader :parameter_types
|
7
|
-
|
7
|
+
|
8
8
|
def initialize(data)
|
9
9
|
parameter_count = data.unpack('n').first
|
10
10
|
parameter_type_ids = data.unpack("@2N#{parameter_count}")
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Vertica
|
2
|
-
module
|
2
|
+
module Protocol
|
3
3
|
class RowDescription < BackendMessage
|
4
4
|
message_id 'T'
|
5
5
|
|
@@ -12,15 +12,15 @@ module Vertica
|
|
12
12
|
field_count.times do |field_index|
|
13
13
|
field_info = data.unpack("@#{pos}Z*NnNnNn")
|
14
14
|
@fields << {
|
15
|
-
:name
|
16
|
-
:table_oid
|
17
|
-
:attribute_number
|
18
|
-
:data_type_oid
|
19
|
-
:data_type_size
|
20
|
-
:
|
21
|
-
:format_code
|
15
|
+
:name => field_info[0].force_encoding('UTF-8'),
|
16
|
+
:table_oid => field_info[1],
|
17
|
+
:attribute_number => field_info[2],
|
18
|
+
:data_type_oid => field_info[3],
|
19
|
+
:data_type_size => field_info[4],
|
20
|
+
:data_type_modifier => field_info[5],
|
21
|
+
:format_code => field_info[6],
|
22
22
|
}
|
23
|
-
|
23
|
+
|
24
24
|
pos += 19 + field_info[0].size
|
25
25
|
end
|
26
26
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Vertica
|
2
|
-
module
|
2
|
+
module Protocol
|
3
3
|
class Bind < FrontendMessage
|
4
4
|
message_id 'B'
|
5
5
|
|
@@ -9,11 +9,10 @@ module Vertica
|
|
9
9
|
@parameter_values = parameter_values
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
12
|
+
def message_body
|
13
13
|
bytes = [@portal_name, @prepared_statement_name, 0, @parameter_values.length].pack('Z*Z*nn')
|
14
14
|
bytes << @parameter_values.map { |val| val.nil? ? [-1].pack('N') : [val.length, val].pack('Na*') }.join('')
|
15
15
|
bytes << [0].pack('n')
|
16
|
-
message_string bytes
|
17
16
|
end
|
18
17
|
end
|
19
18
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Vertica
|
2
|
-
module
|
2
|
+
module Protocol
|
3
3
|
class CancelRequest < FrontendMessage
|
4
4
|
message_id nil
|
5
5
|
|
@@ -8,10 +8,9 @@ module Vertica
|
|
8
8
|
@backend_key = backend_key
|
9
9
|
end
|
10
10
|
|
11
|
-
def
|
12
|
-
|
11
|
+
def message_body
|
12
|
+
[80877102, @backend_pid, @backend_key].pack('N3')
|
13
13
|
end
|
14
|
-
|
15
14
|
end
|
16
15
|
end
|
17
16
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Vertica
|
2
|
-
module
|
2
|
+
module Protocol
|
3
3
|
class Close < FrontendMessage
|
4
4
|
message_id 'C'
|
5
5
|
|
@@ -12,8 +12,8 @@ module Vertica
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
def
|
16
|
-
|
15
|
+
def message_body
|
16
|
+
[@close_type, @close_name].pack('AZ*')
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -1,15 +1,15 @@
|
|
1
1
|
module Vertica
|
2
|
-
module
|
2
|
+
module Protocol
|
3
3
|
class CopyData < FrontendMessage
|
4
4
|
message_id 'd'
|
5
|
-
|
5
|
+
|
6
6
|
def initialize(data)
|
7
7
|
@data = data
|
8
8
|
end
|
9
|
-
|
10
|
-
def
|
11
|
-
|
12
|
-
end
|
9
|
+
|
10
|
+
def message_body
|
11
|
+
@data
|
12
|
+
end
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -1,14 +1,14 @@
|
|
1
1
|
module Vertica
|
2
|
-
module
|
2
|
+
module Protocol
|
3
3
|
class CopyFail < FrontendMessage
|
4
4
|
message_id 'f'
|
5
|
-
|
5
|
+
|
6
6
|
def initialize(error_message)
|
7
7
|
@error_message = error_message
|
8
8
|
end
|
9
|
-
|
10
|
-
def
|
11
|
-
|
9
|
+
|
10
|
+
def message_body
|
11
|
+
[@error_message].pack('Z*')
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Vertica
|
2
|
-
module
|
2
|
+
module Protocol
|
3
3
|
class Describe < FrontendMessage
|
4
4
|
message_id 'D'
|
5
5
|
|
@@ -12,8 +12,8 @@ module Vertica
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
def
|
16
|
-
|
15
|
+
def message_body
|
16
|
+
[@describe_type, @describe_name].pack('AZ*')
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Vertica
|
2
|
-
module
|
2
|
+
module Protocol
|
3
3
|
class Execute < FrontendMessage
|
4
4
|
message_id 'E'
|
5
5
|
|
@@ -8,8 +8,8 @@ module Vertica
|
|
8
8
|
@max_rows = max_rows
|
9
9
|
end
|
10
10
|
|
11
|
-
def
|
12
|
-
|
11
|
+
def message_body
|
12
|
+
[@portal_name, @max_rows].pack('Z*N')
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Vertica
|
2
|
-
module
|
2
|
+
module Protocol
|
3
3
|
class Parse < FrontendMessage
|
4
4
|
message_id 'P'
|
5
5
|
|
@@ -9,8 +9,8 @@ module Vertica
|
|
9
9
|
@param_types = param_types
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
13
|
-
|
12
|
+
def message_body
|
13
|
+
[@name, @query, @param_types.length, *@param_types].pack('Z*Z*nN*')
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Vertica
|
2
|
+
module Protocol
|
3
|
+
class Password < FrontendMessage
|
4
|
+
message_id 'p'
|
5
|
+
|
6
|
+
def initialize(password, auth_method: Vertica::Protocol::Authentication::CLEARTEXT_PASSWORD, salt: nil, user: nil)
|
7
|
+
@password = password
|
8
|
+
@auth_method, @salt, @user = auth_method, salt, user
|
9
|
+
end
|
10
|
+
|
11
|
+
def encoded_password
|
12
|
+
case @auth_method
|
13
|
+
when Vertica::Protocol::Authentication::CLEARTEXT_PASSWORD
|
14
|
+
@password
|
15
|
+
when Vertica::Protocol::Authentication::CRYPT_PASSWORD
|
16
|
+
@password.crypt(@salt)
|
17
|
+
when Vertica::Protocol::Authentication::MD5_PASSWORD
|
18
|
+
require 'digest/md5'
|
19
|
+
@password = Digest::MD5.hexdigest("#{@password}#{@user}")
|
20
|
+
@password = Digest::MD5.hexdigest("#{@password}#{@salt}")
|
21
|
+
@password = "md5#{@password}"
|
22
|
+
else
|
23
|
+
raise ArgumentError.new("unsupported authentication method: #{@auth_method}")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def message_body
|
28
|
+
[encoded_password].pack('Z*')
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
module Vertica
|
2
|
-
module
|
3
|
-
|
2
|
+
module Protocol
|
4
3
|
class Query < FrontendMessage
|
5
4
|
message_id 'Q'
|
6
5
|
|
@@ -8,8 +7,8 @@ module Vertica
|
|
8
7
|
@query_string = query_string
|
9
8
|
end
|
10
9
|
|
11
|
-
def
|
12
|
-
|
10
|
+
def message_body
|
11
|
+
[@query_string].pack('Z*')
|
13
12
|
end
|
14
13
|
end
|
15
14
|
end
|