Class: Vertica::Query
- Inherits:
-
Object
- Object
- Vertica::Query
- Defined in:
- lib/vertica/query.rb
Overview
Note:
This class is for internal use only, you should never interact with this class directly.
The Query class handles the state of the connection while a SQL query is being executed. The connection should call #run and it will block until the query has been handled by the connection, after which control will be given back to the Connection instance.
Instance Method Summary collapse
-
#initialize(connection, sql, row_handler: nil, copy_handler: nil) ⇒ Query
constructor
Instantiates a new query.
-
#inspect ⇒ String
Returns a user-consumable string representation of this query instance.
-
#run ⇒ String, Vertica::Result
Sends the query to the server, and processes the results.
Constructor Details
#initialize(connection, sql, row_handler: nil, copy_handler: nil) ⇒ Query
Instantiates a new query
19 20 21 22 23 24 25 |
# File 'lib/vertica/query.rb', line 19 def initialize(connection, sql, row_handler: nil, copy_handler: nil) @connection, @sql = connection, sql @buffer = row_handler.nil? && copy_handler.nil? ? [] : nil @row_handler = row_handler || lambda { |row| buffer_row(row) } @copy_handler = copy_handler @row_description, @error = nil, nil end |
Instance Method Details
#inspect ⇒ String
Returns a user-consumable string representation of this query instance.
46 47 48 |
# File 'lib/vertica/query.rb', line 46 def inspect "#<Vertica::Query:#{object_id} sql=#{@sql.inspect}>" end |
#run ⇒ String, Vertica::Result
Sends the query to the server, and processes the results.
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/vertica/query.rb', line 34 def run @connection.(Vertica::Protocol::Query.new(@sql)) begin ( = @connection.) end until .kind_of?(Vertica::Protocol::ReadyForQuery) raise @error unless @error.nil? return @result end |