1
by brian
clean slate |
1 |
/* Copyright (C) 2000-2002, 2004, 2006 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 a record from a random position */
|
|
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 |
||
481
by Brian Aker
Remove all of uchar. |
27 |
int heap_rrnd(register HP_INFO *info, unsigned char *record, unsigned char *pos) |
1
by brian
clean slate |
28 |
{
|
29 |
HP_SHARE *share=info->s; |
|
30 |
||
31 |
info->lastinx= -1; |
|
32 |
if (!(info->current_ptr= pos)) |
|
33 |
{
|
|
34 |
info->update= 0; |
|
51.3.1
by Jay Pipes
Removed all DBUG symbols from heap storage engine |
35 |
return(my_errno= HA_ERR_END_OF_FILE); |
1
by brian
clean slate |
36 |
}
|
244.1.1
by Harrison Fisk
Port Ebay/Google memory storage engine variable width columns. |
37 |
if (get_chunk_status(&share->recordspace, info->current_ptr) != CHUNK_STATUS_ACTIVE) |
1
by brian
clean slate |
38 |
{
|
244.1.1
by Harrison Fisk
Port Ebay/Google memory storage engine variable width columns. |
39 |
/* treat deleted and linked chunks as deleted */
|
1
by brian
clean slate |
40 |
info->update= HA_STATE_PREV_FOUND | HA_STATE_NEXT_FOUND; |
51.3.1
by Jay Pipes
Removed all DBUG symbols from heap storage engine |
41 |
return(my_errno=HA_ERR_RECORD_DELETED); |
1
by brian
clean slate |
42 |
}
|
43 |
info->update=HA_STATE_PREV_FOUND | HA_STATE_NEXT_FOUND | HA_STATE_AKTIV; |
|
244.1.1
by Harrison Fisk
Port Ebay/Google memory storage engine variable width columns. |
44 |
hp_extract_record(share, record, info->current_ptr); |
1
by brian
clean slate |
45 |
info->current_hash_ptr=0; /* Can't use rnext */ |
51.3.1
by Jay Pipes
Removed all DBUG symbols from heap storage engine |
46 |
return(0); |
1
by brian
clean slate |
47 |
} /* heap_rrnd */ |
48 |
||
49 |
||
50 |
#ifdef WANT_OLD_HEAP_VERSION
|
|
51 |
||
52 |
/*
|
|
53 |
If pos == -1 then read next record
|
|
54 |
Returns one of following values:
|
|
55 |
0 = Ok.
|
|
56 |
HA_ERR_RECORD_DELETED = Record is deleted.
|
|
57 |
HA_ERR_END_OF_FILE = EOF.
|
|
58 |
*/
|
|
59 |
||
481
by Brian Aker
Remove all of uchar. |
60 |
int heap_rrnd_old(register HP_INFO *info, unsigned char *record, uint32_t pos) |
1
by brian
clean slate |
61 |
{
|
62 |
HP_SHARE *share=info->s; |
|
244.1.1
by Harrison Fisk
Port Ebay/Google memory storage engine variable width columns. |
63 |
asdfasdf; |
1
by brian
clean slate |
64 |
info->lastinx= -1; |
291
by Brian Aker
Head ulong conversion. |
65 |
if (pos == (uint32_t) -1) |
1
by brian
clean slate |
66 |
{
|
67 |
pos= ++info->current_record; |
|
68 |
if (pos % share->block.records_in_block && /* Quick next record */ |
|
244.1.1
by Harrison Fisk
Port Ebay/Google memory storage engine variable width columns. |
69 |
pos < share->used_chunk_count+share->deleted_chunk_count && |
70 |
(info->update & HA_STATE_PREV_FOUND)) |
|
1
by brian
clean slate |
71 |
{
|
244.1.1
by Harrison Fisk
Port Ebay/Google memory storage engine variable width columns. |
72 |
info->current_ptr+=share->block.recbufferlen; |
1
by brian
clean slate |
73 |
goto end; |
74 |
}
|
|
75 |
}
|
|
76 |
else
|
|
77 |
info->current_record=pos; |
|
78 |
||
244.1.1
by Harrison Fisk
Port Ebay/Google memory storage engine variable width columns. |
79 |
if (pos >= share->used_chunk_count+share->deleted_chunk_count) |
1
by brian
clean slate |
80 |
{
|
81 |
info->update= 0; |
|
51.3.1
by Jay Pipes
Removed all DBUG symbols from heap storage engine |
82 |
return(my_errno= HA_ERR_END_OF_FILE); |
1
by brian
clean slate |
83 |
}
|
84 |
||
85 |
/* Find record number pos */
|
|
86 |
hp_find_record(info, pos); |
|
87 |
||
88 |
end: |
|
89 |
if (!info->current_ptr[share->reclength]) |
|
90 |
{
|
|
91 |
info->update= HA_STATE_PREV_FOUND | HA_STATE_NEXT_FOUND; |
|
51.3.1
by Jay Pipes
Removed all DBUG symbols from heap storage engine |
92 |
return(my_errno=HA_ERR_RECORD_DELETED); |
1
by brian
clean slate |
93 |
}
|
94 |
info->update=HA_STATE_PREV_FOUND | HA_STATE_NEXT_FOUND | HA_STATE_AKTIV; |
|
95 |
memcpy(record,info->current_ptr,(size_t) share->reclength); |
|
96 |
info->current_hash_ptr=0; /* Can't use rnext */ |
|
51.3.1
by Jay Pipes
Removed all DBUG symbols from heap storage engine |
97 |
return(0); |
1
by brian
clean slate |
98 |
} /* heap_rrnd */ |
99 |
||
100 |
#endif /* WANT_OLD_HEAP_VERSION */ |