1
/* Copyright (C) 2000-2002, 2004, 2006 MySQL AB
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.
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.
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 */
16
/* Read a record from a random position */
21
Returns one of following values:
23
HA_ERR_RECORD_DELETED = Record is deleted.
24
HA_ERR_END_OF_FILE = EOF.
27
int heap_rrnd(register HP_INFO *info, uchar *record, uchar *pos)
29
HP_SHARE *share=info->s;
30
DBUG_ENTER("heap_rrnd");
31
DBUG_PRINT("enter",("info: 0x%lx pos: %lx",(long) info, (long) pos));
34
if (!(info->current_ptr= pos))
37
DBUG_RETURN(my_errno= HA_ERR_END_OF_FILE);
39
if (!info->current_ptr[share->reclength])
41
info->update= HA_STATE_PREV_FOUND | HA_STATE_NEXT_FOUND;
42
DBUG_RETURN(my_errno=HA_ERR_RECORD_DELETED);
44
info->update=HA_STATE_PREV_FOUND | HA_STATE_NEXT_FOUND | HA_STATE_AKTIV;
45
memcpy(record,info->current_ptr,(size_t) share->reclength);
46
DBUG_PRINT("exit", ("found record at 0x%lx", (long) info->current_ptr));
47
info->current_hash_ptr=0; /* Can't use rnext */
52
#ifdef WANT_OLD_HEAP_VERSION
55
If pos == -1 then read next record
56
Returns one of following values:
58
HA_ERR_RECORD_DELETED = Record is deleted.
59
HA_ERR_END_OF_FILE = EOF.
62
int heap_rrnd_old(register HP_INFO *info, uchar *record, ulong pos)
64
HP_SHARE *share=info->s;
65
DBUG_ENTER("heap_rrnd");
66
DBUG_PRINT("enter",("info: 0x%lx pos: %ld",info,pos));
69
if (pos == (ulong) -1)
71
pos= ++info->current_record;
72
if (pos % share->block.records_in_block && /* Quick next record */
73
pos < share->records+share->deleted &&
74
(info->update & HA_STATE_PREV_FOUND))
76
info->current_ptr+=share->block.recbuffer;
81
info->current_record=pos;
83
if (pos >= share->records+share->deleted)
86
DBUG_RETURN(my_errno= HA_ERR_END_OF_FILE);
89
/* Find record number pos */
90
hp_find_record(info, pos);
93
if (!info->current_ptr[share->reclength])
95
info->update= HA_STATE_PREV_FOUND | HA_STATE_NEXT_FOUND;
96
DBUG_RETURN(my_errno=HA_ERR_RECORD_DELETED);
98
info->update=HA_STATE_PREV_FOUND | HA_STATE_NEXT_FOUND | HA_STATE_AKTIV;
99
memcpy(record,info->current_ptr,(size_t) share->reclength);
100
DBUG_PRINT("exit",("found record at 0x%lx",info->current_ptr));
101
info->current_hash_ptr=0; /* Can't use rnext */
105
#endif /* WANT_OLD_HEAP_VERSION */