1
by brian
clean slate |
1 |
/* Copyright (C) 2000-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 |
#include "heapdef.h" |
|
17 |
||
612.2.13
by Monty Taylor
Work on removing global.h from headers that should be installed. |
18 |
#include <string.h> |
19 |
||
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
20 |
int heap_rkey(HP_INFO *info, unsigned char *record, int inx, const unsigned char *key, |
1
by brian
clean slate |
21 |
key_part_map keypart_map, enum ha_rkey_function find_flag) |
22 |
{
|
|
481
by Brian Aker
Remove all of uchar. |
23 |
unsigned char *pos; |
1
by brian
clean slate |
24 |
HP_SHARE *share= info->s; |
25 |
HP_KEYDEF *keyinfo= share->keydef + inx; |
|
26 |
||
27 |
if ((uint) inx >= share->keys) |
|
28 |
{
|
|
51.3.1
by Jay Pipes
Removed all DBUG symbols from heap storage engine |
29 |
return(my_errno= HA_ERR_WRONG_INDEX); |
1
by brian
clean slate |
30 |
}
|
31 |
info->lastinx= inx; |
|
365.2.8
by Monty Taylor
More MAX macros. |
32 |
info->current_record= UINT32_MAX; /* For heap_rrnd() */ |
1
by brian
clean slate |
33 |
|
34 |
if (keyinfo->algorithm == HA_KEY_ALG_BTREE) |
|
35 |
{
|
|
36 |
heap_rb_param custom_arg; |
|
37 |
||
38 |
custom_arg.keyseg= info->s->keydef[inx].seg; |
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
39 |
custom_arg.key_length= info->lastkey_len= |
481
by Brian Aker
Remove all of uchar. |
40 |
hp_rb_pack_key(keyinfo, (unsigned char*) info->lastkey, |
41 |
(unsigned char*) key, keypart_map); |
|
1
by brian
clean slate |
42 |
custom_arg.search_flag= SEARCH_FIND | SEARCH_SAME; |
43 |
/* for next rkey() after deletion */
|
|
44 |
if (find_flag == HA_READ_AFTER_KEY) |
|
45 |
info->last_find_flag= HA_READ_KEY_OR_NEXT; |
|
46 |
else if (find_flag == HA_READ_BEFORE_KEY) |
|
47 |
info->last_find_flag= HA_READ_KEY_OR_PREV; |
|
48 |
else
|
|
49 |
info->last_find_flag= find_flag; |
|
50 |
if (!(pos= tree_search_key(&keyinfo->rb_tree, info->lastkey, info->parents, |
|
51 |
&info->last_pos, find_flag, &custom_arg))) |
|
52 |
{
|
|
53 |
info->update= 0; |
|
51.3.1
by Jay Pipes
Removed all DBUG symbols from heap storage engine |
54 |
return(my_errno= HA_ERR_KEY_NOT_FOUND); |
1
by brian
clean slate |
55 |
}
|
481
by Brian Aker
Remove all of uchar. |
56 |
memcpy(&pos, pos + (*keyinfo->get_key_length)(keyinfo, pos), sizeof(unsigned char*)); |
1
by brian
clean slate |
57 |
info->current_ptr= pos; |
58 |
}
|
|
59 |
else
|
|
60 |
{
|
|
61 |
if (!(pos= hp_search(info, share->keydef + inx, key, 0))) |
|
62 |
{
|
|
63 |
info->update= 0; |
|
51.3.1
by Jay Pipes
Removed all DBUG symbols from heap storage engine |
64 |
return(my_errno); |
1
by brian
clean slate |
65 |
}
|
53.2.14
by Monty Taylor
Removed HA_END_SPACE_KEY and references to it. It was _supposed_ to be gone anyway, but the ifdef around it was broken (MYSQL_VERSION_ID was actually undefined.) |
66 |
if (!(keyinfo->flag & HA_NOSAME)) |
1
by brian
clean slate |
67 |
memcpy(info->lastkey, key, (size_t) keyinfo->length); |
68 |
}
|
|
244.1.1
by Harrison Fisk
Port Ebay/Google memory storage engine variable width columns. |
69 |
hp_extract_record(share, record, pos); |
1
by brian
clean slate |
70 |
info->update= HA_STATE_AKTIV; |
51.3.1
by Jay Pipes
Removed all DBUG symbols from heap storage engine |
71 |
return(0); |
1
by brian
clean slate |
72 |
}
|
73 |
||
74 |
||
75 |
/* Quick find of record */
|
|
76 |
||
481
by Brian Aker
Remove all of uchar. |
77 |
unsigned char* heap_find(HP_INFO *info, int inx, const unsigned char *key) |
1
by brian
clean slate |
78 |
{
|
79 |
return hp_search(info, info->s->keydef + inx, key, 0); |
|
80 |
}
|