ma_rsamepos.c 1.9 KB
Newer Older
1 2 3 4
/* Copyright (C) 2006 MySQL AB & MySQL Finland AB & TCX DataKonsult AB

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
5
   the Free Software Foundation; version 2 of the License.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */

/* read record through position and fix key-position */
/* As maria_rsame but supply a position */

#include "maria_def.h"


	/*
	** If inx >= 0 update index pointer
	** Returns one of the following values:
	**  0 = Ok.
	** HA_ERR_KEY_NOT_FOUND = Row is deleted
	** HA_ERR_END_OF_FILE   = End of file
	*/

unknown's avatar
unknown committed
30 31
int maria_rsame_with_pos(MARIA_HA *info, byte *record, int inx,
                         MARIA_RECORD_POS filepos)
32 33
{
  DBUG_ENTER("maria_rsame_with_pos");
34
  DBUG_PRINT("enter",("index: %d  filepos: %ld", inx, (long) filepos));
35

36 37
  if (inx < -1 ||
      (inx >= 0 && ! maria_is_key_active(info->s->state.key_map, inx)))
38 39 40 41 42
  {
    DBUG_RETURN(my_errno=HA_ERR_WRONG_INDEX);
  }

  info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
unknown's avatar
unknown committed
43
  if ((*info->s->read_record)(info, record, filepos))
44 45 46 47 48
  {
    if (my_errno == HA_ERR_RECORD_DELETED)
      my_errno=HA_ERR_KEY_NOT_FOUND;
    DBUG_RETURN(my_errno);
  }
unknown's avatar
unknown committed
49 50
  info->cur_row.lastpos= filepos;
  info->lastinx= inx;
51 52 53
  if (inx >= 0)
  {
    info->lastkey_length= _ma_make_key(info,(uint) inx,info->lastkey,record,
unknown's avatar
unknown committed
54
				      info->cur_row.lastpos);
55 56 57 58
    info->update|=HA_STATE_KEY_CHANGED;		/* Don't use indexposition */
  }
  DBUG_RETURN(0);
} /* maria_rsame_pos */