Class: MysqlPR::Protocol::ResultPacket

Inherits:
Object
  • Object
show all
Defined in:
lib/mysql-pr/protocol.rb

Overview

Result packet

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ ResultPacket

Returns a new instance of ResultPacket.



851
852
853
# File 'lib/mysql-pr/protocol.rb', line 851

def initialize(*args)
  @field_count, @affected_rows, @insert_id, @server_status, @warning_count, @message = args
end

Instance Attribute Details

#affected_rowsObject (readonly)

Returns the value of attribute affected_rows.



849
850
851
# File 'lib/mysql-pr/protocol.rb', line 849

def affected_rows
  @affected_rows
end

#field_countObject (readonly)

Returns the value of attribute field_count.



849
850
851
# File 'lib/mysql-pr/protocol.rb', line 849

def field_count
  @field_count
end

#insert_idObject (readonly)

Returns the value of attribute insert_id.



849
850
851
# File 'lib/mysql-pr/protocol.rb', line 849

def insert_id
  @insert_id
end

#messageObject (readonly)

Returns the value of attribute message.



849
850
851
# File 'lib/mysql-pr/protocol.rb', line 849

def message
  @message
end

#server_statusObject (readonly)

Returns the value of attribute server_status.



849
850
851
# File 'lib/mysql-pr/protocol.rb', line 849

def server_status
  @server_status
end

#warning_countObject (readonly)

Returns the value of attribute warning_count.



849
850
851
# File 'lib/mysql-pr/protocol.rb', line 849

def warning_count
  @warning_count
end

Class Method Details

.parse(pkt) ⇒ Object



833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
# File 'lib/mysql-pr/protocol.rb', line 833

def self.parse(pkt)
  field_count = pkt.lcb
  if field_count.zero?
    affected_rows = pkt.lcb
    insert_id = pkt.lcb
    server_status = pkt.ushort
    warning_count = pkt.ushort
    message = pkt.lcs
    new(field_count, affected_rows, insert_id, server_status, warning_count, message)
  elsif field_count.nil? # LOAD DATA LOCAL INFILE
    new(nil, nil, nil, nil, nil, pkt.to_s)
  else
    new(field_count)
  end
end