Exemplo n.º 1
0
int heap_rprev(HP_INFO *info, byte *record)
{
  byte *pos;
  HP_SHARE *share=info->s;
  DBUG_ENTER("heap_rprev");

  if (info->lastinx < 0)
    DBUG_RETURN(my_errno=HA_ERR_WRONG_INDEX);

  if (info->current_ptr || (info->update & HA_STATE_NEXT_FOUND))
  {
    if ((info->update & HA_STATE_DELETED))
      pos= _hp_search(info,share->keydef+info->lastinx, info->lastkey, 3);
    else
      pos= _hp_search(info,share->keydef+info->lastinx, info->lastkey, 2);
  }
  else
  {
    pos=0;					/* Read next after last */
    my_errno=HA_ERR_KEY_NOT_FOUND;
  }
  if (!pos)
  {
    info->update=HA_STATE_PREV_FOUND;		/* For heap_rprev */
    if (my_errno == HA_ERR_KEY_NOT_FOUND)
      my_errno=HA_ERR_END_OF_FILE;
    DBUG_RETURN(my_errno);
  }
  memcpy(record,pos,(size_t) share->reclength);
  info->update=HA_STATE_AKTIV | HA_STATE_PREV_FOUND;
  DBUG_RETURN(0);
}
Exemplo n.º 2
0
int heap_rsame(register HP_INFO *info, byte *record, int inx)
{
  HP_SHARE *share=info->s;
  DBUG_ENTER("heap_rsame");

  test_active(info);
  if (info->current_ptr[share->reclength])
  {
    if (inx < -1 || inx >= (int) share->keys)
    {
      DBUG_RETURN(my_errno=HA_ERR_WRONG_INDEX);
    }
    else if (inx != -1)
    {
      info->lastinx=inx;
      _hp_make_key(share->keydef+inx,info->lastkey,record);
      if (!_hp_search(info,share->keydef+inx,info->lastkey,3))
      {
	info->update=0;
	DBUG_RETURN(my_errno);
      }
    }
    memcpy(record,info->current_ptr,(size_t) share->reclength);
    DBUG_RETURN(0);
  }
  info->update=0;

  DBUG_RETURN(my_errno=HA_ERR_RECORD_DELETED);
}
Exemplo n.º 3
0
int heap_rnext(HP_INFO *info, byte *record)
{
  byte *pos;
  HP_SHARE *share=info->s;
  DBUG_ENTER("heap_rnext");

  if (info->lastinx < 0)
    DBUG_RETURN(my_errno=HA_ERR_WRONG_INDEX);

  if (info->current_hash_ptr)
    pos= _hp_search_next(info,share->keydef+info->lastinx, info->lastkey,
			 info->current_hash_ptr);
  else
  {
    if (!info->current_ptr && (info->update & HA_STATE_NEXT_FOUND))
    {
      pos=0;					/* Read next after last */
      my_errno=HA_ERR_KEY_NOT_FOUND;
    }
    else if (!info->current_ptr)		/* Deleted or first call */
      pos= _hp_search(info,share->keydef+info->lastinx, info->lastkey, 0);
    else
      pos= _hp_search(info,share->keydef+info->lastinx, info->lastkey, 1);
  }

  if (!pos)
  {
    info->update=HA_STATE_NEXT_FOUND;		/* For heap_rprev */
    if (my_errno == HA_ERR_KEY_NOT_FOUND)
      my_errno=HA_ERR_END_OF_FILE;
    DBUG_RETURN(my_errno);
  }
  memcpy(record,pos,(size_t) share->reclength);
  info->update=HA_STATE_AKTIV | HA_STATE_NEXT_FOUND;
  DBUG_RETURN(0);
}