# File lib/innodb/page/index.rb, line 789
  def linear_search_from_cursor(search_cursor, key)
    Innodb::Stats.increment :linear_search_from_cursor

    this_rec = search_cursor.record

    if Innodb.debug?
      puts "linear_search_from_cursor: page=%i, level=%i, start=(%s)" % [
        offset,
        level,
        this_rec && this_rec.key_string,
      ]
    end

    # Iterate through all records until finding either a matching record or
    # one whose key is greater than the desired key.
    while this_rec && next_rec = search_cursor.record
      Innodb::Stats.increment :linear_search_from_cursor_record_scans

      if Innodb.debug?
        puts "linear_search_from_cursor: page=%i, level=%i, current=(%s)" % [
          offset,
          level,
          this_rec && this_rec.key_string,
        ]
      end

      # If we reach supremum, return the last non-system record we got.
      return this_rec if next_rec.header[:type] == :supremum

      if this_rec.compare_key(key) < 0
        return this_rec
      end

      if (this_rec.compare_key(key) >= 0) &&
        (next_rec.compare_key(key) < 0)
        # The desired key is either an exact match for this_rec or is greater
        # than it but less than next_rec. If this is a non-leaf page, that
        # will mean that the record will fall on the leaf page this node
        # pointer record points to, if it exists at all.
        return this_rec
      end

      this_rec = next_rec
    end

    this_rec
  end