vertica 0.8.1 → 0.9.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -0
- data/Gemfile.lock +23 -0
- data/Rakefile +12 -9
- data/VERSION +1 -1
- data/lib/vertica.rb +2 -7
- data/lib/vertica/connection.rb +47 -57
- data/lib/vertica/messages/backend_messages/authentication.rb +6 -7
- data/lib/vertica/messages/backend_messages/backend_key_data.rb +4 -7
- data/lib/vertica/messages/backend_messages/bind_complete.rb +1 -1
- data/lib/vertica/messages/backend_messages/close_complete.rb +1 -1
- data/lib/vertica/messages/backend_messages/command_complete.rb +13 -7
- data/lib/vertica/messages/backend_messages/data_row.rb +10 -10
- data/lib/vertica/messages/backend_messages/empty_query_response.rb +1 -1
- data/lib/vertica/messages/backend_messages/error_response.rb +2 -30
- data/lib/vertica/messages/backend_messages/no_data.rb +1 -1
- data/lib/vertica/messages/backend_messages/notice_response.rb +33 -7
- data/lib/vertica/messages/backend_messages/notification_response.rb +4 -9
- data/lib/vertica/messages/backend_messages/parameter_description.rb +5 -9
- data/lib/vertica/messages/backend_messages/parameter_status.rb +4 -8
- data/lib/vertica/messages/backend_messages/parse_complete.rb +1 -1
- data/lib/vertica/messages/backend_messages/portal_suspended.rb +1 -1
- data/lib/vertica/messages/backend_messages/ready_for_query.rb +3 -4
- data/lib/vertica/messages/backend_messages/row_description.rb +15 -15
- data/lib/vertica/messages/backend_messages/unknown.rb +2 -2
- data/lib/vertica/messages/frontend_messages/bind.rb +3 -12
- data/lib/vertica/messages/frontend_messages/cancel_request.rb +1 -5
- data/lib/vertica/messages/frontend_messages/close.rb +5 -9
- data/lib/vertica/messages/frontend_messages/describe.rb +5 -9
- data/lib/vertica/messages/frontend_messages/execute.rb +2 -6
- data/lib/vertica/messages/frontend_messages/flush.rb +1 -1
- data/lib/vertica/messages/frontend_messages/parse.rb +2 -8
- data/lib/vertica/messages/frontend_messages/password.rb +5 -6
- data/lib/vertica/messages/frontend_messages/query.rb +2 -3
- data/lib/vertica/messages/frontend_messages/ssl_request.rb +1 -2
- data/lib/vertica/messages/frontend_messages/startup.rb +6 -8
- data/lib/vertica/messages/frontend_messages/sync.rb +1 -1
- data/lib/vertica/messages/frontend_messages/terminate.rb +1 -1
- data/lib/vertica/messages/message.rb +9 -18
- data/lib/vertica/result.rb +8 -1
- data/test/functional/connection_test.rb +73 -0
- data/test/functional/query_test.rb +150 -0
- data/test/test_helper.rb +7 -13
- data/test/unit/backend_message_test.rb +106 -0
- metadata +72 -20
- data/lib/vertica/bit_helper.rb +0 -34
- data/lib/vertica/core_ext/numeric.rb +0 -13
- data/lib/vertica/core_ext/string.rb +0 -22
- data/lib/vertica/notice.rb +0 -11
- data/lib/vertica/vertica_socket.rb +0 -19
- data/test/connection_test.rb +0 -191
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vertica
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease: false
|
4
|
+
prerelease: true
|
6
5
|
segments:
|
7
6
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
|
7
|
+
- 9
|
8
|
+
- 0
|
9
|
+
- beta1
|
10
|
+
version: 0.9.0.beta1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jeff Smick
|
@@ -16,10 +16,61 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-
|
19
|
+
date: 2011-09-02 00:00:00 -04:00
|
20
20
|
default_executable:
|
21
|
-
dependencies:
|
22
|
-
|
21
|
+
dependencies:
|
22
|
+
- !ruby/object:Gem::Dependency
|
23
|
+
name: vertica
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
version: "0"
|
32
|
+
type: :runtime
|
33
|
+
prerelease: false
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: jeweler
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
segments:
|
43
|
+
- 0
|
44
|
+
version: "0"
|
45
|
+
type: :development
|
46
|
+
prerelease: false
|
47
|
+
version_requirements: *id002
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: jeweler
|
50
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
segments:
|
56
|
+
- 0
|
57
|
+
version: "0"
|
58
|
+
type: :development
|
59
|
+
prerelease: false
|
60
|
+
version_requirements: *id003
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: rake
|
63
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
segments:
|
69
|
+
- 0
|
70
|
+
version: "0"
|
71
|
+
type: :development
|
72
|
+
prerelease: false
|
73
|
+
version_requirements: *id004
|
23
74
|
description: Query Vertica with ruby
|
24
75
|
email: sprsquish@gmail.com
|
25
76
|
executables: []
|
@@ -30,16 +81,15 @@ extra_rdoc_files:
|
|
30
81
|
- LICENSE
|
31
82
|
- README.md
|
32
83
|
files:
|
84
|
+
- Gemfile
|
85
|
+
- Gemfile.lock
|
33
86
|
- LICENSE
|
34
87
|
- README.md
|
35
88
|
- Rakefile
|
36
89
|
- VERSION
|
37
90
|
- lib/vertica.rb
|
38
|
-
- lib/vertica/bit_helper.rb
|
39
91
|
- lib/vertica/column.rb
|
40
92
|
- lib/vertica/connection.rb
|
41
|
-
- lib/vertica/core_ext/numeric.rb
|
42
|
-
- lib/vertica/core_ext/string.rb
|
43
93
|
- lib/vertica/messages/backend_messages/authentication.rb
|
44
94
|
- lib/vertica/messages/backend_messages/backend_key_data.rb
|
45
95
|
- lib/vertica/messages/backend_messages/bind_complete.rb
|
@@ -72,12 +122,12 @@ files:
|
|
72
122
|
- lib/vertica/messages/frontend_messages/sync.rb
|
73
123
|
- lib/vertica/messages/frontend_messages/terminate.rb
|
74
124
|
- lib/vertica/messages/message.rb
|
75
|
-
- lib/vertica/notice.rb
|
76
125
|
- lib/vertica/notification.rb
|
77
126
|
- lib/vertica/result.rb
|
78
|
-
-
|
79
|
-
- test/
|
127
|
+
- test/functional/connection_test.rb
|
128
|
+
- test/functional/query_test.rb
|
80
129
|
- test/test_helper.rb
|
130
|
+
- test/unit/backend_message_test.rb
|
81
131
|
has_rdoc: true
|
82
132
|
homepage: http://github.com/sprsquish/vertica
|
83
133
|
licenses: []
|
@@ -92,19 +142,19 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
92
142
|
requirements:
|
93
143
|
- - ">="
|
94
144
|
- !ruby/object:Gem::Version
|
95
|
-
hash: 3
|
96
145
|
segments:
|
97
146
|
- 0
|
98
147
|
version: "0"
|
99
148
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
149
|
none: false
|
101
150
|
requirements:
|
102
|
-
- - "
|
151
|
+
- - ">"
|
103
152
|
- !ruby/object:Gem::Version
|
104
|
-
hash: 3
|
105
153
|
segments:
|
106
|
-
-
|
107
|
-
|
154
|
+
- 1
|
155
|
+
- 3
|
156
|
+
- 1
|
157
|
+
version: 1.3.1
|
108
158
|
requirements: []
|
109
159
|
|
110
160
|
rubyforge_project:
|
@@ -113,5 +163,7 @@ signing_key:
|
|
113
163
|
specification_version: 3
|
114
164
|
summary: Pure ruby library for interacting with Vertica
|
115
165
|
test_files:
|
116
|
-
- test/connection_test.rb
|
166
|
+
- test/functional/connection_test.rb
|
167
|
+
- test/functional/query_test.rb
|
117
168
|
- test/test_helper.rb
|
169
|
+
- test/unit/backend_message_test.rb
|
data/lib/vertica/bit_helper.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
module Vertica
|
2
|
-
module BitHelper
|
3
|
-
|
4
|
-
def readn(n)
|
5
|
-
s = read(n)
|
6
|
-
raise "couldn't read #{n} characters" if s.nil? or s.size != n # TODO make into a Vertica Exception
|
7
|
-
s
|
8
|
-
end
|
9
|
-
|
10
|
-
def read_byte
|
11
|
-
readn(1).to_byte
|
12
|
-
end
|
13
|
-
|
14
|
-
def read_network_int16
|
15
|
-
readn(2).to_network_int16
|
16
|
-
end
|
17
|
-
|
18
|
-
def read_network_int32
|
19
|
-
handle_endian_flavor(readn(4)).to_network_int32
|
20
|
-
end
|
21
|
-
|
22
|
-
def read_cstring
|
23
|
-
readline("\000").from_cstring
|
24
|
-
end
|
25
|
-
|
26
|
-
def handle_endian_flavor(s)
|
27
|
-
little_endian? ? s.reverse : s
|
28
|
-
end
|
29
|
-
|
30
|
-
def little_endian?
|
31
|
-
@little_endian ||= ([0x12345678].pack("L") == "\x12\x34\x56\x78" ? false : true)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
class String
|
2
|
-
def to_cstring
|
3
|
-
raise ArgumentError, "Invalid cstring" if self.include?("\000")
|
4
|
-
"#{self}\000"
|
5
|
-
end
|
6
|
-
|
7
|
-
def from_cstring
|
8
|
-
self[0..-2]
|
9
|
-
end
|
10
|
-
|
11
|
-
def to_byte
|
12
|
-
unpack('C').first
|
13
|
-
end
|
14
|
-
|
15
|
-
def to_network_int16
|
16
|
-
unpack('n').first
|
17
|
-
end
|
18
|
-
|
19
|
-
def to_network_int32
|
20
|
-
unpack('l').first
|
21
|
-
end
|
22
|
-
end
|
data/lib/vertica/notice.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
module Vertica
|
2
|
-
class VerticaSocket < TCPSocket
|
3
|
-
include BitHelper
|
4
|
-
|
5
|
-
def read_message
|
6
|
-
type = read_byte
|
7
|
-
size = read_network_int32
|
8
|
-
|
9
|
-
raise Vertica::Error::MessageError.new("Bad message size: #{size}") unless size >= 4
|
10
|
-
Messages::BackendMessage.factory type, self, size
|
11
|
-
end
|
12
|
-
|
13
|
-
def write_message(message)
|
14
|
-
raise ArgumentError, "invalid message: (#{message.inspect})" unless message.respond_to?(:to_bytes)
|
15
|
-
write message.to_bytes
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
19
|
-
end
|
data/test/connection_test.rb
DELETED
@@ -1,191 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "test_helper")
|
2
|
-
|
3
|
-
class ConnectionTest < Test::Unit::TestCase
|
4
|
-
|
5
|
-
def test_new
|
6
|
-
c = Vertica::Connection.new(TEST_CONNECTION_HASH)
|
7
|
-
assert !c.parameters.empty?
|
8
|
-
assert c.backend_pid
|
9
|
-
assert c.backend_key
|
10
|
-
assert c.transaction_status
|
11
|
-
assert c.opened?
|
12
|
-
assert !c.closed?
|
13
|
-
assert_equal({"server_version" => "8.0"}, c.parameters)
|
14
|
-
assert_equal([], c.notifications)
|
15
|
-
c.close
|
16
|
-
assert_equal({}, c.parameters)
|
17
|
-
assert_nil c.backend_pid
|
18
|
-
assert_nil c.backend_key
|
19
|
-
assert_nil c.transaction_status
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_new_with_ssl
|
23
|
-
c = Vertica::Connection.new(TEST_CONNECTION_HASH.merge(:ssl => true))
|
24
|
-
assert !c.parameters.empty?
|
25
|
-
assert c.backend_pid
|
26
|
-
assert c.backend_key
|
27
|
-
assert c.transaction_status
|
28
|
-
c.close
|
29
|
-
assert_equal({}, c.parameters)
|
30
|
-
assert_nil c.backend_pid
|
31
|
-
assert_nil c.backend_key
|
32
|
-
assert_nil c.transaction_status
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_reset
|
36
|
-
c = Vertica::Connection.new(TEST_CONNECTION_HASH)
|
37
|
-
assert !c.parameters.empty?
|
38
|
-
assert c.backend_pid
|
39
|
-
assert c.backend_key
|
40
|
-
assert c.transaction_status
|
41
|
-
c.reset
|
42
|
-
assert_equal({}, c.parameters)
|
43
|
-
assert_nil c.backend_pid
|
44
|
-
assert_nil c.backend_key
|
45
|
-
assert_nil c.transaction_status
|
46
|
-
c.close
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_new_with_error_response
|
50
|
-
assert_raises Vertica::Error::MessageError do
|
51
|
-
Vertica::Connection.new(TEST_CONNECTION_HASH.merge(:database => 'nonexistant_db'))
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def test_select_query_with_results
|
56
|
-
c = Vertica::Connection.new(TEST_CONNECTION_HASH)
|
57
|
-
r = c.query("SELECT * FROM test_table")
|
58
|
-
assert_equal 1, r.row_count
|
59
|
-
assert_equal 2, r.columns.length
|
60
|
-
assert_equal :in, r.columns[0].data_type
|
61
|
-
assert_equal 'id', r.columns[0].name
|
62
|
-
assert_equal :varchar, r.columns[1].data_type
|
63
|
-
assert_equal 'name', r.columns[1].name
|
64
|
-
assert_equal [[1, 'matt']], r.rows
|
65
|
-
c.close
|
66
|
-
end
|
67
|
-
|
68
|
-
def test_select_query_with_no_results
|
69
|
-
c = Vertica::Connection.new(TEST_CONNECTION_HASH)
|
70
|
-
r = c.query("SELECT * FROM test_table WHERE 1 != 1")
|
71
|
-
assert_equal 0, r.row_count
|
72
|
-
assert_equal 2, r.columns.length
|
73
|
-
assert_equal :in, r.columns[0].data_type
|
74
|
-
assert_equal 'id', r.columns[0].name
|
75
|
-
assert_equal :varchar, r.columns[1].data_type
|
76
|
-
assert_equal 'name', r.columns[1].name
|
77
|
-
assert_equal [], r.rows
|
78
|
-
c.close
|
79
|
-
end
|
80
|
-
|
81
|
-
def test_delete_of_no_rows
|
82
|
-
c = Vertica::Connection.new(TEST_CONNECTION_HASH)
|
83
|
-
r = c.query("DELETE FROM test_table WHERE 1 != 1")
|
84
|
-
assert_equal 1, r.row_count
|
85
|
-
assert_equal 1, r.columns.length
|
86
|
-
assert_equal :in, r.columns[0].data_type
|
87
|
-
assert_equal 'OUTPUT', r.columns[0].name
|
88
|
-
assert_equal [[0]], r.rows
|
89
|
-
c.close
|
90
|
-
end
|
91
|
-
|
92
|
-
def test_insert
|
93
|
-
c = Vertica::Connection.new(TEST_CONNECTION_HASH)
|
94
|
-
r = c.query("INSERT INTO test_table VALUES (2, 'stefanie')")
|
95
|
-
assert_equal 1, r.row_count
|
96
|
-
assert_equal 1, r.columns.length
|
97
|
-
assert_equal :in, r.columns[0].data_type
|
98
|
-
assert_equal 'OUTPUT', r.columns[0].name
|
99
|
-
assert_equal [[1]], r.rows
|
100
|
-
c.close
|
101
|
-
end
|
102
|
-
|
103
|
-
def test_delete_of_a_row
|
104
|
-
test_insert
|
105
|
-
c = Vertica::Connection.new(TEST_CONNECTION_HASH)
|
106
|
-
r = c.query("DELETE FROM test_table WHERE id = 2")
|
107
|
-
assert_equal 1, r.row_count
|
108
|
-
assert_equal 1, r.columns.length
|
109
|
-
assert_equal :in, r.columns[0].data_type
|
110
|
-
assert_equal 'OUTPUT', r.columns[0].name
|
111
|
-
assert_equal [[0]], r.rows
|
112
|
-
c.close
|
113
|
-
end
|
114
|
-
|
115
|
-
def test_empty_query
|
116
|
-
c = Vertica::Connection.new(TEST_CONNECTION_HASH)
|
117
|
-
assert_raises ArgumentError do
|
118
|
-
r = c.query("")
|
119
|
-
end
|
120
|
-
assert_raises ArgumentError do
|
121
|
-
r = c.query(nil)
|
122
|
-
end
|
123
|
-
c.close
|
124
|
-
end
|
125
|
-
|
126
|
-
def test_cancel
|
127
|
-
c = Vertica::Connection.new(TEST_CONNECTION_HASH)
|
128
|
-
Vertica::Connection.cancel(c)
|
129
|
-
c.close
|
130
|
-
end
|
131
|
-
|
132
|
-
def test_prepared_statement_with_no_params
|
133
|
-
c = Vertica::Connection.new(TEST_CONNECTION_HASH)
|
134
|
-
c.prepare("my_ps", "SELECT * FROM test_table")
|
135
|
-
r = c.execute_prepared("my_ps")
|
136
|
-
assert_equal 1, r.row_count
|
137
|
-
assert_equal 2, r.columns.length
|
138
|
-
assert_equal :in, r.columns[0].data_type
|
139
|
-
assert_equal 'id', r.columns[0].name
|
140
|
-
assert_equal :varchar, r.columns[1].data_type
|
141
|
-
assert_equal 'name', r.columns[1].name
|
142
|
-
assert_equal [[1, 'matt']], r.rows
|
143
|
-
c.close
|
144
|
-
end
|
145
|
-
|
146
|
-
def test_prepared_statement_with_one_param
|
147
|
-
c = Vertica::Connection.new(TEST_CONNECTION_HASH)
|
148
|
-
c.prepare("my_ps", "SELECT * FROM test_table WHERE id = ?", 1)
|
149
|
-
r = c.execute_prepared("my_ps", 1)
|
150
|
-
assert_equal 1, r.row_count
|
151
|
-
assert_equal 2, r.columns.length
|
152
|
-
assert_equal :in, r.columns[0].data_type
|
153
|
-
assert_equal 'id', r.columns[0].name
|
154
|
-
assert_equal :varchar, r.columns[1].data_type
|
155
|
-
assert_equal 'name', r.columns[1].name
|
156
|
-
assert_equal [[1, 'matt']], r.rows
|
157
|
-
c.close
|
158
|
-
end
|
159
|
-
|
160
|
-
def test_prepared_statement_with_two_params
|
161
|
-
c = Vertica::Connection.new(TEST_CONNECTION_HASH)
|
162
|
-
c.prepare("my_ps", "SELECT * FROM test_table WHERE id = ? OR id = ?", 2)
|
163
|
-
r = c.execute_prepared("my_ps", 1, 3)
|
164
|
-
assert_equal 1, r.row_count
|
165
|
-
assert_equal 2, r.columns.length
|
166
|
-
assert_equal :in, r.columns[0].data_type
|
167
|
-
assert_equal 'id', r.columns[0].name
|
168
|
-
assert_equal :varchar, r.columns[1].data_type
|
169
|
-
assert_equal 'name', r.columns[1].name
|
170
|
-
assert_equal [[1, 'matt']], r.rows
|
171
|
-
c.close
|
172
|
-
end
|
173
|
-
|
174
|
-
def test_double_select
|
175
|
-
c = Vertica::Connection.new(TEST_CONNECTION_HASH)
|
176
|
-
5.times do
|
177
|
-
r = c.query("SELECT * FROM test_table")
|
178
|
-
assert_equal 1, r.row_count
|
179
|
-
assert_equal 2, r.columns.length
|
180
|
-
assert_equal :in, r.columns[0].data_type
|
181
|
-
assert_equal 'id', r.columns[0].name
|
182
|
-
assert_equal :varchar, r.columns[1].data_type
|
183
|
-
assert_equal 'name', r.columns[1].name
|
184
|
-
assert_equal [[1, 'matt']], r.rows
|
185
|
-
end
|
186
|
-
c.close
|
187
|
-
end
|
188
|
-
|
189
|
-
# test parameters
|
190
|
-
|
191
|
-
end
|