1/* Copyright (c) 2000-2002, 2004-2007 MySQL AB
2 Use is subject to license terms
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; version 2 of the License.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
16
17/* Read a record from a random position */
18
19#include "heapdef.h"
20
21/*
22 Returns one of following values:
23 0 = Ok.
24 HA_ERR_RECORD_DELETED = Record is deleted.
25 HA_ERR_END_OF_FILE = EOF.
26*/
27
28int heap_rrnd(register HP_INFO *info, uchar *record, uchar *pos)
29{
30 HP_SHARE *share=info->s;
31 DBUG_ENTER("heap_rrnd");
32 DBUG_PRINT("enter",("info: %p pos: %p", info, pos));
33
34 info->lastinx= -1;
35 if (!(info->current_ptr= pos))
36 {
37 info->update= 0;
38 DBUG_RETURN(my_errno= HA_ERR_END_OF_FILE);
39 }
40 if (!info->current_ptr[share->visible])
41 {
42 info->update= HA_STATE_PREV_FOUND | HA_STATE_NEXT_FOUND;
43 DBUG_RETURN(my_errno=HA_ERR_RECORD_DELETED);
44 }
45 info->update=HA_STATE_PREV_FOUND | HA_STATE_NEXT_FOUND | HA_STATE_AKTIV;
46 memcpy(record,info->current_ptr,(size_t) share->reclength);
47 DBUG_PRINT("exit", ("found record at %p", info->current_ptr));
48 info->current_hash_ptr=0; /* Can't use rnext */
49 DBUG_RETURN(0);
50} /* heap_rrnd */
51