MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mi_rsamepos.c
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
15 
16 /* read record through position and fix key-position */
17 /* As mi_rsame but supply a position */
18 
19 #include "myisamdef.h"
20 
21 
22  /*
23  ** If inx >= 0 update index pointer
24  ** Returns one of the following values:
25  ** 0 = Ok.
26  ** HA_ERR_KEY_NOT_FOUND = Row is deleted
27  ** HA_ERR_END_OF_FILE = End of file
28  */
29 
30 int mi_rsame_with_pos(MI_INFO *info, uchar *record, int inx, my_off_t filepos)
31 {
32  DBUG_ENTER("mi_rsame_with_pos");
33  DBUG_PRINT("enter",("index: %d filepos: %ld", inx, (long) filepos));
34 
35  if (inx < -1 ||
36  (inx >= 0 && ! mi_is_key_active(info->s->state.key_map, inx)))
37  {
38  DBUG_RETURN(my_errno=HA_ERR_WRONG_INDEX);
39  }
40 
41  info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
42  if ((*info->s->read_rnd)(info,record,filepos,0))
43  {
44  if (my_errno == HA_ERR_RECORD_DELETED)
45  my_errno=HA_ERR_KEY_NOT_FOUND;
46  DBUG_RETURN(my_errno);
47  }
48  info->lastpos=filepos;
49  info->lastinx=inx;
50  if (inx >= 0)
51  {
52  info->lastkey_length=_mi_make_key(info,(uint) inx,info->lastkey,record,
53  info->lastpos);
54  info->update|=HA_STATE_KEY_CHANGED; /* Don't use indexposition */
55  }
56  DBUG_RETURN(0);
57 } /* mi_rsame_pos */