1
by brian
clean slate |
1 |
/* Copyright (C) 2000-2002 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 |
/* Scan through all rows */
|
|
17 |
||
18 |
#include "heapdef.h" |
|
19 |
||
20 |
/*
|
|
21 |
Returns one of following values:
|
|
22 |
0 = Ok.
|
|
23 |
HA_ERR_RECORD_DELETED = Record is deleted.
|
|
24 |
HA_ERR_END_OF_FILE = EOF.
|
|
25 |
*/
|
|
26 |
||
27 |
int heap_scan_init(register HP_INFO *info) |
|
28 |
{
|
|
29 |
DBUG_ENTER("heap_scan_init"); |
|
30 |
info->lastinx= -1; |
|
31 |
info->current_record= (ulong) ~0L; /* No current record */ |
|
32 |
info->update=0; |
|
33 |
info->next_block=0; |
|
34 |
DBUG_RETURN(0); |
|
35 |
}
|
|
36 |
||
37 |
int heap_scan(register HP_INFO *info, uchar *record) |
|
38 |
{
|
|
39 |
HP_SHARE *share=info->s; |
|
40 |
ulong pos; |
|
41 |
DBUG_ENTER("heap_scan"); |
|
42 |
||
43 |
pos= ++info->current_record; |
|
44 |
if (pos < info->next_block) |
|
45 |
{
|
|
46 |
info->current_ptr+=share->block.recbuffer; |
|
47 |
}
|
|
48 |
else
|
|
49 |
{
|
|
50 |
info->next_block+=share->block.records_in_block; |
|
51 |
if (info->next_block >= share->records+share->deleted) |
|
52 |
{
|
|
53 |
info->next_block= share->records+share->deleted; |
|
54 |
if (pos >= info->next_block) |
|
55 |
{
|
|
56 |
info->update= 0; |
|
57 |
DBUG_RETURN(my_errno= HA_ERR_END_OF_FILE); |
|
58 |
}
|
|
59 |
}
|
|
60 |
hp_find_record(info, pos); |
|
61 |
}
|
|
62 |
if (!info->current_ptr[share->reclength]) |
|
63 |
{
|
|
64 |
DBUG_PRINT("warning",("Found deleted record")); |
|
65 |
info->update= HA_STATE_PREV_FOUND | HA_STATE_NEXT_FOUND; |
|
66 |
DBUG_RETURN(my_errno=HA_ERR_RECORD_DELETED); |
|
67 |
}
|
|
68 |
info->update= HA_STATE_PREV_FOUND | HA_STATE_NEXT_FOUND | HA_STATE_AKTIV; |
|
69 |
memcpy(record,info->current_ptr,(size_t) share->reclength); |
|
70 |
info->current_hash_ptr=0; /* Can't use read_next */ |
|
71 |
DBUG_RETURN(0); |
|
72 |
} /* heap_scan */ |