~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
/* Copyright (C) 2000-2001, 2005 MySQL AB
2
3
   This program is free software; you can redistribute it and/or modify
4
   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
   This program is distributed in the hope that it will be useful,
8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
9
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
   GNU General Public License for more details.
11
12
   You should have received a copy of the GNU General Public License
13
   along with this program; if not, write to the Free Software
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
16
/* read record through position and fix key-position */
17
/* As mi_rsame but supply a position */
18
19
#include "myisamdef.h"
492.1.7 by Monty Taylor
Moved test() to its own file.
20
#include <drizzled/util/test.h>
21
1 by brian
clean slate
22
23
24
	/*
25
	** If inx >= 0 update index pointer
26
	** Returns one of the following values:
27
	**  0 = Ok.
28
	** HA_ERR_KEY_NOT_FOUND = Row is deleted
29
	** HA_ERR_END_OF_FILE   = End of file
30
	*/
31
481 by Brian Aker
Remove all of uchar.
32
int mi_rsame_with_pos(MI_INFO *info, unsigned char *record, int inx, my_off_t filepos)
1 by brian
clean slate
33
{
34
  if (inx < -1 ||
35
      (inx >= 0 && ! mi_is_key_active(info->s->state.key_map, inx)))
36
  {
51.1.109 by Jay Pipes
Removed/replaced DBUG
37
    return(my_errno=HA_ERR_WRONG_INDEX);
1 by brian
clean slate
38
  }
39
40
  info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
41
  if ((*info->s->read_rnd)(info,record,filepos,0))
42
  {
43
    if (my_errno == HA_ERR_RECORD_DELETED)
44
      my_errno=HA_ERR_KEY_NOT_FOUND;
51.1.109 by Jay Pipes
Removed/replaced DBUG
45
    return(my_errno);
1 by brian
clean slate
46
  }
47
  info->lastpos=filepos;
48
  info->lastinx=inx;
49
  if (inx >= 0)
50
  {
51
    info->lastkey_length=_mi_make_key(info,(uint) inx,info->lastkey,record,
52
				      info->lastpos);
53
    info->update|=HA_STATE_KEY_CHANGED;		/* Don't use indexposition */
54
  }
51.1.109 by Jay Pipes
Removed/replaced DBUG
55
  return(0);
1 by brian
clean slate
56
} /* mi_rsame_pos */