int ha_partition::handle_ordered_prev(uchar *buf)
{
  int error;
  uint part_id= m_top_entry;
  uchar *rec_buf= queue_top(&m_queue) + PARTITION_BYTES_IN_POS;
  handler *file= m_file[part_id];
  DBUG_ENTER("ha_partition::handle_ordered_prev");

  if ((error= file->index_prev(rec_buf)))
  {
    if (error == HA_ERR_END_OF_FILE)
    {
      queue_remove(&m_queue, (uint) 0);
      if (m_queue.elements)
      {
	return_top_record(buf);
	DBUG_PRINT("info", ("Record returned from partition %d (2)",
			    m_top_entry));
        error= 0;
        table->status= 0;
      }
    }
    DBUG_RETURN(error);
  }
  queue_replaced(&m_queue);
  return_top_record(buf);
  DBUG_PRINT("info", ("Record returned from partition %d", m_top_entry));
  DBUG_RETURN(0);
}
int ha_partition::handle_ordered_prev(uchar *buf)
{
  int error;
  uint part_id= m_top_entry;
  uchar *rec_buf= queue_top(&m_queue) + PARTITION_BYTES_IN_POS;
  handler *file= m_file[part_id];
  DBUG_ENTER("ha_partition::handle_ordered_prev");

  if ((error= file->index_prev(rec_buf)))
  {
    if (error == HA_ERR_END_OF_FILE)
    {
      queue_remove(&m_queue, (uint) 0);
      if (m_queue.elements)
      {
	return_top_record(buf);
	DBUG_PRINT("info", ("Record returned from partition %d (2)",
			    m_top_entry));
        error= 0;
        table->status= 0;
      }
    }
    DBUG_RETURN(error);
  }
  queue_replaced(&m_queue);
  return_top_record(buf);
  DBUG_PRINT("info", ("Record returned from partition %d", m_top_entry));
  DBUG_RETURN(0);
}