vertica 0.9.3 → 0.9.4

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.
data/README.md CHANGED
@@ -5,7 +5,7 @@ about Vertica at http://www.vertica.com.
5
5
 
6
6
  This library currently supports connecting, executing SQL queries, and transferring data
7
7
  for a "COPY table FROM STDIN" statement. The gem is tested against Vertica version 4.1,
8
- 5.0, and 5.1, and Ruby version 1.8 and 1.9.
8
+ 5.0, 5.1, and 6.1, and Ruby version 1.8 and 1.9.
9
9
 
10
10
  # Install
11
11
 
@@ -56,7 +56,12 @@ Get all the result rows without buffering by providing a block:
56
56
  end
57
57
 
58
58
  connection.close
59
-
59
+
60
+ Note: you can only use the connection for one query at the time. If you try to run another
61
+ query when the connection is still busy delivering the results of a previous query, a
62
+ `Vertica::Error::SynchronizeError` will be raised. Use buffered resultsets to prevent this
63
+ problem.
64
+
60
65
  ### Buffered result
61
66
 
62
67
  Store the result of the query method as a variable to get a buffered resultset:
@@ -108,3 +113,4 @@ prefixed with <tt>test_ruby_vertica_</tt>.
108
113
  * [Matt Bauer](http://github.com/mattbauer) all the hard work
109
114
  * [Jeff Smick](http://github.com/sprsquish) current maintainer
110
115
  * [Willem van Bergen](http://github.com/wvanbergen) contributor
116
+ * [Camilo Lopez](http://github.com/camilo) contributor
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.3
1
+ 0.9.4
@@ -41,7 +41,7 @@ class Vertica::Connection
41
41
  raw_socket.sync = true
42
42
  raw_socket.connect
43
43
  else
44
- raise Vertica::Error::ConnectionError.new("SSL requested but server doesn't support it.")
44
+ raise Vertica::Error::SSLNotSupported.new("SSL requested but server doesn't support it.")
45
45
  end
46
46
  end
47
47
 
@@ -99,7 +99,7 @@ class Vertica::Connection
99
99
  end
100
100
 
101
101
  def interrupt
102
- raise Vertica::Error::ConnectionError, "Session cannopt be interrupted because the session ID is not known!" if session_id.nil?
102
+ raise Vertica::Error::InterruptImpossible, "Session cannopt be interrupted because the session ID is not known!" if session_id.nil?
103
103
  conn = self.class.new(options.merge(:interruptable => false, :role => nil, :search_path => nil))
104
104
  response = conn.query("SELECT CLOSE_SESSION(#{Vertica.quote(session_id)})").the_value
105
105
  conn.close
data/lib/vertica/error.rb CHANGED
@@ -2,6 +2,8 @@
2
2
  class Vertica::Error < StandardError
3
3
 
4
4
  class ConnectionError < Vertica::Error; end
5
+ class SSLNotSupported < ConnectionError; end
6
+ class InterruptImpossible < Vertica::Error; end
5
7
  class MessageError < Vertica::Error; end
6
8
  class SynchronizeError < Vertica::Error; end
7
9
  class EmptyQueryError < Vertica::Error; end
@@ -32,6 +34,7 @@ class Vertica::Error < StandardError
32
34
  '42601' => (SyntaxError = Class.new(Vertica::Error::QueryError)),
33
35
  '42V01' => (MissingRelation = Class.new(Vertica::Error::QueryError)),
34
36
  '42703' => (MissingColumn = Class.new(Vertica::Error::QueryError)),
35
- '22V04' => (CopyRejected = Class.new(Vertica::Error::QueryError))
37
+ '22V04' => (CopyRejected = Class.new(Vertica::Error::QueryError)),
38
+ '42501' => (PermissionDenied = Class.new(Vertica::Error::QueryError))
36
39
  }
37
40
  end
@@ -6,65 +6,65 @@ class ConnectionTest < Test::Unit::TestCase
6
6
  @connection.close if @connection
7
7
  end
8
8
 
9
- def test_new_connection
10
- @connection = Vertica::Connection.new(TEST_CONNECTION_HASH)
9
+ def assert_valid_open_connection(connection)
10
+ assert connection.opened?
11
+ assert !connection.closed?
11
12
 
12
- assert !@connection.parameters.empty?
13
- assert @connection.backend_pid
14
- assert @connection.backend_key
15
- assert @connection.transaction_status
16
- assert @connection.opened?
17
- assert !@connection.closed?
13
+ # connection variables
14
+ assert connection.backend_pid
15
+ assert connection.backend_key
16
+ assert connection.transaction_status
18
17
 
19
18
  # parameters
20
- assert @connection.parameters.kind_of?(Hash)
21
- assert @connection.parameters.include?('server_version')
19
+ assert connection.parameters.kind_of?(Hash)
20
+ assert connection.parameters.include?('server_version')
22
21
  end
23
-
24
- def test_close_connection
25
- @connection = Vertica::Connection.new(TEST_CONNECTION_HASH)
26
- @connection.close
27
22
 
28
- assert !@connection.opened?
29
- assert @connection.closed?
30
- assert_equal({}, @connection.parameters)
31
- assert_nil @connection.backend_pid
32
- assert_nil @connection.backend_key
33
- assert_nil @connection.transaction_status
23
+ def assert_valid_closed_connection(connection)
24
+ assert !connection.opened?
25
+ assert connection.closed?
26
+ assert_equal({}, connection.parameters)
27
+ assert_nil connection.backend_pid
28
+ assert_nil connection.backend_key
29
+ assert_nil connection.transaction_status
30
+ end
31
+
32
+ def test_opening_and_closing_connection
33
+ connection = Vertica::Connection.new(TEST_CONNECTION_HASH)
34
+ assert_valid_open_connection(connection)
35
+
36
+ connection.close
37
+ assert_valid_closed_connection(connection)
34
38
  end
35
39
 
36
40
  def test_connection_with_ssl
37
- @connection = Vertica::Connection.new(TEST_CONNECTION_HASH.merge(:ssl => true))
41
+ connection = Vertica::Connection.new(TEST_CONNECTION_HASH.merge(:ssl => true))
42
+ assert_valid_open_connection(connection)
43
+ assert connection.ssl?
38
44
 
39
- assert @connection.ssl?
40
- assert !@connection.parameters.empty?
41
- assert @connection.backend_pid
42
- assert @connection.backend_key
43
- assert @connection.transaction_status
44
-
45
- @connection.close
45
+ connection.close
46
+ assert_valid_closed_connection(connection)
47
+ assert !connection.ssl?
46
48
 
47
- assert_equal({}, @connection.parameters)
48
- assert_nil @connection.backend_pid
49
- assert_nil @connection.backend_key
50
- assert_nil @connection.transaction_status
49
+ rescue Vertica::Error::SSLNotSupported => e
50
+ puts "\nThe test server doesn't support SSL, so SSL connections could not be tested."
51
51
  end
52
52
 
53
53
  def test_reset_connection
54
- @connection = Vertica::Connection.new(TEST_CONNECTION_HASH)
55
- original_backend_pid = @connection.backend_pid
56
- original_backend_key = @connection.backend_key
54
+ connection = Vertica::Connection.new(TEST_CONNECTION_HASH)
55
+ original_backend_pid, original_backend_key = connection.backend_pid, connection.backend_key
57
56
 
58
- @connection.reset_connection
57
+ connection.reset_connection
59
58
 
60
- assert_not_equal original_backend_pid, @connection.backend_pid
61
- assert_not_equal original_backend_key, @connection.backend_key
62
- assert_equal :no_transaction, @connection.transaction_status
59
+ assert_valid_open_connection(connection)
60
+ assert_not_equal original_backend_pid, connection.backend_pid
61
+ assert_not_equal original_backend_key, connection.backend_key
62
+ assert_equal :no_transaction, connection.transaction_status
63
63
  end
64
64
 
65
- def test_interrupt_connection
66
- @connection = Vertica::Connection.new(TEST_CONNECTION_HASH.merge(:interruptable => true))
67
- assert @connection.interruptable?, "The connection should be interruptable!"
65
+ def test_interruptable_connection
66
+ connection = Vertica::Connection.new(TEST_CONNECTION_HASH.merge(:interruptable => true))
67
+ assert connection.interruptable?, "The connection should be interruptable!"
68
68
  end
69
69
 
70
70
  def test_new_with_error_response
@@ -193,7 +193,7 @@ class QueryTest < Test::Unit::TestCase
193
193
  assert_equal values.sort, [1,1,1,2,2,2,3,3,3]
194
194
  end
195
195
 
196
- def test_raise_on_synchronisity_problems
196
+ def test_raise_when_connection_is_in_use
197
197
  assert_raise(Vertica::Error::SynchronizeError) do
198
198
  @connection.query("SELECT 1 UNION SELECT 2") do |record|
199
199
  @connection.query("SELECT 3")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vertica
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 0.9.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,11 +11,11 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-12-10 00:00:00.000000000 Z
14
+ date: 2013-01-15 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rake
18
- requirement: &70275673064020 !ruby/object:Gem::Requirement
18
+ requirement: &70135370266420 !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
21
  - - ! '>='
@@ -23,10 +23,10 @@ dependencies:
23
23
  version: '0'
24
24
  type: :runtime
25
25
  prerelease: false
26
- version_requirements: *70275673064020
26
+ version_requirements: *70135370266420
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: jeweler
29
- requirement: &70275673063540 !ruby/object:Gem::Requirement
29
+ requirement: &70135370265940 !ruby/object:Gem::Requirement
30
30
  none: false
31
31
  requirements:
32
32
  - - ! '>='
@@ -34,7 +34,7 @@ dependencies:
34
34
  version: '0'
35
35
  type: :runtime
36
36
  prerelease: false
37
- version_requirements: *70275673063540
37
+ version_requirements: *70135370265940
38
38
  description: Query Vertica with ruby
39
39
  email: sprsquish@gmail.com
40
40
  executables: []