Class: Mysql::Protocol::ExecutePacket
- Inherits:
-
Object
- Object
- Mysql::Protocol::ExecutePacket
- Defined in:
- lib/mysql/protocol.rb
Overview
Execute packet
Class Method Summary collapse
-
.null_bitmap(values) ⇒ Object
make null bitmap.
- .serialize(statement_id, cursor_type, values) ⇒ Object
Class Method Details
.null_bitmap(values) ⇒ Object
make null bitmap
If values is [1, nil, 2, 3, nil] then returns “x12”(0b10010).
832 833 834 835 836 837 |
# File 'lib/mysql/protocol.rb', line 832 def self.null_bitmap(values) bitmap = values.enum_for(:each_slice, 8).map do |vals| vals.reverse.inject(0){|b, v| (b << 1 | (v.nil? ? 1 : 0))} end return bitmap.pack("C*") end |
.serialize(statement_id, cursor_type, values) ⇒ Object
818 819 820 821 822 823 824 825 826 827 |
# File 'lib/mysql/protocol.rb', line 818 def self.serialize(statement_id, cursor_type, values) nbm = null_bitmap values netvalues = "" types = values.map do |v| t, n = Protocol.value2net v netvalues.concat n unless v.nil? t end [Mysql::COM_STMT_EXECUTE, statement_id, cursor_type, 1, nbm, 1, types.pack("v*"), netvalues].pack("CVCVa*Ca*a*") end |