# File lib/innodb/page/index.rb, line 536
  def record(offset)
    return nil unless offset
    return infimum  if offset == pos_infimum
    return supremum if offset == pos_supremum

    cursor(offset).forward.name("record[#{offset}]") do |c|
      # There is a header preceding the row itself, so back up and read it.
      header = c.peek { record_header(c) }

      this_record = {
        :format => page_header[:format],
        :offset => offset,
        :header => header,
        :next => header[:next] == 0 ? nil : (header[:next]),
      }

      if record_format
        this_record[:type] = record_format[:type]

        # Used to indicate whether a field is part of key/row/sys.
        fmap = [:key, :row, :sys].inject({}) do |h, k|
          this_record[k] = []
          record_format[k].each { |f| h[f.position] = k }
          h
        end

        # Read the fields present in this record.
        record_fields.each do |f|
          p = fmap[f.position]
          c.name("#{p.to_s}[#{f.name}]") do
            this_record[p] << {
              :name => f.name,
              :type => f.data_type.name,
              :value => f.value(c, this_record),
              :extern => f.extern(c, this_record),
            }.reject { |k, v| v.nil? }
          end
        end

        # If this is a node (non-leaf) page, it will have a child page number
        # (or "node pointer") stored as the last field.
        if level > 0
          # Read the node pointer in a node (non-leaf) page.
          this_record[:child_page_number] =
            c.name("child_page_number") { c.get_uint32 }
        end

        this_record[:length] = c.position - offset

        # Add system field accessors for convenience.
        this_record[:sys].each do |f|
          case f[:name]
          when "DB_TRX_ID"
            this_record[:transaction_id] = f[:value]
          when "DB_ROLL_PTR"
            this_record[:roll_pointer] = f[:value]
          end
        end
      end

      Innodb::Record.new(self, this_record)
    end
  end